From 3e7c7b43d6fea891b7c9c63b35c009c300490df3 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 12 Jul 2024 11:10:34 +0000 Subject: [PATCH 001/162] feat: Initial draft of the new backend. + Func syntax tree + Essential functionality Func formatter + A new `codegen` package that includes the updated backend + Hacks in the compilation pipeline that allow to use both backends which is needed for differential testing. --- src/codegen/abi.ts | 26 ++ src/codegen/contract.ts | 103 ++++++ src/codegen/expression.ts | 733 ++++++++++++++++++++++++++++++++++++++ src/codegen/function.ts | 291 +++++++++++++++ src/codegen/index.ts | 4 + src/codegen/statement.ts | 498 ++++++++++++++++++++++++++ src/codegen/type.ts | 194 ++++++++++ src/codegen/util.ts | 57 +++ src/func/formatter.ts | 322 +++++++++++++++++ src/func/syntax.ts | 343 ++++++++++++++++++ src/pipeline/build.ts | 2 +- src/pipeline/compile.ts | 45 ++- 12 files changed, 2610 insertions(+), 8 deletions(-) create mode 100644 src/codegen/abi.ts create mode 100644 src/codegen/contract.ts create mode 100644 src/codegen/expression.ts create mode 100644 src/codegen/function.ts create mode 100644 src/codegen/index.ts create mode 100644 src/codegen/statement.ts create mode 100644 src/codegen/type.ts create mode 100644 src/codegen/util.ts create mode 100644 src/func/formatter.ts create mode 100644 src/func/syntax.ts diff --git a/src/codegen/abi.ts b/src/codegen/abi.ts new file mode 100644 index 000000000..55ec6a956 --- /dev/null +++ b/src/codegen/abi.ts @@ -0,0 +1,26 @@ +import { AstExpression, SrcInfo } from "../grammar/ast"; +import { CompilerContext } from "../context"; +import { TypeRef } from "../types/types"; +import { FuncAstExpr } from "../func/syntax"; + +/** + * A static map of functions defining Func expressions for Tact ABI functions and methods. + */ +export type AbiFunction = { + name: string; + resolve: (ctx: CompilerContext, args: TypeRef[], loc: SrcInfo) => TypeRef; + generate: ( + args: TypeRef[], + resolved: AstExpression[], + loc: SrcInfo, + ) => FuncAstExpr; +}; + +// TODO +export const MapFunctions: Map = new Map([]); + +// TODO +export const StructFunctions: Map = new Map([]); + +// TODO +export const GlobalFunctions: Map = new Map([]); diff --git a/src/codegen/contract.ts b/src/codegen/contract.ts new file mode 100644 index 000000000..e327f19f7 --- /dev/null +++ b/src/codegen/contract.ts @@ -0,0 +1,103 @@ +import { CompilerContext } from "../context"; +import { getAllTypes } from "../types/resolveDescriptors"; +import { TypeDescription } from "../types/types"; +import { getSortedTypes } from "../storage/resolveAllocation"; +import { FuncAstModule, FuncAstComment } from "../func/syntax"; +import { FunctionGen } from "./function"; + +/** + * Encapsulates generation of Func contracts from the Tact contract. + */ +export class ContractGen { + private constructor( + private ctx: CompilerContext, + private contractName: string, + private abiName: string, + ) {} + + static fromTact( + ctx: CompilerContext, + contractName: string, + abiName: string, + ): ContractGen { + return new ContractGen(ctx, contractName, abiName); + } + + /** + * Adds stdlib definitions to the generated module. + */ + private addStdlib(m: FuncAstModule): void { + // TODO + } + + private addSerializers(m: FuncAstModule): void { + const sortedTypes = getSortedTypes(this.ctx); + for (const t of sortedTypes) { + } + } + + private addAccessors(m: FuncAstModule): void { + // TODO + } + + private addInitSerializer(m: FuncAstModule): void { + // TODO + } + + private addStorageFunctions(m: FuncAstModule): void { + // TODO + } + + private addStaticFunctions(m: FuncAstModule): void { + // TODO + } + + private addExtensions(m: FuncAstModule): void { + // TODO + } + + /** + * Adds functions defined within the Tact contract to the generated Func module. + * TODO: Why do we need function from *all* the contracts? + */ + private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { + // TODO: Generate init + for (const tactFun of c.functions.values()) { + const funcFun = FunctionGen.fromTact(this.ctx, tactFun).generate(); + } + } + + private addMain(m: FuncAstModule): void { + // TODO + } + + /** + * Adds a comment entry to the module. + */ + private addComment(m: FuncAstModule, c: FuncAstComment): void { + m.entries.push(c); + } + + public generate(): FuncAstModule { + const m: FuncAstModule = { kind: "module", entries: [] }; + + const allTypes = Object.values(getAllTypes(this.ctx)); + const contracts = allTypes.filter((v) => v.kind === "contract"); + const contract = contracts.find((v) => v.name === this.contractName); + if (contract === undefined) { + throw Error(`Contract "${this.contractName}" not found`); + } + + this.addStdlib(m); + this.addSerializers(m); + this.addAccessors(m); + this.addInitSerializer(m); + this.addStorageFunctions(m); + this.addStaticFunctions(m); + this.addExtensions(m); + contracts.forEach((c) => this.addContractFunctions(m, c)); + this.addMain(m); + + return m; + } +} diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts new file mode 100644 index 000000000..cf1bc4638 --- /dev/null +++ b/src/codegen/expression.ts @@ -0,0 +1,733 @@ +import { CompilerContext } from "../context"; +import { TactConstEvalError, throwCompilationError } from "../errors"; +import { evalConstantExpression } from "../constEval"; +import { resolveFuncTypeUnpack } from "./type"; +import { MapFunctions, StructFunctions, GlobalFunctions } from "./abi"; +import { getExpType } from "../types/resolveExpression"; +import { cast, funcIdOf, ops } from "./util"; +import { printTypeRef, TypeRef, Value } from "../types/types"; +import { + getStaticConstant, + getType, + getStaticFunction, + hasStaticConstant, +} from "../types/resolveDescriptors"; +import { idText, AstExpression } from "../grammar/ast"; +import { FuncAstExpr, FuncAstIdExpr, FuncAstCallExpr } from "../func/syntax"; + +function isNull(f: AstExpression): boolean { + return f.kind === "null"; +} + +/** + * Encapsulates generation of Func expressions from the Tact expression. + */ +export class ExpressionGen { + /** + * @param tactExpr Expression to translate. + */ + private constructor( + private ctx: CompilerContext, + private tactExpr: AstExpression, + ) {} + + static fromTact( + ctx: CompilerContext, + tactExpr: AstExpression, + ): ExpressionGen { + return new ExpressionGen(ctx, tactExpr); + } + + /*** + * Generates FunC literals from Tact ones. + */ + private writeValue(val: Value): FuncAstExpr { + if (typeof val === "bigint") { + return { kind: "number_expr", value: val }; + } + // if (typeof val === "string") { + // const id = writeString(val, wCtx); + // wCtx.used(id); + // return `${id}()`; + // } + if (typeof val === "boolean") { + return { kind: "bool_expr", value: val }; + } + // if (Address.isAddress(val)) { + // const res = writeAddress(val, wCtx); + // wCtx.used(res); + // return res + "()"; + // } + // if (val instanceof Cell) { + // const res = writeCell(val, wCtx); + // wCtx.used(res); + // return `${res}()`; + // } + if (val === null) { + return { kind: "nil_expr" }; + } + // if (val instanceof CommentValue) { + // const id = writeComment(val.comment, wCtx); + // wCtx.used(id); + // return `${id}()`; + // } + // if (typeof val === "object" && "$tactStruct" in val) { + // // this is a struct value + // const structDescription = getType( + // wCtx.ctx, + // val["$tactStruct"] as string, + // ); + // const fields = structDescription.fields.map((field) => field.name); + // const id = writeStructConstructor(structDescription, fields, wCtx); + // wCtx.used(id); + // const fieldValues = structDescription.fields.map((field) => { + // if (field.name in val) { + // return writeValue(val[field.name]!, wCtx); + // } else { + // throw Error( + // `Struct value is missing a field: ${field.name}`, + // val, + // ); + // } + // }); + // return `${id}(${fieldValues.join(", ")})`; + // } + throw Error(`Invalid value: ${val}`); + } + + public writeExpression(): FuncAstExpr { + // literals and constant expressions are covered here + try { + const value = evalConstantExpression(this.tactExpr, this.ctx); + return this.writeValue(value); + } catch (error) { + if (!(error instanceof TactConstEvalError) || error.fatal) + throw error; + } + + // + // ID Reference + // + if (this.tactExpr.kind === "id") { + const t = getExpType(this.ctx, this.tactExpr); + + // Handle packed type + if (t.kind === "ref") { + const tt = getType(this.ctx, t.name); + if (tt.kind === "contract" || tt.kind === "struct") { + const value = resolveFuncTypeUnpack( + this.ctx, + t, + funcIdOf(this.tactExpr.text), + ); + return { kind: "id_expr", value }; + } + } + + if (t.kind === "ref_bounced") { + const tt = getType(this.ctx, t.name); + if (tt.kind === "struct") { + const value = resolveFuncTypeUnpack( + this.ctx, + t, + funcIdOf(this.tactExpr.text), + false, + true, + ); + } + } + + // Handle constant + if (hasStaticConstant(this.ctx, this.tactExpr.text)) { + const c = getStaticConstant(this.ctx, this.tactExpr.text); + return this.writeValue(c.value!); + } + + const value = funcIdOf(this.tactExpr.text); + return { kind: "id_expr", value }; + } + + // NOTE: We always wrap in parentheses to avoid operator precedence issues + if (this.tactExpr.kind === "op_binary") { + const negate: (expr: FuncAstExpr) => FuncAstExpr = (expr) => ({ + kind: "unary_expr", + op: "~", + value: expr, + }); + + // Special case for non-integer types and nullable + if (this.tactExpr.op === "==" || this.tactExpr.op === "!=") { + // TODO: Simplify. + if (isNull(this.tactExpr.left) && isNull(this.tactExpr.right)) { + return { + kind: "bool_expr", + value: this.tactExpr.op === "==", + }; + } else if ( + isNull(this.tactExpr.left) && + !isNull(this.tactExpr.right) + ) { + const fun = { kind: "id_expr", value: "null?" }; + const args = [ + ExpressionGen.fromTact( + this.ctx, + this.tactExpr.right, + ).writeExpression(), + ]; + const call = { + kind: "call_expr", + fun, + args, + } as FuncAstCallExpr; + return this.tactExpr.op === "==" ? call : negate(call); + } else if ( + !isNull(this.tactExpr.left) && + isNull(this.tactExpr.right) + ) { + const fun = { kind: "id_expr", value: "null?" }; + const args = [ + ExpressionGen.fromTact( + this.ctx, + this.tactExpr.left, + ).writeExpression(), + ]; + const call = { + kind: "call_expr", + fun, + args, + } as FuncAstCallExpr; + return this.tactExpr.op === "==" ? call : negate(call); + } + } + + // Special case for address + const lt = getExpType(this.ctx, this.tactExpr.left); + const rt = getExpType(this.ctx, this.tactExpr.right); + + // Case for addresses equality + if ( + lt.kind === "ref" && + rt.kind === "ref" && + lt.name === "Address" && + rt.name === "Address" + ) { + if (lt.optional && rt.optional) { + // wCtx.used(`__tact_slice_eq_bits_nullable`); + const fun = { + kind: "id_expr", + value: "__tact_slice_eq_bits_nullable", + }; + const args = [ + ExpressionGen.fromTact( + this.ctx, + this.tactExpr.left, + ).writeExpression(), + ExpressionGen.fromTact( + this.ctx, + this.tactExpr.right, + ).writeExpression(), + ]; + const call = { + kind: "call_expr", + fun, + args, + } as FuncAstCallExpr; + return this.tactExpr.op == "!=" ? negate(call) : call; + } + // if (lt.optional && !rt.optional) { + // // wCtx.used(`__tact_slice_eq_bits_nullable_one`); + // return `( ${prefix}__tact_slice_eq_bits_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)}) )`; + // } + // if (!lt.optional && rt.optional) { + // // wCtx.used(`__tact_slice_eq_bits_nullable_one`); + // return `( ${prefix}__tact_slice_eq_bits_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)}) )`; + // } + // // wCtx.used(`__tact_slice_eq_bits`); + // return `( ${prefix}__tact_slice_eq_bits(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)}) )`; + // } + // + // // Case for cells equality + // if ( + // lt.kind === "ref" && + // rt.kind === "ref" && + // lt.name === "Cell" && + // rt.name === "Cell" + // ) { + // const op = f.op === "==" ? "eq" : "neq"; + // if (lt.optional && rt.optional) { + // wCtx.used(`__tact_cell_${op}_nullable`); + // return `__tact_cell_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + // } + // if (lt.optional && !rt.optional) { + // wCtx.used(`__tact_cell_${op}_nullable_one`); + // return `__tact_cell_${op}_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + // } + // if (!lt.optional && rt.optional) { + // wCtx.used(`__tact_cell_${op}_nullable_one`); + // return `__tact_cell_${op}_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + // } + // wCtx.used(`__tact_cell_${op}`); + // return `__tact_cell_${op}(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + // } + // + // // Case for slices and strings equality + // if ( + // lt.kind === "ref" && + // rt.kind === "ref" && + // lt.name === rt.name && + // (lt.name === "Slice" || lt.name === "String") + // ) { + // const op = f.op === "==" ? "eq" : "neq"; + // if (lt.optional && rt.optional) { + // wCtx.used(`__tact_slice_${op}_nullable`); + // return `__tact_slice_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + // } + // if (lt.optional && !rt.optional) { + // wCtx.used(`__tact_slice_${op}_nullable_one`); + // return `__tact_slice_${op}_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + // } + // if (!lt.optional && rt.optional) { + // wCtx.used(`__tact_slice_${op}_nullable_one`); + // return `__tact_slice_${op}_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + // } + // wCtx.used(`__tact_slice_${op}`); + // return `__tact_slice_${op}(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + // } + // + // // Case for maps equality + // if (lt.kind === "map" && rt.kind === "map") { + // const op = f.op === "==" ? "eq" : "neq"; + // wCtx.used(`__tact_cell_${op}_nullable`); + // return `__tact_cell_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + // } + // + // // Check for int or boolean types + // if ( + // lt.kind !== "ref" || + // rt.kind !== "ref" || + // (lt.name !== "Int" && lt.name !== "Bool") || + // (rt.name !== "Int" && rt.name !== "Bool") + // ) { + // const file = f.loc.file; + // const loc_info = f.loc.interval.getLineAndColumn(); + // throw Error( + // `(Internal Compiler Error) Invalid types for binary operation: ${file}:${loc_info.lineNum}:${loc_info.colNum}`, + // ); // Should be unreachable + // } + // + // // Case for ints equality + // if (f.op === "==" || f.op === "!=") { + // const op = f.op === "==" ? "eq" : "neq"; + // if (lt.optional && rt.optional) { + // wCtx.used(`__tact_int_${op}_nullable`); + // return `__tact_int_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + // } + // if (lt.optional && !rt.optional) { + // wCtx.used(`__tact_int_${op}_nullable_one`); + // return `__tact_int_${op}_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + // } + // if (!lt.optional && rt.optional) { + // wCtx.used(`__tact_int_${op}_nullable_one`); + // return `__tact_int_${op}_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + // } + // if (f.op === "==") { + // return `(${writeExpression(f.left, wCtx)} == ${writeExpression(f.right, wCtx)})`; + // } else { + // return `(${writeExpression(f.left, wCtx)} != ${writeExpression(f.right, wCtx)})`; + // } + // } + // + // // Case for "&&" operator + // if (f.op === "&&") { + // return `( (${writeExpression(f.left, wCtx)}) ? (${writeExpression(f.right, wCtx)}) : (false) )`; + // } + // + // // Case for "||" operator + // if (f.op === "||") { + // return `( (${writeExpression(f.left, wCtx)}) ? (true) : (${writeExpression(f.right, wCtx)}) )`; + // } + // + // // Other ops + // return ( + // "(" + + // writeExpression(f.left, wCtx) + + // " " + + // f.op + + // " " + + // writeExpression(f.right, wCtx) + + // ")" + // ); + throw new Error("NYI"); + } + } + + // // + // // Unary operations: !, -, +, !! + // // NOTE: We always wrap in parenthesis to avoid operator precedence issues + // // + // + // if (f.kind === "op_unary") { + // // NOTE: Logical not is written as a bitwise not + // switch (f.op) { + // case "!": { + // return "(~ " + writeExpression(f.operand, wCtx) + ")"; + // } + // + // case "~": { + // return "(~ " + writeExpression(f.operand, wCtx) + ")"; + // } + // + // case "-": { + // return "(- " + writeExpression(f.operand, wCtx) + ")"; + // } + // + // case "+": { + // return "(+ " + writeExpression(f.operand, wCtx) + ")"; + // } + // + // // NOTE: Assert function that ensures that the value is not null + // case "!!": { + // const t = getExpType(wCtx.ctx, f.operand); + // if (t.kind === "ref") { + // const tt = getType(wCtx.ctx, t.name); + // if (tt.kind === "struct") { + // return `${ops.typeNotNull(tt.name, wCtx)}(${writeExpression(f.operand, wCtx)})`; + // } + // } + // + // wCtx.used("__tact_not_null"); + // return `${wCtx.used("__tact_not_null")}(${writeExpression(f.operand, wCtx)})`; + // } + // } + // } + // + // // + // // Field Access + // // NOTE: this branch resolves "a.b", where "a" is an expression and "b" is a field name + // // + // + // if (f.kind === "field_access") { + // // Resolve the type of the expression + // const src = getExpType(wCtx.ctx, f.aggregate); + // if ( + // (src.kind !== "ref" || src.optional) && + // src.kind !== "ref_bounced" + // ) { + // throwCompilationError( + // `Cannot access field of non-struct type: "${printTypeRef(src)}"`, + // f.loc, + // ); + // } + // const srcT = getType(wCtx.ctx, src.name); + // + // // Resolve field + // let fields: FieldDescription[]; + // + // fields = srcT.fields; + // if (src.kind === "ref_bounced") { + // fields = fields.slice(0, srcT.partialFieldCount); + // } + // + // const field = fields.find((v) => eqNames(v.name, f.field)); + // const cst = srcT.constants.find((v) => eqNames(v.name, f.field)); + // if (!field && !cst) { + // throwCompilationError( + // `Cannot find field ${idTextErr(f.field)} in struct ${idTextErr(srcT.name)}`, + // f.field.loc, + // ); + // } + // + // if (field) { + // // Trying to resolve field as a path + // const path = tryExtractPath(f); + // if (path) { + // // Prepare path + // const idd = writePathExpression(path); + // + // // Special case for structs + // if (field.type.kind === "ref") { + // const ft = getType(wCtx.ctx, field.type.name); + // if (ft.kind === "struct" || ft.kind === "contract") { + // return resolveFuncTypeUnpack(field.type, idd, wCtx); + // } + // } + // + // return idd; + // } + // + // // Getter instead of direct field access + // return `${ops.typeField(srcT.name, field.name, wCtx)}(${writeExpression(f.aggregate, wCtx)})`; + // } else { + // return writeValue(cst!.value!, wCtx); + // } + // } + // + + // + // Static Function Call + // + if (this.tactExpr.kind === "static_call") { + // Check global functions + if (GlobalFunctions.has(idText(this.tactExpr.function))) { + return GlobalFunctions.get( + idText(this.tactExpr.function), + )!.generate( + this.tactExpr.args.map((v) => getExpType(this.ctx, v)), + this.tactExpr.args, + this.tactExpr.loc, + ); + } + + const sf = getStaticFunction( + this.ctx, + idText(this.tactExpr.function), + ); + // if (sf.ast.kind === "native_function_decl") { + // n = idText(sf.ast.nativeName); + // if (n.startsWith("__tact")) { + // // wCtx.used(n); + // } + // } else { + // // wCtx.used(n); + // } + const fun = { + kind: "id_expr", + value: ops.global(idText(this.tactExpr.function)), + } as FuncAstIdExpr; + const args = this.tactExpr.args.map((argAst, i) => + ExpressionGen.fromTact(this.ctx, argAst).writeCastedExpression( + sf.params[i]!.type, + ), + ); + return { kind: "call_expr", fun, args }; + } + + // + // // + // // Struct Constructor + // // + // + // if (f.kind === "struct_instance") { + // const src = getType(wCtx.ctx, f.type); + // + // // Write a constructor + // const id = writeStructConstructor( + // src, + // f.args.map((v) => idText(v.field)), + // wCtx, + // ); + // wCtx.used(id); + // + // // Write an expression + // const expressions = f.args.map( + // (v) => + // writeCastedExpression( + // v.initializer, + // src.fields.find((v2) => eqNames(v2.name, v.field))! + // .type, + // wCtx, + // ), + // wCtx, + // ); + // return `${id}(${expressions.join(", ")})`; + // } + // + // + // Object-based function call + // + if (this.tactExpr.kind === "method_call") { + // Resolve source type + const src = getExpType(this.ctx, this.tactExpr.self); + + // Reference type + if (src.kind === "ref") { + if (src.optional) { + throwCompilationError( + `Cannot call function of non - direct type: "${printTypeRef(src)}"`, + this.tactExpr.loc, + ); + } + + // Render function call + const methodTy = getType(this.ctx, src.name); + + // Check struct ABI + if (methodTy.kind === "struct") { + if (StructFunctions.has(idText(this.tactExpr.method))) { + console.log(`getting ${idText(this.tactExpr.method)}`); + const abi = StructFunctions.get( + idText(this.tactExpr.method), + )!; + // return abi.generate( + // wCtx, + // [ + // src, + // ...this.tactExpr.args.map((v) => getExpType(this.ctx, v)), + // ], + // [this.tactExpr.self, ...this.tactExpr.args], + // this.tactExpr.loc, + // ); + } + } + + // Resolve function + const methodFun = methodTy.functions.get( + idText(this.tactExpr.method), + )!; + let name = ops.extension( + src.name, + idText(this.tactExpr.method), + ); + if ( + methodFun.ast.kind === "function_def" || + methodFun.ast.kind === "function_decl" + ) { + // wCtx.used(name); + } else { + name = idText(methodFun.ast.nativeName); + if (name.startsWith("__tact")) { + // wCtx.used(name); + } + } + + // Translate arguments + let argExprs = this.tactExpr.args.map((a, i) => + ExpressionGen.fromTact(this.ctx, a).writeCastedExpression( + methodFun.params[i]!.type, + ), + ); + + // Hack to replace a single struct argument to a tensor wrapper since otherwise + // func would convert (int) type to just int and break mutating functions + if (methodFun.isMutating) { + if (this.tactExpr.args.length === 1) { + const t = getExpType(this.ctx, this.tactExpr.args[0]!); + if (t.kind === "ref") { + const tt = getType(this.ctx, t.name); + if ( + (tt.kind === "contract" || + tt.kind === "struct") && + methodFun.params[0]!.type.kind === "ref" && + !methodFun.params[0]!.type.optional + ) { + const fun = { + kind: "id_expr", + value: ops.typeTensorCast(tt.name), + } as FuncAstIdExpr; + argExprs = [ + { + kind: "call_expr", + fun, + args: [argExprs[0]!], + }, + ]; + } + } + } + } + + // Generate function call + const selfExpr = ExpressionGen.fromTact( + this.ctx, + this.tactExpr.self, + ).writeExpression(); + if (methodFun.isMutating) { + if ( + this.tactExpr.self.kind === "id" || + this.tactExpr.self.kind === "field_access" + ) { + if (selfExpr.kind !== "id_expr") { + throw new Error( + `Impossible self kind: ${selfExpr.kind}`, + ); + } + const fun = { + kind: "id_expr", + value: `${selfExpr}~${name}`, + } as FuncAstIdExpr; + return { kind: "call_expr", fun, args: argExprs }; + } else { + const fun = { + kind: "id_expr", + value: ops.nonModifying(name), + } as FuncAstIdExpr; + return { + kind: "call_expr", + fun, + args: [selfExpr, ...argExprs], + }; + } + } else { + const fun = { + kind: "id_expr", + value: name, + } as FuncAstIdExpr; + return { + kind: "call_expr", + fun, + args: [selfExpr, ...argExprs], + }; + } + } + + // Map types + if (src.kind === "map") { + if (!MapFunctions.has(idText(this.tactExpr.method))) { + throwCompilationError( + `Map function "${idText(this.tactExpr.method)}" not found`, + this.tactExpr.loc, + ); + } + const abf = MapFunctions.get(idText(this.tactExpr.method))!; + return abf.generate( + [ + src, + ...this.tactExpr.args.map((v) => + getExpType(this.ctx, v), + ), + ], + [this.tactExpr.self, ...this.tactExpr.args], + this.tactExpr.loc, + ); + } + + if (src.kind === "ref_bounced") { + throw Error("Unimplemented"); + } + + throwCompilationError( + `Cannot call function of non - direct type: "${printTypeRef(src)}"`, + this.tactExpr.loc, + ); + } + + // + // // + // // Init of + // // + // + // if (f.kind === "init_of") { + // const type = getType(wCtx.ctx, f.contract); + // return `${ops.contractInitChild(idText(f.contract), wCtx)}(${["__tact_context_sys", ...f.args.map((a, i) => writeCastedExpression(a, type.init!.params[i]!.type, wCtx))].join(", ")})`; + // } + // + // // + // // Ternary operator + // // + // + // if (f.kind === "conditional") { + // return `(${writeExpression(f.condition, wCtx)} ? ${writeExpression(f.thenBranch, wCtx)} : ${writeExpression(f.elseBranch, wCtx)})`; + // } + // + // // + // // Unreachable + // // + // + throw Error(`Unknown expression: ${this.tactExpr.kind}`); + } + + public writeCastedExpression(to: TypeRef): FuncAstExpr { + const expr = getExpType(this.ctx, this.tactExpr); + return cast(this.ctx, expr, to, this.writeExpression()); + } +} diff --git a/src/codegen/function.ts b/src/codegen/function.ts new file mode 100644 index 000000000..af52b3d1b --- /dev/null +++ b/src/codegen/function.ts @@ -0,0 +1,291 @@ +import { CompilerContext } from "../context"; +import { enabledInline } from "../config/features"; +import { getType, resolveTypeRef } from "../types/resolveDescriptors"; +import { ops, funcIdOf } from "./util"; +import { TypeDescription, FunctionDescription, TypeRef } from "../types/types"; +import { + FuncAstFunction, + FuncAstStmt, + FuncAstFormalFunctionParam, + FuncAstFunctionAttribute, + FuncAstExpr, + FuncType, + FuncTensorType, + UNIT_TYPE, +} from "../func/syntax"; +import { StatementGen } from "./statement"; +import { resolveFuncTypeUnpack } from "./type"; + +/** + * Encapsulates generation of Func functions from the Tact function. + */ +export class FunctionGen { + /** + * @param tactFun Type description of the Tact function. + */ + private constructor( + private ctx: CompilerContext, + private tactFun: FunctionDescription, + ) {} + + static fromTact( + ctx: CompilerContext, + tactFun: FunctionDescription, + ): FunctionGen { + return new FunctionGen(ctx, tactFun); + } + + /** + * Generates Func types based on the Tact type definition. + * TODO: Why do they use a separate function for this. + */ + private resolveFuncType( + descriptor: TypeRef | TypeDescription | string, + optional: boolean = false, + usePartialFields: boolean = false, + ): FuncType { + // string + if (typeof descriptor === "string") { + return this.resolveFuncType( + getType(this.ctx, descriptor), + false, + usePartialFields, + ); + } + + // TypeRef + if (descriptor.kind === "ref") { + return this.resolveFuncType( + getType(this.ctx, descriptor.name), + descriptor.optional, + usePartialFields, + ); + } + if (descriptor.kind === "map") { + return { kind: "cell" }; + } + if (descriptor.kind === "ref_bounced") { + return this.resolveFuncType( + getType(this.ctx, descriptor.name), + false, + true, + ); + } + if (descriptor.kind === "void") { + return UNIT_TYPE; + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + if (descriptor.name === "Int") { + return { kind: "int" }; + } else if (descriptor.name === "Bool") { + return { kind: "int" }; + } else if (descriptor.name === "Slice") { + return { kind: "slice" }; + } else if (descriptor.name === "Cell") { + return { kind: "cell" }; + } else if (descriptor.name === "Builder") { + return { kind: "builder" }; + } else if (descriptor.name === "Address") { + return { kind: "slice" }; + } else if (descriptor.name === "String") { + return { kind: "slice" }; + } else if (descriptor.name === "StringBuilder") { + return { kind: "tuple" }; + } else { + throw Error(`Unknown primitive type: ${descriptor.name}`); + } + } else if (descriptor.kind === "struct") { + const fieldsToUse = usePartialFields + ? descriptor.fields.slice(0, descriptor.partialFieldCount) + : descriptor.fields; + if (optional || fieldsToUse.length === 0) { + return { kind: "tuple" }; + } else { + const value = fieldsToUse.map((v) => + this.resolveFuncType(v.type, false, usePartialFields), + ) as FuncTensorType; + return { kind: "tensor", value }; + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return { kind: "tuple" }; + } else { + const value = descriptor.fields.map((v) => + this.resolveFuncType(v.type, false, usePartialFields), + ) as FuncTensorType; + return { kind: "tensor", value }; + } + } + + // Unreachable + throw Error(`Unknown type: ${descriptor.kind}`); + } + + private resolveFuncPrimitive( + descriptor: TypeRef | TypeDescription | string, + ): boolean { + // String + if (typeof descriptor === "string") { + return this.resolveFuncPrimitive(getType(this.ctx, descriptor)); + } + + // TypeRef + if (descriptor.kind === "ref") { + return this.resolveFuncPrimitive( + getType(this.ctx, descriptor.name), + ); + } + if (descriptor.kind === "map") { + return true; + } + if (descriptor.kind === "ref_bounced") { + throw Error("Unimplemented: ref_bounced descriptor"); + } + if (descriptor.kind === "void") { + return true; + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + if (descriptor.name === "Int") { + return true; + } else if (descriptor.name === "Bool") { + return true; + } else if (descriptor.name === "Slice") { + return true; + } else if (descriptor.name === "Cell") { + return true; + } else if (descriptor.name === "Builder") { + return true; + } else if (descriptor.name === "Address") { + return true; + } else if (descriptor.name === "String") { + return true; + } else if (descriptor.name === "StringBuilder") { + return true; + } else { + throw Error(`Unknown primitive type: ${descriptor.name}`); + } + } else if (descriptor.kind === "struct") { + return false; + } else if (descriptor.kind === "contract") { + return false; + } + + // Unreachable + throw Error(`Unknown type: ${descriptor.kind}`); + } + + // NOTE: writeFunction + /** + * Generates Func function from the Tact funciton description. + */ + public generate(): FuncAstFunction { + if (this.tactFun.ast.kind !== "function_def") { + throw new Error(`Unknown function kind: ${this.tactFun.ast.kind}`); + } + + let returnTy = this.resolveFuncType(this.tactFun.returns); + // let returnsStr: string | null; + const self: TypeDescription | undefined = this.tactFun.self + ? getType(this.ctx, this.tactFun.self) + : undefined; + if (self !== undefined && this.tactFun.isMutating) { + // Add `self` to the method signature as it is mutating in the body. + const selfTy = this.resolveFuncType(self); + returnTy = { kind: "tensor", value: [selfTy, returnTy] }; + // returnsStr = resolveFuncTypeUnpack(ctx, self, funcIdOf("self")); + } + + const params: FuncAstFormalFunctionParam[] = this.tactFun.params.reduce( + (acc, a) => [ + ...acc, + { + kind: "function_param", + ty: this.resolveFuncType(a.type), + name: funcIdOf(a.name), + }, + ], + self + ? [ + { + kind: "function_param", + ty: this.resolveFuncType(self), + name: funcIdOf("self"), + }, + ] + : [], + ); + + // TODO: handle native functions delcs. should be in a separatre funciton + + const name = self + ? ops.extension(self.name, this.tactFun.name) + : ops.global(this.tactFun.name); + + // Prepare function attributes + let attrs: FuncAstFunctionAttribute[] = ["impure"]; + if (enabledInline(this.ctx) || this.tactFun.isInline) { + attrs.push("inline"); + } + // TODO: handle stdlib + // if (f.origin === "stdlib") { + // ctx.context("stdlib"); + // } + + // Write function body + const body: FuncAstStmt[] = []; + + // Add arguments + if (self) { + const varName = resolveFuncTypeUnpack( + this.ctx, + self, + funcIdOf("self"), + ); + const init: FuncAstExpr = { + kind: "id_expr", + value: funcIdOf("self"), + }; + body.push({ + kind: "var_def_stmt", + name: varName, + init, + ty: undefined, + }); + } + for (const a of this.tactFun.ast.params) { + if (!this.resolveFuncPrimitive(resolveTypeRef(this.ctx, a.type))) { + const name = resolveFuncTypeUnpack( + this.ctx, + resolveTypeRef(this.ctx, a.type), + funcIdOf(a.name), + ); + const init: FuncAstExpr = { + kind: "id_expr", + value: funcIdOf(a.name), + }; + body.push({ kind: "var_def_stmt", name, init, ty: undefined }); + } + } + + const selfName = + self !== undefined + ? resolveFuncTypeUnpack(this.ctx, self, funcIdOf("self")) + : undefined; + // Process statements + this.tactFun.ast.statements.forEach((stmt) => { + const funcStmt = StatementGen.fromTact( + this.ctx, + stmt, + selfName, + this.tactFun.returns, + ).writeStatement(); + body.push(funcStmt); + }); + + return { kind: "function", attrs, params, returnTy, body }; + } +} diff --git a/src/codegen/index.ts b/src/codegen/index.ts new file mode 100644 index 000000000..cdc3b3db3 --- /dev/null +++ b/src/codegen/index.ts @@ -0,0 +1,4 @@ +export { ContractGen } from "./contract"; +export { FunctionGen } from "./function"; +export { StatementGen } from "./statement"; +export { ExpressionGen } from "./expression"; diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts new file mode 100644 index 000000000..d03aefda8 --- /dev/null +++ b/src/codegen/statement.ts @@ -0,0 +1,498 @@ +import { CompilerContext } from "../context"; +import { funcIdOf } from "./util"; +import { getType, resolveTypeRef } from "../types/resolveDescriptors"; +import { getExpType } from "../types/resolveExpression"; +import { TypeRef } from "../types/types"; +import { + AstCondition, + AstStatement, + isWildcard, +} from "../grammar/ast"; +import { ExpressionGen } from "./expression"; +import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; +import { + FuncAstStmt, + FuncAstConditionStmt, + FuncAstExpr, + FuncAstTupleExpr, + FuncAstUnitExpr, +} from "../func/syntax"; + +/** + * Encapsulates generation of Func statements from the Tact statement. + */ +export class StatementGen { + /** + * @param tactStmt Tact AST statement + * @param selfName Actual name of the `self` parameter present in the Func code. + * @param returns The return value of the return statement. + */ + private constructor( + private ctx: CompilerContext, + private tactStmt: AstStatement, + private selfName?: string, + private returns?: TypeRef, + ) {} + + static fromTact( + ctx: CompilerContext, + tactStmt: AstStatement, + selfVarName?: string, + returns?: TypeRef, + ): StatementGen { + return new StatementGen(ctx, tactStmt, selfVarName, returns); + } + + /** + * Tranforms the Tact conditional statement to the Func one. + */ + private writeCondition( + f: AstCondition, + ): FuncAstConditionStmt { + const writeStmt = (stmt: AstStatement) => + StatementGen.fromTact( + this.ctx, + stmt, + this.selfName, + this.returns, + ).writeStatement(); + const condition = ExpressionGen.fromTact( + this.ctx, + f.condition, + ).writeExpression(); + const thenBlock = f.trueStatements.map(writeStmt); + const elseStmt: FuncAstConditionStmt | undefined = + f.falseStatements !== null && f.falseStatements.length > 0 + ? { + kind: "condition_stmt", + condition: undefined, + ifnot: false, + body: f.falseStatements.map(writeStmt), + else: undefined, + } + : f.elseif + ? this.writeCondition(f.elseif) + : undefined; + return { + kind: "condition_stmt", + condition, + ifnot: false, + body: thenBlock, + else: elseStmt, + }; + } + + public writeStatement(): FuncAstStmt { + switch (this.tactStmt.kind) { + case "statement_return": { + const kind = "return_stmt"; + const selfVar = this.selfName + ? { kind: "id", value: this.selfName } + : undefined; + const getValue = (expr: FuncAstExpr): FuncAstExpr => + this.selfName + ? ({ + kind: "tuple_expr", + values: [selfVar!, expr], + } as FuncAstTupleExpr) + : expr; + if (this.tactStmt.expression) { + const castedReturns = ExpressionGen.fromTact( + this.ctx, + this.tactStmt.expression, + ).writeCastedExpression(this.returns!); + return { kind, value: getValue(castedReturns) }; + } else { + const unit = { kind: "unit_expr" } as FuncAstUnitExpr; + return { kind, value: getValue(unit) }; + } + } + case "statement_let": { + // Underscore name case + if (isWildcard(this.tactStmt.name)) { + const expr = ExpressionGen.fromTact( + this.ctx, + this.tactStmt.expression, + ).writeExpression(); + return { kind: "expr_stmt", expr }; + } + + // Contract/struct case + const t = + this.tactStmt.type === null + ? getExpType(this.ctx, this.tactStmt.expression) + : resolveTypeRef(this.ctx, this.tactStmt.type); + + if (t.kind === "ref") { + const tt = getType(this.ctx, t.name); + if (tt.kind === "contract" || tt.kind === "struct") { + if (t.optional) { + const name = funcIdOf(this.tactStmt.name); + const init = ExpressionGen.fromTact( + this.ctx, + this.tactStmt.expression, + ).writeCastedExpression(t); + return { + kind: "var_def_stmt", + name, + ty: { kind: "tuple" }, + init, + }; + } else { + const name = resolveFuncTypeUnpack( + this.ctx, + t, + funcIdOf(this.tactStmt.name), + ); + const init = ExpressionGen.fromTact( + this.ctx, + this.tactStmt.expression, + ).writeCastedExpression(t); + return { + kind: "var_def_stmt", + name, + ty: undefined, + init, + }; + } + } + } + + const ty = resolveFuncType(this.ctx, t); + const name = funcIdOf(this.tactStmt.name); + const init = ExpressionGen.fromTact( + this.ctx, + this.tactStmt.expression, + ).writeCastedExpression(t); + return { kind: "var_def_stmt", name, ty, init }; + } + + // case "statement_assign": { + // // Prepare lvalue + // const lvaluePath = tryExtractPath(f.path); + // if (lvaluePath === null) { + // // typechecker is supposed to catch this + // throwInternalCompilerError( + // `Assignments are allowed only into path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + // f.path.loc, + // ); + // } + // const path = writePathExpression(lvaluePath); + // + // // Contract/struct case + // const t = getExpType(ctx.ctx, f.path); + // if (t.kind === "ref") { + // const tt = getType(ctx.ctx, t.name); + // if (tt.kind === "contract" || tt.kind === "struct") { + // ctx.append( + // `${resolveFuncTypeUnpack(t, path, ctx)} = ${writeCastedExpression(f.expression, t, ctx)};`, + // ); + // return; + // } + // } + // + // ctx.append( + // `${path} = ${writeCastedExpression(f.expression, t, ctx)};`, + // ); + // return; + // } + // case "statement_augmentedassign": { + // const lvaluePath = tryExtractPath(f.path); + // if (lvaluePath === null) { + // // typechecker is supposed to catch this + // throwInternalCompilerError( + // `Assignments are allowed only into path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + // f.path.loc, + // ); + // } + // const path = writePathExpression(lvaluePath); + // const t = getExpType(ctx.ctx, f.path); + // ctx.append( + // `${path} = ${cast(t, t, `${path} ${f.op} ${writeExpression(f.expression, ctx)}`, ctx)};`, + // ); + // return; + // } + case "statement_condition": { + return this.writeCondition(this.tactStmt); + } + case "statement_expression": { + const expr = ExpressionGen.fromTact( + this.ctx, + this.tactStmt.expression, + ).writeExpression(); + return { kind: "expr_stmt", expr }; + } + // case "statement_while": { + // ctx.append(`while (${writeExpression(f.condition, ctx)}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // }); + // ctx.append(`}`); + // return; + // } + // case "statement_until": { + // ctx.append(`do {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // }); + // ctx.append(`} until (${writeExpression(f.condition, ctx)});`); + // return; + // } + // case "statement_repeat": { + // ctx.append(`repeat (${writeExpression(f.iterations, ctx)}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // }); + // ctx.append(`}`); + // return; + // } + // case "statement_try": { + // ctx.append(`try {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // }); + // ctx.append("} catch (_) { }"); + // return; + // } + // case "statement_try_catch": { + // ctx.append(`try {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // }); + // if (isWildcard(f.catchName)) { + // ctx.append(`} catch (_) {`); + // } else { + // ctx.append(`} catch (_, ${funcIdOf(f.catchName)}) {`); + // } + // ctx.inIndent(() => { + // for (const s of f.catchStatements) { + // writeStatement(s, self, returns, ctx); + // } + // }); + // ctx.append(`}`); + // return; + // } + // case "statement_foreach": { + // const mapPath = tryExtractPath(f.map); + // if (mapPath === null) { + // // typechecker is supposed to catch this + // throwInternalCompilerError( + // `foreach is only allowed over maps that are path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + // f.map.loc, + // ); + // } + // const path = writePathExpression(mapPath); + // + // const t = getExpType(ctx.ctx, f.map); + // if (t.kind !== "map") { + // throw Error("Unknown map type"); + // } + // + // const flag = freshIdentifier("flag"); + // const key = isWildcard(f.keyName) + // ? freshIdentifier("underscore") + // : funcIdOf(f.keyName); + // const value = isWildcard(f.valueName) + // ? freshIdentifier("underscore") + // : funcIdOf(f.valueName); + // + // // Handle Int key + // if (t.key === "Int") { + // let bits = 257; + // let kind = "int"; + // if (t.keyAs?.startsWith("int")) { + // bits = parseInt(t.keyAs.slice(3), 10); + // } else if (t.keyAs?.startsWith("uint")) { + // bits = parseInt(t.keyAs.slice(4), 10); + // kind = "uint"; + // } + // if (t.value === "Int") { + // let vBits = 257; + // let vKind = "int"; + // if (t.valueAs?.startsWith("int")) { + // vBits = parseInt(t.valueAs.slice(3), 10); + // } else if (t.valueAs?.startsWith("uint")) { + // vBits = parseInt(t.valueAs.slice(4), 10); + // vKind = "uint"; + // } + // + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_${vKind}`)}(${path}, ${bits}, ${vBits});`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_${vKind}`)}(${path}, ${bits}, ${key}, ${vBits});`, + // ); + // }); + // ctx.append(`}`); + // } else if (t.value === "Bool") { + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_int`)}(${path}, ${bits}, 1);`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_int`)}(${path}, ${bits}, ${key}, 1);`, + // ); + // }); + // ctx.append(`}`); + // } else if (t.value === "Cell") { + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_cell`)}(${path}, ${bits});`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_cell`)}(${path}, ${bits}, ${key});`, + // ); + // }); + // ctx.append(`}`); + // } else if (t.value === "Address") { + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_slice`)}(${path}, ${bits});`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_slice`)}(${path}, ${bits}, ${key});`, + // ); + // }); + // ctx.append(`}`); + // } else { + // // value is struct + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_cell`)}(${path}, ${bits});`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // ctx.append( + // `var ${resolveFuncTypeUnpack(t.value, funcIdOf(f.valueName), ctx)} = ${ops.typeNotNull(t.value, ctx)}(${ops.readerOpt(t.value, ctx)}(${value}));`, + // ); + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_cell`)}(${path}, ${bits}, ${key});`, + // ); + // }); + // ctx.append(`}`); + // } + // } + // + // // Handle address key + // if (t.key === "Address") { + // if (t.value === "Int") { + // let vBits = 257; + // let vKind = "int"; + // if (t.valueAs?.startsWith("int")) { + // vBits = parseInt(t.valueAs.slice(3), 10); + // } else if (t.valueAs?.startsWith("uint")) { + // vBits = parseInt(t.valueAs.slice(4), 10); + // vKind = "uint"; + // } + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_${vKind}`)}(${path}, 267, ${vBits});`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_${vKind}`)}(${path}, 267, ${key}, ${vBits});`, + // ); + // }); + // ctx.append(`}`); + // } else if (t.value === "Bool") { + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_int`)}(${path}, 267, 1);`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_int`)}(${path}, 267, ${key}, 1);`, + // ); + // }); + // ctx.append(`}`); + // } else if (t.value === "Cell") { + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_cell`)}(${path}, 267);`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_cell`)}(${path}, 267, ${key});`, + // ); + // }); + // ctx.append(`}`); + // } else if (t.value === "Address") { + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_slice`)}(${path}, 267);`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_slice`)}(${path}, 267, ${key});`, + // ); + // }); + // ctx.append(`}`); + // } else { + // // value is struct + // ctx.append( + // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_cell`)}(${path}, 267);`, + // ); + // ctx.append(`while (${flag}) {`); + // ctx.inIndent(() => { + // ctx.append( + // `var ${resolveFuncTypeUnpack(t.value, funcIdOf(f.valueName), ctx)} = ${ops.typeNotNull(t.value, ctx)}(${ops.readerOpt(t.value, ctx)}(${value}));`, + // ); + // for (const s of f.statements) { + // writeStatement(s, self, returns, ctx); + // } + // ctx.append( + // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_cell`)}(${path}, 267, ${key});`, + // ); + // }); + // ctx.append(`}`); + // } + // } + // + // return; + // } + } + + throw Error(`Unknown statement kind: ${this.tactStmt.kind}`); + } +} diff --git a/src/codegen/type.ts b/src/codegen/type.ts new file mode 100644 index 000000000..74151719f --- /dev/null +++ b/src/codegen/type.ts @@ -0,0 +1,194 @@ +import { CompilerContext } from "../context"; +import { TypeDescription, TypeRef } from "../types/types"; +import { getType } from "../types/resolveDescriptors"; +import { FuncType, UNIT_TYPE } from "../func/syntax"; + +/** + * Unpacks string representation of a user-defined Tact type from its type description. + * The generated string represents an identifier avialable in the current scope. + */ +export function resolveFuncTypeUnpack( + ctx: CompilerContext, + descriptor: TypeRef | TypeDescription | string, + name: string, + optional: boolean = false, + usePartialFields: boolean = false, +): string { + // String + if (typeof descriptor === "string") { + return resolveFuncTypeUnpack( + ctx, + getType(ctx, descriptor), + name, + false, + usePartialFields, + ); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncTypeUnpack( + ctx, + getType(ctx, descriptor.name), + name, + descriptor.optional, + usePartialFields, + ); + } + if (descriptor.kind === "map") { + return name; + } + if (descriptor.kind === "ref_bounced") { + return resolveFuncTypeUnpack( + ctx, + getType(ctx, descriptor.name), + name, + false, + true, + ); + } + if (descriptor.kind === "void") { + throw Error(`Void type is not allowed in function arguments: ${name}`); + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + return name; + } else if (descriptor.kind === "struct") { + const fieldsToUse = usePartialFields + ? descriptor.fields.slice(0, descriptor.partialFieldCount) + : descriptor.fields; + if (optional || fieldsToUse.length === 0) { + return name; + } else { + return ( + "(" + + fieldsToUse + .map((v) => + resolveFuncTypeUnpack( + ctx, + v.type, + name + `'` + v.name, + false, + usePartialFields, + ), + ) + .join(", ") + + ")" + ); + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return name; + } else { + return ( + "(" + + descriptor.fields + .map((v) => + resolveFuncTypeUnpack( + ctx, + v.type, + name + `'` + v.name, + false, + usePartialFields, + ), + ) + .join(", ") + + ")" + ); + } + } + + // Unreachable + throw Error(`Unknown type: ${descriptor.kind}`); +} + +/** + * Generates Func type from the Tact type. + */ +export function resolveFuncType( + ctx: CompilerContext, + descriptor: TypeRef | TypeDescription | string, + optional: boolean = false, + usePartialFields: boolean = false, +): FuncType { + // String + if (typeof descriptor === "string") { + return resolveFuncType( + ctx, + getType(ctx, descriptor), + false, + usePartialFields, + ); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncType( + ctx, + getType(ctx, descriptor.name), + descriptor.optional, + usePartialFields, + ); + } + if (descriptor.kind === "map") { + return { kind: "cell" }; + } + if (descriptor.kind === "ref_bounced") { + return resolveFuncType(ctx, getType(ctx, descriptor.name), false, true); + } + if (descriptor.kind === "void") { + return UNIT_TYPE; + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + if (descriptor.name === "Int") { + return { kind: "int" }; + } else if (descriptor.name === "Bool") { + return { kind: "int" }; + } else if (descriptor.name === "Slice") { + return { kind: "slice" }; + } else if (descriptor.name === "Cell") { + return { kind: "cell" }; + } else if (descriptor.name === "Builder") { + return { kind: "builder" }; + } else if (descriptor.name === "Address") { + return { kind: "slice" }; + } else if (descriptor.name === "String") { + return { kind: "slice" }; + } else if (descriptor.name === "StringBuilder") { + return { kind: "tuple" }; + } else { + throw Error(`Unknown primitive type: ${descriptor.name}`); + } + } else if (descriptor.kind === "struct") { + const fieldsToUse = usePartialFields + ? descriptor.fields.slice(0, descriptor.partialFieldCount) + : descriptor.fields; + if (optional || fieldsToUse.length === 0) { + return { kind: "tuple" }; + } else { + return { + kind: "tensor", + value: fieldsToUse.map((v) => + resolveFuncType(ctx, v.type, false, usePartialFields), + ), + }; + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return { kind: "tuple" }; + } else { + return { + kind: "tensor", + value: descriptor.fields.map((v) => + resolveFuncType(ctx, v.type, false, usePartialFields), + ), + }; + } + } + + // Unreachable + throw Error(`Unknown type: ${descriptor.kind}`); +} diff --git a/src/codegen/util.ts b/src/codegen/util.ts new file mode 100644 index 000000000..053bfa011 --- /dev/null +++ b/src/codegen/util.ts @@ -0,0 +1,57 @@ +import { getType } from "../types/resolveDescriptors"; +import { CompilerContext } from "../context"; +import { TypeRef } from "../types/types"; +import { FuncAstExpr, FuncAstIdExpr } from "../func/syntax"; +import { AstId, idText } from "../grammar/ast"; + +export namespace ops { + export function extension(type: string, name: string): string { + return `$${type}$_fun_${name}`; + } + export function global(name: string): string { + return `$global_${name}`; + } + export function typeAsOptional(type: string) { + return `$${type}$_as_optional`; + } + export function typeTensorCast(type: string) { + return `$${type}$_tensor_cast`; + } + export function nonModifying(name: string) { + return `${name}$not_mut`; + } +} + +/** + * Wraps the expression in `_as_optional()` if needed. + */ +export function cast( + ctx: CompilerContext, + from: TypeRef, + to: TypeRef, + expr: FuncAstExpr, +): FuncAstExpr { + if (from.kind === "ref" && to.kind === "ref") { + if (from.name !== to.name) { + throw Error(`Impossible: ${from.name} != ${to.name}`); + } + if (!from.optional && to.optional) { + const type = getType(ctx, from.name); + if (type.kind === "struct") { + const fun = { + kind: "id_expr", + value: ops.typeAsOptional(type.name), + } as FuncAstIdExpr; + return { kind: "call_expr", fun, args: [expr] }; + } + } + } + return expr; +} + +export function funcIdOf(ident: AstId | string): string { + return typeof ident === "string" ? `$${ident}` : `$${idText(ident)}`; +} +export function funcInitIdOf(ident: AstId | string): string { + return typeof ident === "string" ? `$${ident}` : `$init`; +} diff --git a/src/func/formatter.ts b/src/func/formatter.ts new file mode 100644 index 000000000..eea5ecdbc --- /dev/null +++ b/src/func/formatter.ts @@ -0,0 +1,322 @@ +import { + FuncAstNode, + FuncType, + FuncAstIdExpr, + FuncAstPragma, + FuncAstComment, + FuncAstInclude, + FuncAstModule, + FuncAstFunction, + FuncAstVarDefStmt, + FuncAstReturnStmt, + FuncAstBlockStmt, + FuncAstRepeatStmt, + FuncAstConditionStmt, + FuncAstDoUntilStmt, + FuncAstWhileStmt, + FuncAstExprStmt, + FuncAstTryCatchStmt, + FuncAstConstant, + FuncAstGlobalVariable, + FuncAstCallExpr, + FuncAstAugmentedAssignExpr, + FuncAstTernaryExpr, + FuncAstBinaryExpr, + FuncAstUnaryExpr, + FuncAstNumberExpr, + FuncAstBoolExpr, + FuncAstStringExpr, + FuncAstNilExpr, + FuncAstApplyExpr, + FuncAstTupleExpr, + FuncAstTensorExpr, + FuncAstUnitExpr, + FuncAstHoleExpr, + FuncAstPrimitiveTypeExpr, +} from "./syntax"; + +/** + * Provides utilities to print the generated Func AST. + */ +export class FuncFormatter { + public static dump(node: FuncAstNode): string { + switch (node.kind) { + case "id_expr": + return this.formatIdExpr(node as FuncAstIdExpr); + case "include": + return this.formatInclude(node as FuncAstInclude); + case "pragma": + return this.formatPragma(node as FuncAstPragma); + case "comment": + return this.formatComment(node as FuncAstComment); + case "int": + case "cell": + case "slice": + case "builder": + case "cont": + case "tuple": + case "tensor": + case "type": + return this.formatType(node as FuncType); + case "module": + return this.formatModule(node as FuncAstModule); + case "function": + return this.formatFunction(node as FuncAstFunction); + case "var_def_stmt": + return this.formatVarDefStmt(node as FuncAstVarDefStmt); + case "return_stmt": + return this.formatReturnStmt(node as FuncAstReturnStmt); + case "block_stmt": + return this.formatBlockStmt(node as FuncAstBlockStmt); + case "repeat_stmt": + return this.formatRepeatStmt(node as FuncAstRepeatStmt); + case "condition_stmt": + return this.formatConditionStmt(node as FuncAstConditionStmt); + case "do_until_stmt": + return this.formatDoUntilStmt(node as FuncAstDoUntilStmt); + case "while_stmt": + return this.formatWhileStmt(node as FuncAstWhileStmt); + case "expr_stmt": + return this.formatExprStmt(node as FuncAstExprStmt); + case "try_catch_stmt": + return this.formatTryCatchStmt(node as FuncAstTryCatchStmt); + case "constant": + return this.formatConstant(node as FuncAstConstant); + case "global_variable": + return this.formatGlobalVariable(node as FuncAstGlobalVariable); + case "call_expr": + return this.formatCallExpr(node as FuncAstCallExpr); + case "augmented_assign_expr": + return this.formatAugmentedAssignExpr( + node as FuncAstAugmentedAssignExpr, + ); + case "ternary_expr": + return this.formatTernaryExpr(node as FuncAstTernaryExpr); + case "binary_expr": + return this.formatBinaryExpr(node as FuncAstBinaryExpr); + case "unary_expr": + return this.formatUnaryExpr(node as FuncAstUnaryExpr); + case "number_expr": + return this.formatNumberExpr(node as FuncAstNumberExpr); + case "bool_expr": + return this.formatBoolExpr(node as FuncAstBoolExpr); + case "string_expr": + return this.formatStringExpr(node as FuncAstStringExpr); + case "nil_expr": + return this.formatNilExpr(node as FuncAstNilExpr); + case "apply_expr": + return this.formatApplyExpr(node as FuncAstApplyExpr); + case "tuple_expr": + return this.formatTupleExpr(node as FuncAstTupleExpr); + case "tensor_expr": + return this.formatTensorExpr(node as FuncAstTensorExpr); + case "unit_expr": + return this.formatUnitExpr(node as FuncAstUnitExpr); + case "hole_expr": + return this.formatHoleExpr(node as FuncAstHoleExpr); + case "primitive_type_expr": + return this.formatPrimitiveTypeExpr( + node as FuncAstPrimitiveTypeExpr, + ); + default: + throw new Error(`Unsupported node kind: ${node}`); + } + } + + private static formatModule(node: FuncAstModule): string { + return node.entries.map((entry) => this.dump(entry)).join("\n"); + } + + private static formatFunction(node: FuncAstFunction): string { + const attrs = node.attrs.join(" "); + const params = node.params + .map((param) => `${param.ty} ${param.name}`) + .join(", "); + const returnType = node.returnTy; + const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + return `${attrs} ${params} -> ${returnType} {\n${body}\n}`; + } + + private static formatVarDefStmt(node: FuncAstVarDefStmt): string { + const type = node.ty ? `${this.dump(node.ty)} ` : ""; + const init = node.init ? ` = ${this.dump(node.init)}` : ""; + return `var ${node.name}: ${type}${init};`; + } + + private static formatReturnStmt(node: FuncAstReturnStmt): string { + const value = node.value ? ` ${this.dump(node.value)}` : ""; + return `return${value};`; + } + + private static formatBlockStmt(node: FuncAstBlockStmt): string { + const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + return `{\n${body}\n}`; + } + + private static formatRepeatStmt(node: FuncAstRepeatStmt): string { + const condition = this.dump(node.condition); + const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + return `repeat ${condition} {\n${body}\n}`; + } + + private static formatConditionStmt(node: FuncAstConditionStmt): string { + const condition = node.condition ? this.dump(node.condition) : ""; + const ifnot = node.ifnot ? "ifnot" : "if"; + const thenBlock = node.body + .map((stmt) => this.dump(stmt)) + .join("\n"); + const elseBlock = node.else ? this.formatConditionStmt(node.else) : ""; + return `${ifnot} ${condition} {\n${thenBlock}\n}${elseBlock ? ` else {\n${elseBlock}\n}` : ""}`; + } + + private static formatDoUntilStmt(node: FuncAstDoUntilStmt): string { + const condition = this.dump(node.condition); + const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + return `do {\n${body}\n} until ${condition};`; + } + + private static formatWhileStmt(node: FuncAstWhileStmt): string { + const condition = this.dump(node.condition); + const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + return `while ${condition} {\n${body}\n}`; + } + + private static formatExprStmt(node: FuncAstExprStmt): string { + return `${this.dump(node.expr)};`; + } + + private static formatTryCatchStmt(node: FuncAstTryCatchStmt): string { + const tryBlock = node.tryBlock + .map((stmt) => this.dump(stmt)) + .join("\n"); + const catchBlock = node.catchBlock + .map((stmt) => this.dump(stmt)) + .join("\n"); + const catchVar = node.catchVar ? ` (${node.catchVar})` : ""; + return `try {\n${tryBlock}\n} catch${catchVar} {\n${catchBlock}\n}`; + } + + private static formatConstant(node: FuncAstConstant): string { + const type = this.dump(node.ty); + const init = this.dump(node.init); + return `const ${type} = ${init};`; + } + + private static formatGlobalVariable(node: FuncAstGlobalVariable): string { + const type = this.dump(node.ty); + return `global ${type} ${node.name};`; + } + + private static formatCallExpr(node: FuncAstCallExpr): string { + const fun = this.dump(node.fun); + const args = node.args.map((arg) => this.dump(arg)).join(", "); + return `${fun}(${args})`; + } + + private static formatAugmentedAssignExpr( + node: FuncAstAugmentedAssignExpr, + ): string { + const lhs = this.dump(node.lhs); + const rhs = this.dump(node.rhs); + return `${lhs} ${node.op} ${rhs}`; + } + + private static formatTernaryExpr(node: FuncAstTernaryExpr): string { + const cond = this.dump(node.cond); + const body = this.dump(node.body); + const elseExpr = this.dump(node.else); + return `${cond} ? ${body} : ${elseExpr}`; + } + + private static formatBinaryExpr(node: FuncAstBinaryExpr): string { + const lhs = this.dump(node.lhs); + const rhs = this.dump(node.rhs); + return `${lhs} ${node.op} ${rhs}`; + } + + private static formatUnaryExpr(node: FuncAstUnaryExpr): string { + const value = this.dump(node.value); + return `${node.op}${value}`; + } + + private static formatNumberExpr(node: FuncAstNumberExpr): string { + return node.value.toString(); + } + + private static formatBoolExpr(node: FuncAstBoolExpr): string { + return node.value.toString(); + } + + private static formatStringExpr(node: FuncAstStringExpr): string { + return `"${node.value}"`; + } + + private static formatNilExpr(_: FuncAstNilExpr): string { + return "nil"; + } + + private static formatApplyExpr(node: FuncAstApplyExpr): string { + const lhs = this.dump(node.lhs); + const rhs = this.dump(node.rhs); + return `${lhs} ${rhs}`; + } + + private static formatTupleExpr(node: FuncAstTupleExpr): string { + const values = node.values.map((value) => this.dump(value)).join(", "); + return `[${values}]`; + } + + private static formatTensorExpr(node: FuncAstTensorExpr): string { + const values = node.values.map((value) => this.dump(value)).join(", "); + return `(${values})`; + } + + private static formatUnitExpr(_: FuncAstUnitExpr): string { + return "()"; + } + + private static formatHoleExpr(node: FuncAstHoleExpr): string { + const id = node.id ? node.id : "_"; + const init = this.dump(node.init); + return `${id} = ${init}`; + } + + private static formatPrimitiveTypeExpr( + node: FuncAstPrimitiveTypeExpr, + ): string { + return node.ty.kind; + } + + private static formatIdExpr(node: FuncAstIdExpr): string { + return node.value; + } + + private static formatInclude(node: FuncAstInclude): string { + return `#include ${node.kind}`; + } + + private static formatPragma(node: FuncAstPragma): string { + return `#pragma ${node.kind}`; + } + + private static formatComment(node: FuncAstComment): string { + return `;; ${node.value}`; + } + + private static formatType(node: FuncType): string { + switch (node.kind) { + case "int": + case "cell": + case "slice": + case "builder": + case "cont": + case "tuple": + case "type": + return node.kind; + case "tensor": + return `tensor(${node.value.map((t) => this.formatType(t)).join(", ")})`; + default: + throw new Error(`Unsupported type kind: ${node}`); + } + } +} diff --git a/src/func/syntax.ts b/src/func/syntax.ts new file mode 100644 index 000000000..3a30ce3ff --- /dev/null +++ b/src/func/syntax.ts @@ -0,0 +1,343 @@ +/** + * The supported version of the Func compiler: + * https://github.com/ton-blockchain/ton/blob/6897b5624566a2ab9126596d8bc4980dfbcaff2d/crypto/func/func.h#L48 + */ +export const FUNC_VERSION: string = "0.4.4"; + +/** + * Represents an ordered collection of values. + * NOTE: Unit type `()` is a special case of the tensor type. + */ +export type FuncTensorType = FuncType[]; +export const UNIT_TYPE: FuncType = { + kind: "tensor", + value: [] as FuncTensorType, +}; + +/** + * Type annotations available within the syntax tree. + */ +export type FuncType = + | { kind: "int" } + | { kind: "cell" } + | { kind: "slice" } + | { kind: "builder" } + | { kind: "cont" } + | { kind: "tuple" } + | { kind: "tensor"; value: FuncTensorType } + | { kind: "type" }; + +export type FuncAstUnaryOp = "-" | "~"; + +export type FuncAstBinaryOp = + | "+" + | "-" + | "*" + | "/" + | "%" + | "=" + | "<" + | ">" + | "&" + | "|" + | "^" + | "==" + | "!=" + | "<=" + | ">=" + | "<=>" + | "<<" + | ">>" + | "~>>" + | "^>>" + | "~/" + | "^/" + | "~%" + | "^%" + | "/%"; + +export type FuncAstAugmentedAssignOp = + | "+=" + | "-=" + | "*=" + | "/=" + | "~/=" + | "^/=" + | "%=" + | "~%=" + | "^%=" + | "<<=" + | ">>=" + | "~>>=" + | "^>>=" + | "&=" + | "|=" + | "^="; + +export type FuncAstTmpVarClass = "In" | "Named" | "Tmp" | "UniqueName"; + +interface FuncAstVarDescrFlags { + Last: boolean; + Unused: boolean; + Const: boolean; + Int: boolean; + Zero: boolean; + NonZero: boolean; + Pos: boolean; + Neg: boolean; + Bool: boolean; + Bit: boolean; + Finite: boolean; + Nan: boolean; + Even: boolean; + Odd: boolean; + Null: boolean; + NotNull: boolean; +} + +export type FuncAstConstant = { + kind: "constant"; + ty: FuncType; + init: FuncAstExpr; +}; + +export type FuncAstIdExpr = { + kind: "id_expr"; + value: string; +}; + +export type FuncAstCallExpr = { + kind: "call_expr"; + fun: FuncAstExpr; + args: FuncAstExpr[]; +}; + +// Augmented assignment: a += 42; +export type FuncAstAugmentedAssignExpr = { + kind: "augmented_assign_expr"; + lhs: FuncAstExpr; + op: FuncAstAugmentedAssignOp; + rhs: FuncAstExpr; +}; + +export type FuncAstTernaryExpr = { + kind: "ternary_expr"; + cond: FuncAstExpr; + body: FuncAstExpr; + else: FuncAstExpr; +}; + +export type FuncAstBinaryExpr = { + kind: "binary_expr"; + lhs: FuncAstExpr; + op: FuncAstBinaryOp; + rhs: FuncAstExpr; +}; + +export type FuncAstUnaryExpr = { + kind: "unary_expr"; + op: FuncAstUnaryOp; + value: FuncAstExpr; +}; + +export type FuncAstNumberExpr = { + kind: "number_expr"; + value: bigint; +}; + +export type FuncAstBoolExpr = { + kind: "bool_expr"; + value: boolean; +}; + +export type FuncAstStringExpr = { + kind: "string_expr"; + value: string; +}; + +export type FuncAstNilExpr = { + kind: "nil_expr"; +}; + +export type FuncAstApplyExpr = { + kind: "apply_expr"; + lhs: FuncAstExpr; + rhs: FuncAstExpr; +}; + +export type FuncAstTupleExpr = { + kind: "tuple_expr"; + values: FuncAstExpr[]; +}; + +export type FuncAstTensorExpr = { + kind: "tensor_expr"; + values: FuncAstExpr[]; +}; + +export type FuncAstUnitExpr = { + kind: "unit_expr"; +}; + +// Defines a variable applying the local type inference rules: +// var x = 2; +// _ = 2; +export type FuncAstHoleExpr = { + kind: "hole_expr"; + id: string | undefined; + init: FuncAstExpr; +}; + +// Primitive types are used in the syntax tree to express polymorphism. +export type FuncAstPrimitiveTypeExpr = { + kind: "primitive_type_expr"; + ty: FuncType; +}; + +// Local variable definition: +// int x = 2; // ty = int +// var x = 2; // ty is undefined +export type FuncAstVarDefStmt = { + kind: "var_def_stmt"; + name: string; + ty: FuncType | undefined; + init: FuncAstExpr | undefined; +}; + +export type FuncAstReturnStmt = { + kind: "return_stmt"; + value: FuncAstExpr | undefined; +}; + +export type FuncAstBlockStmt = { + kind: "block_stmt"; + body: FuncAstStmt[]; +}; + +export type FuncAstRepeatStmt = { + kind: "repeat_stmt"; + condition: FuncAstExpr; + body: FuncAstStmt[]; +}; + +export type FuncAstConditionStmt = { + kind: "condition_stmt"; + condition?: FuncAstExpr; + ifnot: boolean; // negation: ifnot or elseifnot attribute + body: FuncAstStmt[]; + else?: FuncAstConditionStmt; +}; + +export type FuncAstDoUntilStmt = { + kind: "do_until_stmt"; + body: FuncAstStmt[]; + condition: FuncAstExpr; +}; + +export type FuncAstWhileStmt = { + kind: "while_stmt"; + condition: FuncAstExpr; + body: FuncAstStmt[]; +}; + +export type FuncAstExprStmt = { + kind: "expr_stmt"; + expr: FuncAstExpr; +}; + +export type FuncAstTryCatchStmt = { + kind: "try_catch_stmt"; + tryBlock: FuncAstStmt[]; + catchBlock: FuncAstStmt[]; + catchVar: string | null; +}; + +export type FuncAstFunctionAttribute = "impure" | "inline"; + +export type FuncAstFormalFunctionParam = { + kind: "function_param"; + name: string; + ty: FuncType; +}; + +export type FuncAstFunction = { + kind: "function"; + attrs: FuncAstFunctionAttribute[]; + params: FuncAstFormalFunctionParam[]; + returnTy: FuncType; + body: FuncAstStmt[]; +}; + +export type FuncAstComment = { + kind: "comment"; + value: string; +}; + +export type FuncAstInclude = { + kind: "include"; +}; + +export type FuncAstPragma = { + kind: "pragma"; +}; + +export type FuncAstGlobalVariable = { + kind: "global_variable"; + name: string; + ty: FuncType; +}; + +export type FuncAstModuleEntry = + | FuncAstInclude + | FuncAstPragma + | FuncAstFunction + | FuncAstComment + | FuncAstConstant + | FuncAstGlobalVariable; + +export type FuncAstModule = { + kind: "module"; + entries: FuncAstModuleEntry[]; +}; + +export type FuncAstLiteralExpr = + | FuncAstNumberExpr + | FuncAstBoolExpr + | FuncAstStringExpr + | FuncAstNilExpr; +export type FuncAstSimpleExpr = + | FuncAstIdExpr + | FuncAstTupleExpr + | FuncAstTensorExpr + | FuncAstUnitExpr + | FuncAstHoleExpr + | FuncAstPrimitiveTypeExpr; +export type FuncAstCompositeExpr = + | FuncAstCallExpr + | FuncAstAugmentedAssignExpr + | FuncAstTernaryExpr + | FuncAstBinaryExpr + | FuncAstUnaryExpr + | FuncAstApplyExpr; +export type FuncAstExpr = + | FuncAstLiteralExpr + | FuncAstSimpleExpr + | FuncAstCompositeExpr; + +export type FuncAstStmt = + | FuncAstBlockStmt + | FuncAstVarDefStmt + | FuncAstReturnStmt + | FuncAstRepeatStmt + | FuncAstConditionStmt + | FuncAstDoUntilStmt + | FuncAstWhileStmt + | FuncAstExprStmt + | FuncAstTryCatchStmt; + +export type FuncAstNode = + | FuncAstStmt + | FuncAstExpr + | FuncAstModule + | FuncAstModuleEntry + | FuncType; diff --git a/src/pipeline/build.ts b/src/pipeline/build.ts index bcc35e6a6..1aaecea23 100644 --- a/src/pipeline/build.ts +++ b/src/pipeline/build.ts @@ -116,7 +116,7 @@ export async function build(args: { const res = await compile( ctx, contract, - config.name + "_" + contract, + `${config.name}_${contract}`, ); for (const files of res.output.files) { const ffc = project.resolve(config.output, files.name); diff --git a/src/pipeline/compile.ts b/src/pipeline/compile.ts index 84fde8302..e73bd693b 100644 --- a/src/pipeline/compile.ts +++ b/src/pipeline/compile.ts @@ -1,14 +1,45 @@ import { CompilerContext } from "../context"; import { createABI } from "../generator/createABI"; import { writeProgram } from "../generator/writeProgram"; +import { ContractGen } from "../codegen"; +import { FuncFormatter } from "../func/formatter"; +export type CompilationOutput = { + entrypoint: string; + files: { + name: string; + code: string; + }[]; + abi: string; +}; + +export type CompilationResults = { + output: CompilationOutput; + ctx: CompilerContext; +}; + +/** + * Compiles the given contract to Func. + */ export async function compile( ctx: CompilerContext, - name: string, - basename: string, -) { - const abi = createABI(ctx, name); - const output = await writeProgram(ctx, abi, basename); - const cOutput = output; - return { output: cOutput, ctx }; + contractName: string, + abiName: string, +): Promise { + const abi = createABI(ctx, contractName); + if (process.env.NEW_CODEGEN === "1") { + const funcAst = ContractGen.fromTact( + ctx, + contractName, + abiName, + ).generate(); + const output = FuncFormatter.dump(funcAst); + throw new Error(`output:\n${output}`); + // return { output, ctx }; + } else { + const output = await writeProgram(ctx, abi, abiName); + console.log(`${contractName} output:`); + output.files.forEach((o) => console.log(`---------------\nname=${o.name}; code:\n${o.code}\n`)); + return { output, ctx }; + } } From 60831d1cb3d90d5f4eadbe38c8c81350fdd643c0 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 01:29:29 +0000 Subject: [PATCH 002/162] feat(codegen): Support all `ops` --- src/codegen/util.ts | 70 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/src/codegen/util.ts b/src/codegen/util.ts index 053bfa011..5d7dad693 100644 --- a/src/codegen/util.ts +++ b/src/codegen/util.ts @@ -4,23 +4,59 @@ import { TypeRef } from "../types/types"; import { FuncAstExpr, FuncAstIdExpr } from "../func/syntax"; import { AstId, idText } from "../grammar/ast"; -export namespace ops { - export function extension(type: string, name: string): string { - return `$${type}$_fun_${name}`; - } - export function global(name: string): string { - return `$global_${name}`; - } - export function typeAsOptional(type: string) { - return `$${type}$_as_optional`; - } - export function typeTensorCast(type: string) { - return `$${type}$_tensor_cast`; - } - export function nonModifying(name: string) { - return `${name}$not_mut`; - } -} +export const ops = { + // Type operations + writer: (type: string) => `$${type}$_store`, + writerCell: (type: string) => `$${type}$_store_cell`, + writerCellOpt: (type: string) => `$${type}$_store_opt`, + reader: (type: string) => `$${type}$_load`, + readerNonModifying: (type: string) => `$${type}$_load_not_mut`, + readerBounced: (type: string) => `$${type}$_load_bounced`, + readerOpt: (type: string) => `$${type}$_load_opt`, + typeField: (type: string, name: string) => `$${type}$_get_${name}`, + typeTensorCast: (type: string) => `$${type}$_tensor_cast`, + typeNotNull: (type: string) => `$${type}$_not_null`, + typeAsOptional: (type: string) => `$${type}$_as_optional`, + typeToTuple: (type: string) => `$${type}$_to_tuple`, + typeToOptTuple: (type: string) => `$${type}$_to_opt_tuple`, + typeFromTuple: (type: string) => `$${type}$_from_tuple`, + typeFromOptTuple: (type: string) => `$${type}$_from_opt_tuple`, + typeToExternal: (type: string) => `$${type}$_to_external`, + typeToOptExternal: (type: string) => `$${type}$_to_opt_external`, + typeConstructor: (type: string, fields: string[]) => + `$${type}$_constructor_${fields.join("_")}`, + + // Contract operations + contractInit: (type: string) => `$${type}$_contract_init`, + contractInitChild: (type: string) => `$${type}$_init_child`, + contractLoad: (type: string) => `$${type}$_contract_load`, + contractStore: (type: string) => `$${type}$_contract_store`, + contractRouter: (type: string, kind: "internal" | "external") => + `$${type}$_contract_router_${kind}`, // Not rendered as dependency + + // Router operations + receiveEmpty: (type: string, kind: "internal" | "external") => + `%$${type}$_${kind}_empty`, + receiveType: (type: string, kind: "internal" | "external", msg: string) => + `$${type}$_${kind}_binary_${msg}`, + receiveAnyText: (type: string, kind: "internal" | "external") => + `$${type}$_${kind}_any_text`, + receiveText: (type: string, kind: "internal" | "external", hash: string) => + `$${type}$_${kind}_text_${hash}`, + receiveAny: (type: string, kind: "internal" | "external") => + `$${type}$_${kind}_any`, + receiveTypeBounce: (type: string, msg: string) => + `$${type}$_receive_binary_bounce_${msg}`, + receiveBounceAny: (type: string) => `$${type}$_receive_bounce`, + + // Functions + extension: (type: string, name: string) => `$${type}$_fun_${name}`, + global: (name: string) => `$global_${name}`, + nonModifying: (name: string) => `${name}$not_mut`, + + // Constants + str: (id: string) => `__gen_str_${id}`, +}; /** * Wraps the expression in `_as_optional()` if needed. From a2215691339d90717a6b152c0ebe1544892df881 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 01:29:40 +0000 Subject: [PATCH 003/162] feat(codegen): Support unary expressions + refactor --- src/codegen/expression.ts | 209 ++++++++++++++++---------------------- src/func/syntax.ts | 2 +- src/func/syntaxUtils.ts | 16 +++ 3 files changed, 106 insertions(+), 121 deletions(-) create mode 100644 src/func/syntaxUtils.ts diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index cf1bc4638..56d3a8920 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -13,12 +13,25 @@ import { hasStaticConstant, } from "../types/resolveDescriptors"; import { idText, AstExpression } from "../grammar/ast"; -import { FuncAstExpr, FuncAstIdExpr, FuncAstCallExpr } from "../func/syntax"; +import { FuncAstExpr, FuncAstUnaryOp } from "../func/syntax"; +import { makeId, makeCall } from "../func/syntaxUtils"; function isNull(f: AstExpression): boolean { return f.kind === "null"; } +function addUnary(op: FuncAstUnaryOp, expr: FuncAstExpr): FuncAstExpr { + return { + kind: "unary_expr", + op, + value: expr, + }; +} + +function negate(expr: FuncAstExpr): FuncAstExpr { + return addUnary("~", expr); +} + /** * Encapsulates generation of Func expressions from the Tact expression. */ @@ -120,7 +133,7 @@ export class ExpressionGen { t, funcIdOf(this.tactExpr.text), ); - return { kind: "id_expr", value }; + return makeId(value); } } @@ -143,18 +156,11 @@ export class ExpressionGen { return this.writeValue(c.value!); } - const value = funcIdOf(this.tactExpr.text); - return { kind: "id_expr", value }; + return makeId(funcIdOf(this.tactExpr.text)); } // NOTE: We always wrap in parentheses to avoid operator precedence issues if (this.tactExpr.kind === "op_binary") { - const negate: (expr: FuncAstExpr) => FuncAstExpr = (expr) => ({ - kind: "unary_expr", - op: "~", - value: expr, - }); - // Special case for non-integer types and nullable if (this.tactExpr.op === "==" || this.tactExpr.op === "!=") { // TODO: Simplify. @@ -167,35 +173,17 @@ export class ExpressionGen { isNull(this.tactExpr.left) && !isNull(this.tactExpr.right) ) { - const fun = { kind: "id_expr", value: "null?" }; - const args = [ - ExpressionGen.fromTact( - this.ctx, - this.tactExpr.right, - ).writeExpression(), - ]; - const call = { - kind: "call_expr", - fun, - args, - } as FuncAstCallExpr; + const call = makeCall("null?", [ + this.writeNestedExpression(this.tactExpr.right), + ]); return this.tactExpr.op === "==" ? call : negate(call); } else if ( !isNull(this.tactExpr.left) && isNull(this.tactExpr.right) ) { - const fun = { kind: "id_expr", value: "null?" }; - const args = [ - ExpressionGen.fromTact( - this.ctx, - this.tactExpr.left, - ).writeExpression(), - ]; - const call = { - kind: "call_expr", - fun, - args, - } as FuncAstCallExpr; + const call = makeCall("null?", [ + this.writeNestedExpression(this.tactExpr.left), + ]); return this.tactExpr.op === "==" ? call : negate(call); } } @@ -212,26 +200,10 @@ export class ExpressionGen { rt.name === "Address" ) { if (lt.optional && rt.optional) { - // wCtx.used(`__tact_slice_eq_bits_nullable`); - const fun = { - kind: "id_expr", - value: "__tact_slice_eq_bits_nullable", - }; - const args = [ - ExpressionGen.fromTact( - this.ctx, - this.tactExpr.left, - ).writeExpression(), - ExpressionGen.fromTact( - this.ctx, - this.tactExpr.right, - ).writeExpression(), - ]; - const call = { - kind: "call_expr", - fun, - args, - } as FuncAstCallExpr; + const call = makeCall("__tact_slice_eq_bits_nullable", [ + this.writeNestedExpression(this.tactExpr.left), + this.writeNestedExpression(this.tactExpr.right), + ]); return this.tactExpr.op == "!=" ? negate(call) : call; } // if (lt.optional && !rt.optional) { @@ -364,43 +336,49 @@ export class ExpressionGen { // // // // Unary operations: !, -, +, !! // // NOTE: We always wrap in parenthesis to avoid operator precedence issues - // // - // - // if (f.kind === "op_unary") { - // // NOTE: Logical not is written as a bitwise not - // switch (f.op) { - // case "!": { - // return "(~ " + writeExpression(f.operand, wCtx) + ")"; - // } - // - // case "~": { - // return "(~ " + writeExpression(f.operand, wCtx) + ")"; - // } - // - // case "-": { - // return "(- " + writeExpression(f.operand, wCtx) + ")"; - // } - // - // case "+": { - // return "(+ " + writeExpression(f.operand, wCtx) + ")"; - // } - // - // // NOTE: Assert function that ensures that the value is not null - // case "!!": { - // const t = getExpType(wCtx.ctx, f.operand); - // if (t.kind === "ref") { - // const tt = getType(wCtx.ctx, t.name); - // if (tt.kind === "struct") { - // return `${ops.typeNotNull(tt.name, wCtx)}(${writeExpression(f.operand, wCtx)})`; - // } - // } - // - // wCtx.used("__tact_not_null"); - // return `${wCtx.used("__tact_not_null")}(${writeExpression(f.operand, wCtx)})`; - // } - // } - // } - // + if (this.tactExpr.kind === "op_unary") { + // NOTE: Logical not is written as a bitwise not + switch (this.tactExpr.op) { + case "!": + case "~": { + const expr = this.writeNestedExpression( + this.tactExpr.operand, + ); + return negate(expr); + } + case "-": { + const expr = this.writeNestedExpression( + this.tactExpr.operand, + ); + return addUnary("-", expr); + } + case "+": { + const expr = this.writeNestedExpression( + this.tactExpr.operand, + ); + return addUnary("+", expr); + } + + // NOTE: Assert function that ensures that the value is not null + case "!!": { + const t = getExpType(this.ctx, this.tactExpr.operand); + if (t.kind === "ref") { + const tt = getType(this.ctx, t.name); + if (tt.kind === "struct") { + return makeCall(ops.typeNotNull(tt.name), [ + this.writeNestedExpression( + this.tactExpr.operand, + ), + ]); + } + } + return makeCall("__tact_not_null", [ + this.writeNestedExpression(this.tactExpr.operand), + ]); + } + } + } + // // // // Field Access // // NOTE: this branch resolves "a.b", where "a" is an expression and "b" is a field name @@ -490,14 +468,9 @@ export class ExpressionGen { // } else { // // wCtx.used(n); // } - const fun = { - kind: "id_expr", - value: ops.global(idText(this.tactExpr.function)), - } as FuncAstIdExpr; + const fun = makeId(ops.global(idText(this.tactExpr.function))); const args = this.tactExpr.args.map((argAst, i) => - ExpressionGen.fromTact(this.ctx, argAst).writeCastedExpression( - sf.params[i]!.type, - ), + this.writeNestedCastedExpression(argAst, sf.params[i]!.type), ); return { kind: "call_expr", fun, args }; } @@ -592,7 +565,8 @@ export class ExpressionGen { // Translate arguments let argExprs = this.tactExpr.args.map((a, i) => - ExpressionGen.fromTact(this.ctx, a).writeCastedExpression( + this.writeNestedCastedExpression( + a, methodFun.params[i]!.type, ), ); @@ -610,10 +584,7 @@ export class ExpressionGen { methodFun.params[0]!.type.kind === "ref" && !methodFun.params[0]!.type.optional ) { - const fun = { - kind: "id_expr", - value: ops.typeTensorCast(tt.name), - } as FuncAstIdExpr; + const fun = makeId(ops.typeTensorCast(tt.name)); argExprs = [ { kind: "call_expr", @@ -627,10 +598,7 @@ export class ExpressionGen { } // Generate function call - const selfExpr = ExpressionGen.fromTact( - this.ctx, - this.tactExpr.self, - ).writeExpression(); + const selfExpr = this.writeNestedExpression(this.tactExpr.self); if (methodFun.isMutating) { if ( this.tactExpr.self.kind === "id" || @@ -641,16 +609,10 @@ export class ExpressionGen { `Impossible self kind: ${selfExpr.kind}`, ); } - const fun = { - kind: "id_expr", - value: `${selfExpr}~${name}`, - } as FuncAstIdExpr; + const fun = makeId(`${selfExpr}~${name}`); return { kind: "call_expr", fun, args: argExprs }; } else { - const fun = { - kind: "id_expr", - value: ops.nonModifying(name), - } as FuncAstIdExpr; + const fun = makeId(ops.nonModifying(name)); return { kind: "call_expr", fun, @@ -658,13 +620,9 @@ export class ExpressionGen { }; } } else { - const fun = { - kind: "id_expr", - value: name, - } as FuncAstIdExpr; return { kind: "call_expr", - fun, + fun: makeId(name), args: [selfExpr, ...argExprs], }; } @@ -726,8 +684,19 @@ export class ExpressionGen { throw Error(`Unknown expression: ${this.tactExpr.kind}`); } + private writeNestedExpression(src: AstExpression): FuncAstExpr { + return ExpressionGen.fromTact(this.ctx, src).writeExpression(); + } + public writeCastedExpression(to: TypeRef): FuncAstExpr { const expr = getExpType(this.ctx, this.tactExpr); return cast(this.ctx, expr, to, this.writeExpression()); } + + private writeNestedCastedExpression( + src: AstExpression, + to: TypeRef, + ): FuncAstExpr { + return ExpressionGen.fromTact(this.ctx, src).writeCastedExpression(to); + } } diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 3a30ce3ff..c3e524adc 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -27,7 +27,7 @@ export type FuncType = | { kind: "tensor"; value: FuncTensorType } | { kind: "type" }; -export type FuncAstUnaryOp = "-" | "~"; +export type FuncAstUnaryOp = "-" | "~" | "+"; export type FuncAstBinaryOp = | "+" diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts new file mode 100644 index 000000000..3fbfe1880 --- /dev/null +++ b/src/func/syntaxUtils.ts @@ -0,0 +1,16 @@ +import { FuncAstExpr, FuncAstIdExpr, FuncAstCallExpr } from "./syntax"; + +export function makeId(value: string): FuncAstIdExpr { + return { kind: "id_expr", value }; +} + +export function makeCall( + fun: FuncAstIdExpr | string, + args: FuncAstExpr[], +): FuncAstCallExpr { + return { + kind: "call_expr", + fun: typeof fun === "string" ? makeId(fun) : fun, + args, + }; +} From d7acbb2ac9d9260f4f13804c1070f251caa7166d Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 01:41:06 +0000 Subject: [PATCH 004/162] feat(func): Support regular assigns --- src/func/formatter.ts | 13 +++++++++++++ src/func/syntax.ts | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index eea5ecdbc..76fa56bd5 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -2,6 +2,7 @@ import { FuncAstNode, FuncType, FuncAstIdExpr, +FuncAstAssignExpr, FuncAstPragma, FuncAstComment, FuncAstInclude, @@ -86,6 +87,10 @@ export class FuncFormatter { return this.formatGlobalVariable(node as FuncAstGlobalVariable); case "call_expr": return this.formatCallExpr(node as FuncAstCallExpr); + case "assign_expr": + return this.formatAssignExpr( + node as FuncAstAssignExpr, + ); case "augmented_assign_expr": return this.formatAugmentedAssignExpr( node as FuncAstAugmentedAssignExpr, @@ -213,6 +218,14 @@ export class FuncFormatter { return `${fun}(${args})`; } + private static formatAssignExpr( + node: FuncAstAssignExpr, + ): string { + const lhs = this.dump(node.lhs); + const rhs = this.dump(node.rhs); + return `${lhs} = ${rhs}`; + } + private static formatAugmentedAssignExpr( node: FuncAstAugmentedAssignExpr, ): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index c3e524adc..831c5a2b9 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -112,6 +112,12 @@ export type FuncAstCallExpr = { args: FuncAstExpr[]; }; +export type FuncAstAssignExpr = { + kind: "assign_expr"; + lhs: FuncAstExpr; + rhs: FuncAstExpr; +}; + // Augmented assignment: a += 42; export type FuncAstAugmentedAssignExpr = { kind: "augmented_assign_expr"; @@ -314,6 +320,7 @@ export type FuncAstSimpleExpr = | FuncAstPrimitiveTypeExpr; export type FuncAstCompositeExpr = | FuncAstCallExpr + | FuncAstAssignExpr | FuncAstAugmentedAssignExpr | FuncAstTernaryExpr | FuncAstBinaryExpr From 29cf7b51e941a1776b78858075142643fa92ffd8 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 01:45:57 +0000 Subject: [PATCH 005/162] feat(codegen): Support assign statements --- src/codegen/expression.ts | 13 +++++- src/codegen/statement.ts | 83 +++++++++++++++++++++++---------------- 2 files changed, 61 insertions(+), 35 deletions(-) diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 56d3a8920..5930cbd7c 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -12,8 +12,8 @@ import { getStaticFunction, hasStaticConstant, } from "../types/resolveDescriptors"; -import { idText, AstExpression } from "../grammar/ast"; -import { FuncAstExpr, FuncAstUnaryOp } from "../func/syntax"; +import { idText, AstExpression, AstId } from "../grammar/ast"; +import { FuncAstExpr, FuncAstUnaryOp, FuncAstIdExpr } from "../func/syntax"; import { makeId, makeCall } from "../func/syntaxUtils"; function isNull(f: AstExpression): boolean { @@ -32,6 +32,15 @@ function negate(expr: FuncAstExpr): FuncAstExpr { return addUnary("~", expr); } +/** + * Creates a Func identifier in the following format: a'b'c. + */ +export function writePathExpression(path: AstId[]): FuncAstIdExpr { + return makeId( + [funcIdOf(idText(path[0]!)), ...path.slice(1).map(idText)].join(`'`), + ); +} + /** * Encapsulates generation of Func expressions from the Tact expression. */ diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index d03aefda8..17860e3aa 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -1,4 +1,5 @@ import { CompilerContext } from "../context"; +import { throwInternalCompilerError } from "../errors"; import { funcIdOf } from "./util"; import { getType, resolveTypeRef } from "../types/resolveDescriptors"; import { getExpType } from "../types/resolveExpression"; @@ -7,8 +8,9 @@ import { AstCondition, AstStatement, isWildcard, + tryExtractPath, } from "../grammar/ast"; -import { ExpressionGen } from "./expression"; +import { ExpressionGen, writePathExpression } from "./expression"; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; import { FuncAstStmt, @@ -17,6 +19,7 @@ import { FuncAstTupleExpr, FuncAstUnitExpr, } from "../func/syntax"; +import { makeId } from "../func/syntaxUtils"; /** * Encapsulates generation of Func statements from the Tact statement. @@ -46,9 +49,7 @@ export class StatementGen { /** * Tranforms the Tact conditional statement to the Func one. */ - private writeCondition( - f: AstCondition, - ): FuncAstConditionStmt { + private writeCondition(f: AstCondition): FuncAstConditionStmt { const writeStmt = (stmt: AstStatement) => StatementGen.fromTact( this.ctx, @@ -167,35 +168,51 @@ export class StatementGen { return { kind: "var_def_stmt", name, ty, init }; } - // case "statement_assign": { - // // Prepare lvalue - // const lvaluePath = tryExtractPath(f.path); - // if (lvaluePath === null) { - // // typechecker is supposed to catch this - // throwInternalCompilerError( - // `Assignments are allowed only into path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, - // f.path.loc, - // ); - // } - // const path = writePathExpression(lvaluePath); - // - // // Contract/struct case - // const t = getExpType(ctx.ctx, f.path); - // if (t.kind === "ref") { - // const tt = getType(ctx.ctx, t.name); - // if (tt.kind === "contract" || tt.kind === "struct") { - // ctx.append( - // `${resolveFuncTypeUnpack(t, path, ctx)} = ${writeCastedExpression(f.expression, t, ctx)};`, - // ); - // return; - // } - // } - // - // ctx.append( - // `${path} = ${writeCastedExpression(f.expression, t, ctx)};`, - // ); - // return; - // } + case "statement_assign": { + // Prepare lvalue + const lvaluePath = tryExtractPath(this.tactStmt.path); + if (lvaluePath === null) { + // typechecker is supposed to catch this + throwInternalCompilerError( + `Assignments are allowed only into path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + this.tactStmt.path.loc, + ); + } + const path = writePathExpression(lvaluePath); + + // Contract/struct case + const t = getExpType(this.ctx, this.tactStmt.path); + if (t.kind === "ref") { + const tt = getType(this.ctx, t.name); + if (tt.kind === "contract" || tt.kind === "struct") { + const lhs = makeId( + resolveFuncTypeUnpack(this.ctx, t, path.value), + ); + const rhs = ExpressionGen.fromTact( + this.ctx, + this.tactStmt.expression, + ).writeCastedExpression(t); + const expr = { + kind: "assign_expr", + lhs, + rhs, + } as FuncAstExpr; + return { kind: "expr_stmt", expr }; + } + } + + const rhs = ExpressionGen.fromTact( + this.ctx, + this.tactStmt.expression, + ).writeCastedExpression(t); + const expr = { + kind: "assign_expr", + lhs: path, + rhs, + } as FuncAstExpr; + return { kind: "expr_stmt", expr }; + } + // case "statement_augmentedassign": { // const lvaluePath = tryExtractPath(f.path); // if (lvaluePath === null) { From 11a1487054612f21e4c9f8c10cfe117362361fdd Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 01:53:48 +0000 Subject: [PATCH 006/162] chore(codegen): Refactor statements --- src/codegen/statement.ts | 77 +++++++++++++++++++--------------------- src/func/syntaxUtils.ts | 11 +++++- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index 17860e3aa..0ff25374b 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -6,6 +6,7 @@ import { getExpType } from "../types/resolveExpression"; import { TypeRef } from "../types/types"; import { AstCondition, + AstExpression, AstStatement, isWildcard, tryExtractPath, @@ -19,7 +20,7 @@ import { FuncAstTupleExpr, FuncAstUnitExpr, } from "../func/syntax"; -import { makeId } from "../func/syntaxUtils"; +import { makeId, makeExprStmt } from "../func/syntaxUtils"; /** * Encapsulates generation of Func statements from the Tact statement. @@ -46,6 +47,17 @@ export class StatementGen { return new StatementGen(ctx, tactStmt, selfVarName, returns); } + /** + * Translates an expression in the current context. + */ + private makeExpr(expr: AstExpression): FuncAstExpr { + return ExpressionGen.fromTact(this.ctx, expr).writeExpression(); + } + + private makeCastedExpr(expr: AstExpression, to: TypeRef): FuncAstExpr { + return ExpressionGen.fromTact(this.ctx, expr).writeCastedExpression(to); + } + /** * Tranforms the Tact conditional statement to the Func one. */ @@ -57,10 +69,7 @@ export class StatementGen { this.selfName, this.returns, ).writeStatement(); - const condition = ExpressionGen.fromTact( - this.ctx, - f.condition, - ).writeExpression(); + const condition = this.makeExpr(f.condition); const thenBlock = f.trueStatements.map(writeStmt); const elseStmt: FuncAstConditionStmt | undefined = f.falseStatements !== null && f.falseStatements.length > 0 @@ -98,10 +107,10 @@ export class StatementGen { } as FuncAstTupleExpr) : expr; if (this.tactStmt.expression) { - const castedReturns = ExpressionGen.fromTact( - this.ctx, + const castedReturns = this.makeCastedExpr( this.tactStmt.expression, - ).writeCastedExpression(this.returns!); + this.returns!, + ); return { kind, value: getValue(castedReturns) }; } else { const unit = { kind: "unit_expr" } as FuncAstUnitExpr; @@ -111,11 +120,9 @@ export class StatementGen { case "statement_let": { // Underscore name case if (isWildcard(this.tactStmt.name)) { - const expr = ExpressionGen.fromTact( - this.ctx, - this.tactStmt.expression, - ).writeExpression(); - return { kind: "expr_stmt", expr }; + return makeExprStmt( + this.makeExpr(this.tactStmt.expression), + ); } // Contract/struct case @@ -129,10 +136,10 @@ export class StatementGen { if (tt.kind === "contract" || tt.kind === "struct") { if (t.optional) { const name = funcIdOf(this.tactStmt.name); - const init = ExpressionGen.fromTact( - this.ctx, + const init = this.makeCastedExpr( this.tactStmt.expression, - ).writeCastedExpression(t); + t, + ); return { kind: "var_def_stmt", name, @@ -145,10 +152,10 @@ export class StatementGen { t, funcIdOf(this.tactStmt.name), ); - const init = ExpressionGen.fromTact( - this.ctx, + const init = this.makeCastedExpr( this.tactStmt.expression, - ).writeCastedExpression(t); + t, + ); return { kind: "var_def_stmt", name, @@ -161,10 +168,7 @@ export class StatementGen { const ty = resolveFuncType(this.ctx, t); const name = funcIdOf(this.tactStmt.name); - const init = ExpressionGen.fromTact( - this.ctx, - this.tactStmt.expression, - ).writeCastedExpression(t); + const init = this.makeCastedExpr(this.tactStmt.expression, t); return { kind: "var_def_stmt", name, ty, init }; } @@ -188,29 +192,24 @@ export class StatementGen { const lhs = makeId( resolveFuncTypeUnpack(this.ctx, t, path.value), ); - const rhs = ExpressionGen.fromTact( - this.ctx, + const rhs = this.makeCastedExpr( this.tactStmt.expression, - ).writeCastedExpression(t); - const expr = { + t, + ); + return makeExprStmt({ kind: "assign_expr", lhs, rhs, - } as FuncAstExpr; - return { kind: "expr_stmt", expr }; + }); } } - const rhs = ExpressionGen.fromTact( - this.ctx, - this.tactStmt.expression, - ).writeCastedExpression(t); - const expr = { + const rhs = this.makeCastedExpr(this.tactStmt.expression, t); + return makeExprStmt({ kind: "assign_expr", lhs: path, rhs, - } as FuncAstExpr; - return { kind: "expr_stmt", expr }; + }); } // case "statement_augmentedassign": { @@ -233,11 +232,7 @@ export class StatementGen { return this.writeCondition(this.tactStmt); } case "statement_expression": { - const expr = ExpressionGen.fromTact( - this.ctx, - this.tactStmt.expression, - ).writeExpression(); - return { kind: "expr_stmt", expr }; + return makeExprStmt(this.makeExpr(this.tactStmt.expression)); } // case "statement_while": { // ctx.append(`while (${writeExpression(f.condition, ctx)}) {`); diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index 3fbfe1880..27e99a0da 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -1,4 +1,9 @@ -import { FuncAstExpr, FuncAstIdExpr, FuncAstCallExpr } from "./syntax"; +import { + FuncAstExpr, + FuncAstIdExpr, + FuncAstCallExpr, + FuncAstStmt, +} from "./syntax"; export function makeId(value: string): FuncAstIdExpr { return { kind: "id_expr", value }; @@ -14,3 +19,7 @@ export function makeCall( args, }; } + +export function makeExprStmt(expr: FuncAstExpr): FuncAstStmt { + return { kind: "expr_stmt", expr }; +} From c989cb8d23962297d5abb109eee280aea829f1b0 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 02:01:01 +0000 Subject: [PATCH 007/162] feat(codegen): Support field access --- src/codegen/expression.ts | 182 +++++++++++++++++++------------------- 1 file changed, 92 insertions(+), 90 deletions(-) diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 5930cbd7c..c4861cf27 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -1,18 +1,28 @@ import { CompilerContext } from "../context"; -import { TactConstEvalError, throwCompilationError } from "../errors"; +import { + TactConstEvalError, + throwCompilationError, + idTextErr, +} from "../errors"; import { evalConstantExpression } from "../constEval"; import { resolveFuncTypeUnpack } from "./type"; import { MapFunctions, StructFunctions, GlobalFunctions } from "./abi"; import { getExpType } from "../types/resolveExpression"; import { cast, funcIdOf, ops } from "./util"; -import { printTypeRef, TypeRef, Value } from "../types/types"; +import { printTypeRef, TypeRef, Value, FieldDescription } from "../types/types"; import { getStaticConstant, getType, getStaticFunction, hasStaticConstant, } from "../types/resolveDescriptors"; -import { idText, AstExpression, AstId } from "../grammar/ast"; +import { + idText, + AstExpression, + AstId, + eqNames, + tryExtractPath, +} from "../grammar/ast"; import { FuncAstExpr, FuncAstUnaryOp, FuncAstIdExpr } from "../func/syntax"; import { makeId, makeCall } from "../func/syntaxUtils"; @@ -183,7 +193,7 @@ export class ExpressionGen { !isNull(this.tactExpr.right) ) { const call = makeCall("null?", [ - this.writeNestedExpression(this.tactExpr.right), + this.makeExpr(this.tactExpr.right), ]); return this.tactExpr.op === "==" ? call : negate(call); } else if ( @@ -191,7 +201,7 @@ export class ExpressionGen { isNull(this.tactExpr.right) ) { const call = makeCall("null?", [ - this.writeNestedExpression(this.tactExpr.left), + this.makeExpr(this.tactExpr.left), ]); return this.tactExpr.op === "==" ? call : negate(call); } @@ -210,8 +220,8 @@ export class ExpressionGen { ) { if (lt.optional && rt.optional) { const call = makeCall("__tact_slice_eq_bits_nullable", [ - this.writeNestedExpression(this.tactExpr.left), - this.writeNestedExpression(this.tactExpr.right), + this.makeExpr(this.tactExpr.left), + this.makeExpr(this.tactExpr.right), ]); return this.tactExpr.op == "!=" ? negate(call) : call; } @@ -350,21 +360,15 @@ export class ExpressionGen { switch (this.tactExpr.op) { case "!": case "~": { - const expr = this.writeNestedExpression( - this.tactExpr.operand, - ); + const expr = this.makeExpr(this.tactExpr.operand); return negate(expr); } case "-": { - const expr = this.writeNestedExpression( - this.tactExpr.operand, - ); + const expr = this.makeExpr(this.tactExpr.operand); return addUnary("-", expr); } case "+": { - const expr = this.writeNestedExpression( - this.tactExpr.operand, - ); + const expr = this.makeExpr(this.tactExpr.operand); return addUnary("+", expr); } @@ -375,80 +379,84 @@ export class ExpressionGen { const tt = getType(this.ctx, t.name); if (tt.kind === "struct") { return makeCall(ops.typeNotNull(tt.name), [ - this.writeNestedExpression( - this.tactExpr.operand, - ), + this.makeExpr(this.tactExpr.operand), ]); } } return makeCall("__tact_not_null", [ - this.writeNestedExpression(this.tactExpr.operand), + this.makeExpr(this.tactExpr.operand), ]); } } } - // // - // // Field Access - // // NOTE: this branch resolves "a.b", where "a" is an expression and "b" is a field name - // // - // - // if (f.kind === "field_access") { - // // Resolve the type of the expression - // const src = getExpType(wCtx.ctx, f.aggregate); - // if ( - // (src.kind !== "ref" || src.optional) && - // src.kind !== "ref_bounced" - // ) { - // throwCompilationError( - // `Cannot access field of non-struct type: "${printTypeRef(src)}"`, - // f.loc, - // ); - // } - // const srcT = getType(wCtx.ctx, src.name); // - // // Resolve field - // let fields: FieldDescription[]; - // - // fields = srcT.fields; - // if (src.kind === "ref_bounced") { - // fields = fields.slice(0, srcT.partialFieldCount); - // } - // - // const field = fields.find((v) => eqNames(v.name, f.field)); - // const cst = srcT.constants.find((v) => eqNames(v.name, f.field)); - // if (!field && !cst) { - // throwCompilationError( - // `Cannot find field ${idTextErr(f.field)} in struct ${idTextErr(srcT.name)}`, - // f.field.loc, - // ); - // } - // - // if (field) { - // // Trying to resolve field as a path - // const path = tryExtractPath(f); - // if (path) { - // // Prepare path - // const idd = writePathExpression(path); - // - // // Special case for structs - // if (field.type.kind === "ref") { - // const ft = getType(wCtx.ctx, field.type.name); - // if (ft.kind === "struct" || ft.kind === "contract") { - // return resolveFuncTypeUnpack(field.type, idd, wCtx); - // } - // } - // - // return idd; - // } - // - // // Getter instead of direct field access - // return `${ops.typeField(srcT.name, field.name, wCtx)}(${writeExpression(f.aggregate, wCtx)})`; - // } else { - // return writeValue(cst!.value!, wCtx); - // } - // } + // Field Access + // NOTE: this branch resolves "a.b", where "a" is an expression and "b" is a field name // + if (this.tactExpr.kind === "field_access") { + // Resolve the type of the expression + const src = getExpType(this.ctx, this.tactExpr.aggregate); + if ( + (src.kind !== "ref" || src.optional) && + src.kind !== "ref_bounced" + ) { + throwCompilationError( + `Cannot access field of non-struct type: "${printTypeRef(src)}"`, + this.tactExpr.loc, + ); + } + const srcT = getType(this.ctx, src.name); + + // Resolve field + let fields: FieldDescription[]; + + fields = srcT.fields; + if (src.kind === "ref_bounced") { + fields = fields.slice(0, srcT.partialFieldCount); + } + + const fieldExpr = this.tactExpr.field; + const field = fields.find((v) => eqNames(v.name, fieldExpr)); + const cst = srcT.constants.find((v) => eqNames(v.name, fieldExpr)); + if (!field && !cst) { + throwCompilationError( + `Cannot find field ${idTextErr(this.tactExpr.field)} in struct ${idTextErr(srcT.name)}`, + this.tactExpr.field.loc, + ); + } + + if (field) { + // Trying to resolve field as a path + const path = tryExtractPath(this.tactExpr); + if (path) { + // Prepare path + const idd = writePathExpression(path); + + // Special case for structs + if (field.type.kind === "ref") { + const ft = getType(this.ctx, field.type.name); + if (ft.kind === "struct" || ft.kind === "contract") { + return makeId( + resolveFuncTypeUnpack( + this.ctx, + field.type, + idd.value, + ), + ); + } + } + return idd; + } + + // Getter instead of direct field access + return makeCall(ops.typeField(srcT.name, field.name), [ + this.makeExpr(this.tactExpr.aggregate), + ]); + } else { + return this.writeValue(cst!.value!); + } + } // // Static Function Call @@ -479,7 +487,7 @@ export class ExpressionGen { // } const fun = makeId(ops.global(idText(this.tactExpr.function))); const args = this.tactExpr.args.map((argAst, i) => - this.writeNestedCastedExpression(argAst, sf.params[i]!.type), + this.makeCastedExpr(argAst, sf.params[i]!.type), ); return { kind: "call_expr", fun, args }; } @@ -574,10 +582,7 @@ export class ExpressionGen { // Translate arguments let argExprs = this.tactExpr.args.map((a, i) => - this.writeNestedCastedExpression( - a, - methodFun.params[i]!.type, - ), + this.makeCastedExpr(a, methodFun.params[i]!.type), ); // Hack to replace a single struct argument to a tensor wrapper since otherwise @@ -607,7 +612,7 @@ export class ExpressionGen { } // Generate function call - const selfExpr = this.writeNestedExpression(this.tactExpr.self); + const selfExpr = this.makeExpr(this.tactExpr.self); if (methodFun.isMutating) { if ( this.tactExpr.self.kind === "id" || @@ -693,7 +698,7 @@ export class ExpressionGen { throw Error(`Unknown expression: ${this.tactExpr.kind}`); } - private writeNestedExpression(src: AstExpression): FuncAstExpr { + private makeExpr(src: AstExpression): FuncAstExpr { return ExpressionGen.fromTact(this.ctx, src).writeExpression(); } @@ -702,10 +707,7 @@ export class ExpressionGen { return cast(this.ctx, expr, to, this.writeExpression()); } - private writeNestedCastedExpression( - src: AstExpression, - to: TypeRef, - ): FuncAstExpr { + private makeCastedExpr(src: AstExpression, to: TypeRef): FuncAstExpr { return ExpressionGen.fromTact(this.ctx, src).writeCastedExpression(to); } } From 477eb2c7a6587858c8b835eedca124b5bf5d76d5 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 02:26:23 +0000 Subject: [PATCH 008/162] fix(syntax): Remove assignments from available binary operations --- src/func/syntax.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 831c5a2b9..588717e6b 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -35,7 +35,6 @@ export type FuncAstBinaryOp = | "*" | "/" | "%" - | "=" | "<" | ">" | "&" From 2fd26e76eaa79ac7cae05b4ab420460b3ec2c6db Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 02:34:34 +0000 Subject: [PATCH 009/162] chore(syntax): Refactor --- src/func/formatter.ts | 18 ++++++------------ src/func/syntax.ts | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 76fa56bd5..4941ad6ab 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -2,7 +2,7 @@ import { FuncAstNode, FuncType, FuncAstIdExpr, -FuncAstAssignExpr, + FuncAstAssignExpr, FuncAstPragma, FuncAstComment, FuncAstInclude, @@ -88,9 +88,7 @@ export class FuncFormatter { case "call_expr": return this.formatCallExpr(node as FuncAstCallExpr); case "assign_expr": - return this.formatAssignExpr( - node as FuncAstAssignExpr, - ); + return this.formatAssignExpr(node as FuncAstAssignExpr); case "augmented_assign_expr": return this.formatAugmentedAssignExpr( node as FuncAstAugmentedAssignExpr, @@ -167,9 +165,7 @@ export class FuncFormatter { private static formatConditionStmt(node: FuncAstConditionStmt): string { const condition = node.condition ? this.dump(node.condition) : ""; const ifnot = node.ifnot ? "ifnot" : "if"; - const thenBlock = node.body - .map((stmt) => this.dump(stmt)) - .join("\n"); + const thenBlock = node.body.map((stmt) => this.dump(stmt)).join("\n"); const elseBlock = node.else ? this.formatConditionStmt(node.else) : ""; return `${ifnot} ${condition} {\n${thenBlock}\n}${elseBlock ? ` else {\n${elseBlock}\n}` : ""}`; } @@ -218,9 +214,7 @@ export class FuncFormatter { return `${fun}(${args})`; } - private static formatAssignExpr( - node: FuncAstAssignExpr, - ): string { + private static formatAssignExpr(node: FuncAstAssignExpr): string { const lhs = this.dump(node.lhs); const rhs = this.dump(node.rhs); return `${lhs} = ${rhs}`; @@ -236,8 +230,8 @@ export class FuncFormatter { private static formatTernaryExpr(node: FuncAstTernaryExpr): string { const cond = this.dump(node.cond); - const body = this.dump(node.body); - const elseExpr = this.dump(node.else); + const body = this.dump(node.trueExpr); + const elseExpr = this.dump(node.falseExpr); return `${cond} ? ${body} : ${elseExpr}`; } diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 588717e6b..d8f635552 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -128,8 +128,8 @@ export type FuncAstAugmentedAssignExpr = { export type FuncAstTernaryExpr = { kind: "ternary_expr"; cond: FuncAstExpr; - body: FuncAstExpr; - else: FuncAstExpr; + trueExpr: FuncAstExpr; + falseExpr: FuncAstExpr; }; export type FuncAstBinaryExpr = { From b327bb961bdda9f7e73bee74d703d0acfc84d43e Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 02:34:44 +0000 Subject: [PATCH 010/162] feat(codegen): Support all the binary expressions --- src/codegen/expression.ts | 327 ++++++++++++++++++++++---------------- src/func/syntaxUtils.ts | 13 ++ 2 files changed, 205 insertions(+), 135 deletions(-) diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index c4861cf27..62e237357 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -23,8 +23,13 @@ import { eqNames, tryExtractPath, } from "../grammar/ast"; -import { FuncAstExpr, FuncAstUnaryOp, FuncAstIdExpr } from "../func/syntax"; -import { makeId, makeCall } from "../func/syntaxUtils"; +import { + FuncAstExpr, + FuncAstUnaryOp, + FuncAstIdExpr, + FuncAstTernaryExpr, +} from "../func/syntax"; +import { makeId, makeCall, makeBinop } from "../func/syntaxUtils"; function isNull(f: AstExpression): boolean { return f.kind === "null"; @@ -182,7 +187,6 @@ export class ExpressionGen { if (this.tactExpr.kind === "op_binary") { // Special case for non-integer types and nullable if (this.tactExpr.op === "==" || this.tactExpr.op === "!=") { - // TODO: Simplify. if (isNull(this.tactExpr.left) && isNull(this.tactExpr.right)) { return { kind: "bool_expr", @@ -218,143 +222,196 @@ export class ExpressionGen { lt.name === "Address" && rt.name === "Address" ) { + const maybeNegate = (call: any): any => { + if (this.tactExpr.kind !== "op_binary") { + throw new Error("Impossible"); + } + return this.tactExpr.op == "!=" ? negate(call) : call; + }; if (lt.optional && rt.optional) { - const call = makeCall("__tact_slice_eq_bits_nullable", [ + return maybeNegate( + makeCall("__tact_slice_eq_bits_nullable", [ + this.makeExpr(this.tactExpr.left), + this.makeExpr(this.tactExpr.right), + ]), + ); + } + if (lt.optional && !rt.optional) { + return maybeNegate( + makeCall("__tact_slice_eq_bits_nullable_one", [ + this.makeExpr(this.tactExpr.left), + this.makeExpr(this.tactExpr.right), + ]), + ); + } + if (!lt.optional && rt.optional) { + return maybeNegate( + makeCall("__tact_slice_eq_bits_nullable_one", [ + this.makeExpr(this.tactExpr.right), + this.makeExpr(this.tactExpr.left), + ]), + ); + } + return maybeNegate( + makeCall("__tact_slice_eq_bits", [ + this.makeExpr(this.tactExpr.right), + this.makeExpr(this.tactExpr.left), + ]), + ); + } + + // Case for cells equality + if ( + lt.kind === "ref" && + rt.kind === "ref" && + lt.name === "Cell" && + rt.name === "Cell" + ) { + const op = this.tactExpr.op === "==" ? "eq" : "neq"; + if (lt.optional && rt.optional) { + return makeCall(`__tact_cell_${op}_nullable`, [ + this.makeExpr(this.tactExpr.left), + this.makeExpr(this.tactExpr.right), + ]); + } + if (lt.optional && !rt.optional) { + return makeCall(`__tact_cell_${op}_nullable_one`, [ + this.makeExpr(this.tactExpr.left), + this.makeExpr(this.tactExpr.right), + ]); + } + if (!lt.optional && rt.optional) { + return makeCall(`__tact_cell_${op}_nullable_one`, [ + this.makeExpr(this.tactExpr.right), + this.makeExpr(this.tactExpr.left), + ]); + } + return makeCall(`__tact_cell_${op}`, [ + this.makeExpr(this.tactExpr.right), + this.makeExpr(this.tactExpr.left), + ]); + } + + // Case for slices and strings equality + if ( + lt.kind === "ref" && + rt.kind === "ref" && + lt.name === rt.name && + (lt.name === "Slice" || lt.name === "String") + ) { + const op = this.tactExpr.op === "==" ? "eq" : "neq"; + if (lt.optional && rt.optional) { + return makeCall(`__tact_slice_${op}_nullable`, [ + this.makeExpr(this.tactExpr.left), + this.makeExpr(this.tactExpr.right), + ]); + } + if (lt.optional && !rt.optional) { + return makeCall(`__tact_slice_${op}_nullable_one`, [ + this.makeExpr(this.tactExpr.left), + this.makeExpr(this.tactExpr.right), + ]); + } + if (!lt.optional && rt.optional) { + return makeCall(`__tact_slice_${op}_nullable_one`, [ + this.makeExpr(this.tactExpr.right), + this.makeExpr(this.tactExpr.left), + ]); + } + return makeCall(`__tact_slice_${op}`, [ + this.makeExpr(this.tactExpr.right), + this.makeExpr(this.tactExpr.left), + ]); + } + + // Case for maps equality + if (lt.kind === "map" && rt.kind === "map") { + const op = this.tactExpr.op === "==" ? "eq" : "neq"; + return makeCall(`__tact_cell_${op}_nullable`, [ + this.makeExpr(this.tactExpr.left), + this.makeExpr(this.tactExpr.right), + ]); + } + + // Check for int or boolean types + if ( + lt.kind !== "ref" || + rt.kind !== "ref" || + (lt.name !== "Int" && lt.name !== "Bool") || + (rt.name !== "Int" && rt.name !== "Bool") + ) { + const file = this.tactExpr.loc.file; + const loc_info = this.tactExpr.loc.interval.getLineAndColumn(); + throw Error( + `(Internal Compiler Error) Invalid types for binary operation: ${file}:${loc_info.lineNum}:${loc_info.colNum}`, + ); // Should be unreachable + } + + // Case for ints equality + if (this.tactExpr.op === "==" || this.tactExpr.op === "!=") { + const op = this.tactExpr.op === "==" ? "eq" : "neq"; + if (lt.optional && rt.optional) { + return makeCall(`__tact_int_${op}_nullable`, [ + this.makeExpr(this.tactExpr.left), + this.makeExpr(this.tactExpr.right), + ]); + } + if (lt.optional && !rt.optional) { + return makeCall(`__tact_int_${op}_nullable_one`, [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]); - return this.tactExpr.op == "!=" ? negate(call) : call; } - // if (lt.optional && !rt.optional) { - // // wCtx.used(`__tact_slice_eq_bits_nullable_one`); - // return `( ${prefix}__tact_slice_eq_bits_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)}) )`; - // } - // if (!lt.optional && rt.optional) { - // // wCtx.used(`__tact_slice_eq_bits_nullable_one`); - // return `( ${prefix}__tact_slice_eq_bits_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)}) )`; - // } - // // wCtx.used(`__tact_slice_eq_bits`); - // return `( ${prefix}__tact_slice_eq_bits(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)}) )`; - // } - // - // // Case for cells equality - // if ( - // lt.kind === "ref" && - // rt.kind === "ref" && - // lt.name === "Cell" && - // rt.name === "Cell" - // ) { - // const op = f.op === "==" ? "eq" : "neq"; - // if (lt.optional && rt.optional) { - // wCtx.used(`__tact_cell_${op}_nullable`); - // return `__tact_cell_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; - // } - // if (lt.optional && !rt.optional) { - // wCtx.used(`__tact_cell_${op}_nullable_one`); - // return `__tact_cell_${op}_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; - // } - // if (!lt.optional && rt.optional) { - // wCtx.used(`__tact_cell_${op}_nullable_one`); - // return `__tact_cell_${op}_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; - // } - // wCtx.used(`__tact_cell_${op}`); - // return `__tact_cell_${op}(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; - // } - // - // // Case for slices and strings equality - // if ( - // lt.kind === "ref" && - // rt.kind === "ref" && - // lt.name === rt.name && - // (lt.name === "Slice" || lt.name === "String") - // ) { - // const op = f.op === "==" ? "eq" : "neq"; - // if (lt.optional && rt.optional) { - // wCtx.used(`__tact_slice_${op}_nullable`); - // return `__tact_slice_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; - // } - // if (lt.optional && !rt.optional) { - // wCtx.used(`__tact_slice_${op}_nullable_one`); - // return `__tact_slice_${op}_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; - // } - // if (!lt.optional && rt.optional) { - // wCtx.used(`__tact_slice_${op}_nullable_one`); - // return `__tact_slice_${op}_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; - // } - // wCtx.used(`__tact_slice_${op}`); - // return `__tact_slice_${op}(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; - // } - // - // // Case for maps equality - // if (lt.kind === "map" && rt.kind === "map") { - // const op = f.op === "==" ? "eq" : "neq"; - // wCtx.used(`__tact_cell_${op}_nullable`); - // return `__tact_cell_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; - // } - // - // // Check for int or boolean types - // if ( - // lt.kind !== "ref" || - // rt.kind !== "ref" || - // (lt.name !== "Int" && lt.name !== "Bool") || - // (rt.name !== "Int" && rt.name !== "Bool") - // ) { - // const file = f.loc.file; - // const loc_info = f.loc.interval.getLineAndColumn(); - // throw Error( - // `(Internal Compiler Error) Invalid types for binary operation: ${file}:${loc_info.lineNum}:${loc_info.colNum}`, - // ); // Should be unreachable - // } - // - // // Case for ints equality - // if (f.op === "==" || f.op === "!=") { - // const op = f.op === "==" ? "eq" : "neq"; - // if (lt.optional && rt.optional) { - // wCtx.used(`__tact_int_${op}_nullable`); - // return `__tact_int_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; - // } - // if (lt.optional && !rt.optional) { - // wCtx.used(`__tact_int_${op}_nullable_one`); - // return `__tact_int_${op}_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; - // } - // if (!lt.optional && rt.optional) { - // wCtx.used(`__tact_int_${op}_nullable_one`); - // return `__tact_int_${op}_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; - // } - // if (f.op === "==") { - // return `(${writeExpression(f.left, wCtx)} == ${writeExpression(f.right, wCtx)})`; - // } else { - // return `(${writeExpression(f.left, wCtx)} != ${writeExpression(f.right, wCtx)})`; - // } - // } - // - // // Case for "&&" operator - // if (f.op === "&&") { - // return `( (${writeExpression(f.left, wCtx)}) ? (${writeExpression(f.right, wCtx)}) : (false) )`; - // } - // - // // Case for "||" operator - // if (f.op === "||") { - // return `( (${writeExpression(f.left, wCtx)}) ? (true) : (${writeExpression(f.right, wCtx)}) )`; - // } - // - // // Other ops - // return ( - // "(" + - // writeExpression(f.left, wCtx) + - // " " + - // f.op + - // " " + - // writeExpression(f.right, wCtx) + - // ")" - // ); - throw new Error("NYI"); + if (!lt.optional && rt.optional) { + return makeCall(`__tact_int_${op}_nullable_one`, [ + this.makeExpr(this.tactExpr.right), + this.makeExpr(this.tactExpr.left), + ]); + } + const binop = this.tactExpr.op === "==" ? "==" : "!="; + return makeBinop( + this.makeExpr(this.tactExpr.left), + binop, + this.makeExpr(this.tactExpr.right), + ); } + + // Case for "&&" operator + if (this.tactExpr.op === "&&") { + const cond = this.makeExpr(this.tactExpr.left); + const trueExpr = this.makeExpr(this.tactExpr.right); + const falseExpr = { kind: "bool_expr", value: false }; + return { + kind: "ternary_expr", + cond, + trueExpr, + falseExpr, + } as FuncAstTernaryExpr; + } + + // Case for "||" operator + if (this.tactExpr.op === "||") { + const cond = this.makeExpr(this.tactExpr.left); + const trueExpr = { kind: "bool_expr", value: true }; + const falseExpr = this.makeExpr(this.tactExpr.right); + return { + kind: "ternary_expr", + cond, + trueExpr, + falseExpr, + } as FuncAstTernaryExpr; + } + + // Other ops + return makeBinop( + this.makeExpr(this.tactExpr.left), + this.tactExpr.op, + this.makeExpr(this.tactExpr.right), + ); } - // // - // // Unary operations: !, -, +, !! - // // NOTE: We always wrap in parenthesis to avoid operator precedence issues + // Unary operations: !, -, +, !! + // NOTE: We always wrap in parenthesis to avoid operator precedence issues if (this.tactExpr.kind === "op_unary") { // NOTE: Logical not is written as a bitwise not switch (this.tactExpr.op) { @@ -691,9 +748,9 @@ export class ExpressionGen { // return `(${writeExpression(f.condition, wCtx)} ? ${writeExpression(f.thenBranch, wCtx)} : ${writeExpression(f.elseBranch, wCtx)})`; // } // - // // - // // Unreachable - // // + + // + // Unreachable // throw Error(`Unknown expression: ${this.tactExpr.kind}`); } diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index 27e99a0da..70e386cb9 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -2,6 +2,7 @@ import { FuncAstExpr, FuncAstIdExpr, FuncAstCallExpr, + FuncAstBinaryOp, FuncAstStmt, } from "./syntax"; @@ -23,3 +24,15 @@ export function makeCall( export function makeExprStmt(expr: FuncAstExpr): FuncAstStmt { return { kind: "expr_stmt", expr }; } + +export function makeAssign(lhs: FuncAstExpr, rhs: FuncAstExpr): FuncAstExpr { + return { kind: "assign_expr", lhs, rhs }; +} + +export function makeBinop( + lhs: FuncAstExpr, + op: FuncAstBinaryOp, + rhs: FuncAstExpr, +): FuncAstExpr { + return { kind: "binary_expr", lhs, op, rhs }; +} From 811d659e1b523ce35c074b56d22427a2e9b1eb89 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 13 Jul 2024 06:07:34 +0000 Subject: [PATCH 011/162] chore(function): Reuse `resolveFuncType` --- src/codegen/function.ts | 97 ++--------------------------------------- 1 file changed, 4 insertions(+), 93 deletions(-) diff --git a/src/codegen/function.ts b/src/codegen/function.ts index af52b3d1b..b1dac355e 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -14,7 +14,7 @@ import { UNIT_TYPE, } from "../func/syntax"; import { StatementGen } from "./statement"; -import { resolveFuncTypeUnpack } from "./type"; +import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; /** * Encapsulates generation of Func functions from the Tact function. @@ -35,94 +35,6 @@ export class FunctionGen { return new FunctionGen(ctx, tactFun); } - /** - * Generates Func types based on the Tact type definition. - * TODO: Why do they use a separate function for this. - */ - private resolveFuncType( - descriptor: TypeRef | TypeDescription | string, - optional: boolean = false, - usePartialFields: boolean = false, - ): FuncType { - // string - if (typeof descriptor === "string") { - return this.resolveFuncType( - getType(this.ctx, descriptor), - false, - usePartialFields, - ); - } - - // TypeRef - if (descriptor.kind === "ref") { - return this.resolveFuncType( - getType(this.ctx, descriptor.name), - descriptor.optional, - usePartialFields, - ); - } - if (descriptor.kind === "map") { - return { kind: "cell" }; - } - if (descriptor.kind === "ref_bounced") { - return this.resolveFuncType( - getType(this.ctx, descriptor.name), - false, - true, - ); - } - if (descriptor.kind === "void") { - return UNIT_TYPE; - } - - // TypeDescription - if (descriptor.kind === "primitive_type_decl") { - if (descriptor.name === "Int") { - return { kind: "int" }; - } else if (descriptor.name === "Bool") { - return { kind: "int" }; - } else if (descriptor.name === "Slice") { - return { kind: "slice" }; - } else if (descriptor.name === "Cell") { - return { kind: "cell" }; - } else if (descriptor.name === "Builder") { - return { kind: "builder" }; - } else if (descriptor.name === "Address") { - return { kind: "slice" }; - } else if (descriptor.name === "String") { - return { kind: "slice" }; - } else if (descriptor.name === "StringBuilder") { - return { kind: "tuple" }; - } else { - throw Error(`Unknown primitive type: ${descriptor.name}`); - } - } else if (descriptor.kind === "struct") { - const fieldsToUse = usePartialFields - ? descriptor.fields.slice(0, descriptor.partialFieldCount) - : descriptor.fields; - if (optional || fieldsToUse.length === 0) { - return { kind: "tuple" }; - } else { - const value = fieldsToUse.map((v) => - this.resolveFuncType(v.type, false, usePartialFields), - ) as FuncTensorType; - return { kind: "tensor", value }; - } - } else if (descriptor.kind === "contract") { - if (optional || descriptor.fields.length === 0) { - return { kind: "tuple" }; - } else { - const value = descriptor.fields.map((v) => - this.resolveFuncType(v.type, false, usePartialFields), - ) as FuncTensorType; - return { kind: "tensor", value }; - } - } - - // Unreachable - throw Error(`Unknown type: ${descriptor.kind}`); - } - private resolveFuncPrimitive( descriptor: TypeRef | TypeDescription | string, ): boolean { @@ -178,7 +90,6 @@ export class FunctionGen { throw Error(`Unknown type: ${descriptor.kind}`); } - // NOTE: writeFunction /** * Generates Func function from the Tact funciton description. */ @@ -187,14 +98,14 @@ export class FunctionGen { throw new Error(`Unknown function kind: ${this.tactFun.ast.kind}`); } - let returnTy = this.resolveFuncType(this.tactFun.returns); + let returnTy = resolveFuncType(this.ctx, this.tactFun.returns); // let returnsStr: string | null; const self: TypeDescription | undefined = this.tactFun.self ? getType(this.ctx, this.tactFun.self) : undefined; if (self !== undefined && this.tactFun.isMutating) { // Add `self` to the method signature as it is mutating in the body. - const selfTy = this.resolveFuncType(self); + const selfTy = resolveFuncType(this.ctx, self); returnTy = { kind: "tensor", value: [selfTy, returnTy] }; // returnsStr = resolveFuncTypeUnpack(ctx, self, funcIdOf("self")); } @@ -204,7 +115,7 @@ export class FunctionGen { ...acc, { kind: "function_param", - ty: this.resolveFuncType(a.type), + ty: resolveFuncType(this.ctx, a.type), name: funcIdOf(a.name), }, ], From 5c0af8a1d0db70181556962c2f70c75313ab4ec1 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 00:44:43 +0000 Subject: [PATCH 012/162] feat(codegen): Constructor functions + relevant changes in AST --- src/codegen/contract.ts | 2 +- src/codegen/expression.ts | 18 ++++-- src/codegen/function.ts | 127 ++++++++++++++++++++++++-------------- src/func/formatter.ts | 3 +- src/func/syntax.ts | 1 + src/func/syntaxUtils.ts | 27 +++++++- 6 files changed, 124 insertions(+), 54 deletions(-) diff --git a/src/codegen/contract.ts b/src/codegen/contract.ts index e327f19f7..015726a6d 100644 --- a/src/codegen/contract.ts +++ b/src/codegen/contract.ts @@ -63,7 +63,7 @@ export class ContractGen { private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { // TODO: Generate init for (const tactFun of c.functions.values()) { - const funcFun = FunctionGen.fromTact(this.ctx, tactFun).generate(); + const funcFun = FunctionGen.fromTact(this.ctx).writeFunction(tactFun); } } diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 62e237357..b4293852c 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -5,11 +5,17 @@ import { idTextErr, } from "../errors"; import { evalConstantExpression } from "../constEval"; -import { resolveFuncTypeUnpack } from "./type"; +import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; import { MapFunctions, StructFunctions, GlobalFunctions } from "./abi"; import { getExpType } from "../types/resolveExpression"; +import { FunctionGen } from "./function"; import { cast, funcIdOf, ops } from "./util"; -import { printTypeRef, TypeRef, Value, FieldDescription } from "../types/types"; +import { + printTypeRef, + TypeRef, + Value, + FieldDescription, +} from "../types/types"; import { getStaticConstant, getType, @@ -78,7 +84,7 @@ export class ExpressionGen { /*** * Generates FunC literals from Tact ones. */ - private writeValue(val: Value): FuncAstExpr { + static writeValue(val: Value): FuncAstExpr { if (typeof val === "bigint") { return { kind: "number_expr", value: val }; } @@ -136,7 +142,7 @@ export class ExpressionGen { // literals and constant expressions are covered here try { const value = evalConstantExpression(this.tactExpr, this.ctx); - return this.writeValue(value); + return ExpressionGen.writeValue(value); } catch (error) { if (!(error instanceof TactConstEvalError) || error.fatal) throw error; @@ -177,7 +183,7 @@ export class ExpressionGen { // Handle constant if (hasStaticConstant(this.ctx, this.tactExpr.text)) { const c = getStaticConstant(this.ctx, this.tactExpr.text); - return this.writeValue(c.value!); + return ExpressionGen.writeValue(c.value!); } return makeId(funcIdOf(this.tactExpr.text)); @@ -511,7 +517,7 @@ export class ExpressionGen { this.makeExpr(this.tactExpr.aggregate), ]); } else { - return this.writeValue(cst!.value!); + return ExpressionGen.writeValue(cst!.value!); } } diff --git a/src/codegen/function.ts b/src/codegen/function.ts index b1dac355e..b89e0499a 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -2,17 +2,22 @@ import { CompilerContext } from "../context"; import { enabledInline } from "../config/features"; import { getType, resolveTypeRef } from "../types/resolveDescriptors"; import { ops, funcIdOf } from "./util"; +import { ExpressionGen } from "./expression"; +import { AstId } from "../grammar/ast"; import { TypeDescription, FunctionDescription, TypeRef } from "../types/types"; import { FuncAstFunction, FuncAstStmt, - FuncAstFormalFunctionParam, FuncAstFunctionAttribute, FuncAstExpr, FuncType, - FuncTensorType, - UNIT_TYPE, } from "../func/syntax"; +import { + makeId, + makeCall, + makeReturn, + makeFunction, +} from "../func/syntaxUtils"; import { StatementGen } from "./statement"; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; @@ -23,16 +28,10 @@ export class FunctionGen { /** * @param tactFun Type description of the Tact function. */ - private constructor( - private ctx: CompilerContext, - private tactFun: FunctionDescription, - ) {} - - static fromTact( - ctx: CompilerContext, - tactFun: FunctionDescription, - ): FunctionGen { - return new FunctionGen(ctx, tactFun); + private constructor(private ctx: CompilerContext) {} + + static fromTact(ctx: CompilerContext): FunctionGen { + return new FunctionGen(ctx); } private resolveFuncPrimitive( @@ -93,52 +92,40 @@ export class FunctionGen { /** * Generates Func function from the Tact funciton description. */ - public generate(): FuncAstFunction { - if (this.tactFun.ast.kind !== "function_def") { - throw new Error(`Unknown function kind: ${this.tactFun.ast.kind}`); + public writeFunction(tactFun: FunctionDescription): FuncAstFunction { + if (tactFun.ast.kind !== "function_def") { + throw new Error(`Unknown function kind: ${tactFun.ast.kind}`); } - let returnTy = resolveFuncType(this.ctx, this.tactFun.returns); + let returnTy = resolveFuncType(this.ctx, tactFun.returns); // let returnsStr: string | null; - const self: TypeDescription | undefined = this.tactFun.self - ? getType(this.ctx, this.tactFun.self) + const self: TypeDescription | undefined = tactFun.self + ? getType(this.ctx, tactFun.self) : undefined; - if (self !== undefined && this.tactFun.isMutating) { + if (self !== undefined && tactFun.isMutating) { // Add `self` to the method signature as it is mutating in the body. const selfTy = resolveFuncType(this.ctx, self); returnTy = { kind: "tensor", value: [selfTy, returnTy] }; // returnsStr = resolveFuncTypeUnpack(ctx, self, funcIdOf("self")); } - const params: FuncAstFormalFunctionParam[] = this.tactFun.params.reduce( - (acc, a) => [ - ...acc, - { - kind: "function_param", - ty: resolveFuncType(this.ctx, a.type), - name: funcIdOf(a.name), - }, - ], - self - ? [ - { - kind: "function_param", - ty: this.resolveFuncType(self), - name: funcIdOf("self"), - }, - ] - : [], + const params: [string, FuncType][] = tactFun.params.reduce( + (acc, a) => { + acc.push([funcIdOf(a.name), resolveFuncType(this.ctx, a.type)]); + return acc; + }, + self ? [[funcIdOf("self"), resolveFuncType(this.ctx, self)]] : [], ); // TODO: handle native functions delcs. should be in a separatre funciton const name = self - ? ops.extension(self.name, this.tactFun.name) - : ops.global(this.tactFun.name); + ? ops.extension(self.name, tactFun.name) + : ops.global(tactFun.name); // Prepare function attributes let attrs: FuncAstFunctionAttribute[] = ["impure"]; - if (enabledInline(this.ctx) || this.tactFun.isInline) { + if (enabledInline(this.ctx) || tactFun.isInline) { attrs.push("inline"); } // TODO: handle stdlib @@ -167,7 +154,7 @@ export class FunctionGen { ty: undefined, }); } - for (const a of this.tactFun.ast.params) { + for (const a of tactFun.ast.params) { if (!this.resolveFuncPrimitive(resolveTypeRef(this.ctx, a.type))) { const name = resolveFuncTypeUnpack( this.ctx, @@ -187,16 +174,66 @@ export class FunctionGen { ? resolveFuncTypeUnpack(this.ctx, self, funcIdOf("self")) : undefined; // Process statements - this.tactFun.ast.statements.forEach((stmt) => { + tactFun.ast.statements.forEach((stmt) => { const funcStmt = StatementGen.fromTact( this.ctx, stmt, selfName, - this.tactFun.returns, + tactFun.returns, ).writeStatement(); body.push(funcStmt); }); - return { kind: "function", attrs, params, returnTy, body }; + return makeFunction(attrs, name, params, returnTy, body); + } + + /** + * Creates a Func function that represents a constructor for the Tact struct, e.g.: + * ``` + * inline (int, int) $MyStruct_$constructor_f1_f2(int $f1, int $f2) { + * return (f1, f2); + * } + * ``` + */ + private writeStructConstructor( + type: TypeDescription, + args: AstId[], + ): FuncAstFunction { + const attrs: FuncAstFunctionAttribute[] = ["inline"]; + const name = ops.typeConstructor( + type.name, + args.map((a) => a.text), + ); + const returnTy = resolveFuncType(this.ctx, type); + // Rename a struct constructor formal parameter to avoid + // name clashes with FunC keywords, e.g. `struct Foo {type: Int}` + // is a perfectly fine Tact structure, but its constructor would + // have the wrong parameter name: `$Foo$_constructor_type(int type)` + const avoidFunCKeywordNameClash = (p: string) => `$${p}`; + const params: [string, FuncType][] = args.map((arg: AstId) => [ + avoidFunCKeywordNameClash(arg.text), + resolveFuncType( + this.ctx, + type.fields.find((v2) => v2.name === arg.text)!.type, + ), + ]); + // Create expressions used in actual arguments + const values: FuncAstExpr[] = type.fields.map((v) => { + const arg = args.find((v2) => v2.text === v.name); + if (arg) { + return makeId(avoidFunCKeywordNameClash(arg.text)); + } else if (v.default !== undefined) { + return ExpressionGen.writeValue(v.default); + } else { + throw Error( + `Missing argument for field "${v.name}" in struct "${type.name}"`, + ); // Must not happen + } + }); + const body = + values.length === 0 && returnTy.kind === "tuple" + ? [makeReturn(makeCall("empty_tuple", []))] + : [makeReturn({ kind: "tensor_expr", values })]; + return makeFunction(attrs, name, params, returnTy, body); } } diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 4941ad6ab..381dbf755 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -132,12 +132,13 @@ export class FuncFormatter { private static formatFunction(node: FuncAstFunction): string { const attrs = node.attrs.join(" "); + const name = node.name; const params = node.params .map((param) => `${param.ty} ${param.name}`) .join(", "); const returnType = node.returnTy; const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); - return `${attrs} ${params} -> ${returnType} {\n${body}\n}`; + return `${attrs} ${name} ${params} -> ${returnType} {\n${body}\n}`; } private static formatVarDefStmt(node: FuncAstVarDefStmt): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index d8f635552..8e35987a2 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -267,6 +267,7 @@ export type FuncAstFormalFunctionParam = { export type FuncAstFunction = { kind: "function"; + name: string, attrs: FuncAstFunctionAttribute[]; params: FuncAstFormalFunctionParam[]; returnTy: FuncType; diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index 70e386cb9..1b168ca21 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -1,6 +1,10 @@ import { FuncAstExpr, FuncAstIdExpr, + FuncAstFunctionAttribute, + FuncAstFormalFunctionParam, + FuncAstFunction, + FuncType, FuncAstCallExpr, FuncAstBinaryOp, FuncAstStmt, @@ -11,7 +15,7 @@ export function makeId(value: string): FuncAstIdExpr { } export function makeCall( - fun: FuncAstIdExpr | string, + fun: FuncAstExpr | string, args: FuncAstExpr[], ): FuncAstCallExpr { return { @@ -36,3 +40,24 @@ export function makeBinop( ): FuncAstExpr { return { kind: "binary_expr", lhs, op, rhs }; } + +export function makeReturn(value: FuncAstExpr | undefined): FuncAstStmt { + return { kind: "return_stmt", value }; +} + +export function makeFunction( + attrs: FuncAstFunctionAttribute[], + name: string, + paramValues: [string, FuncType][], + returnTy: FuncType, + body: FuncAstStmt[], +): FuncAstFunction { + const params = paramValues.map(([name, ty]) => { + return { + kind: "function_param", + name, + ty, + } as FuncAstFormalFunctionParam; + }); + return { kind: "function", attrs, name, params, returnTy, body }; +} From c7bfbc97f7556d8d870c69422babfc12aa523094 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 00:53:11 +0000 Subject: [PATCH 013/162] chore(codegen): Func example --- src/codegen/function.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen/function.ts b/src/codegen/function.ts index b89e0499a..045082c25 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -190,8 +190,8 @@ export class FunctionGen { /** * Creates a Func function that represents a constructor for the Tact struct, e.g.: * ``` - * inline (int, int) $MyStruct_$constructor_f1_f2(int $f1, int $f2) { - * return (f1, f2); + * ((int, int)) $MyStruct$_constructor_f1_f2(int $f1, int $f2) inline { + * return ($f1, $f2); * } * ``` */ From 2f219f3570de23c9d32535beeefe60d48ee9e8ce Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 01:04:55 +0000 Subject: [PATCH 014/162] feat(codegen): Introduce `CodegenContext` Needed for bottom-up AST generation; e.g. function definiton might be generated from the expression that calls it. --- src/codegen/context.ts | 17 ++++++ src/codegen/contract.ts | 15 +++--- src/codegen/expression.ts | 107 +++++++++++++++++--------------------- src/codegen/function.ts | 38 +++++++------- src/codegen/index.ts | 3 +- src/codegen/statement.ts | 23 ++++---- src/pipeline/compile.ts | 9 ++-- 7 files changed, 110 insertions(+), 102 deletions(-) create mode 100644 src/codegen/context.ts diff --git a/src/codegen/context.ts b/src/codegen/context.ts new file mode 100644 index 000000000..ac9f8abec --- /dev/null +++ b/src/codegen/context.ts @@ -0,0 +1,17 @@ +import { CompilerContext } from "../context"; +import { FuncAstFunction } from "../func/syntax"; + +/** + * The context containing the objects generated from the bottom-up in the generation + * process and other intermediate information. + */ +export class CodegenContext { + public ctx: CompilerContext; + + /** Generated struct constructors. */ + public constructors: FuncAstFunction[] = []; + + constructor(ctx: CompilerContext) { + this.ctx = ctx; + } +} diff --git a/src/codegen/contract.ts b/src/codegen/contract.ts index 015726a6d..84af8dd95 100644 --- a/src/codegen/contract.ts +++ b/src/codegen/contract.ts @@ -1,22 +1,21 @@ -import { CompilerContext } from "../context"; import { getAllTypes } from "../types/resolveDescriptors"; import { TypeDescription } from "../types/types"; import { getSortedTypes } from "../storage/resolveAllocation"; import { FuncAstModule, FuncAstComment } from "../func/syntax"; -import { FunctionGen } from "./function"; +import { FunctionGen, CodegenContext } from "."; /** * Encapsulates generation of Func contracts from the Tact contract. */ export class ContractGen { private constructor( - private ctx: CompilerContext, + private ctx: CodegenContext, private contractName: string, private abiName: string, ) {} static fromTact( - ctx: CompilerContext, + ctx: CodegenContext , contractName: string, abiName: string, ): ContractGen { @@ -31,7 +30,7 @@ export class ContractGen { } private addSerializers(m: FuncAstModule): void { - const sortedTypes = getSortedTypes(this.ctx); + const sortedTypes = getSortedTypes(this.ctx.ctx); for (const t of sortedTypes) { } } @@ -63,7 +62,9 @@ export class ContractGen { private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { // TODO: Generate init for (const tactFun of c.functions.values()) { - const funcFun = FunctionGen.fromTact(this.ctx).writeFunction(tactFun); + const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( + tactFun, + ); } } @@ -81,7 +82,7 @@ export class ContractGen { public generate(): FuncAstModule { const m: FuncAstModule = { kind: "module", entries: [] }; - const allTypes = Object.values(getAllTypes(this.ctx)); + const allTypes = Object.values(getAllTypes(this.ctx.ctx)); const contracts = allTypes.filter((v) => v.kind === "contract"); const contract = contracts.find((v) => v.name === this.contractName); if (contract === undefined) { diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index b4293852c..8ba9f74f8 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -1,4 +1,3 @@ -import { CompilerContext } from "../context"; import { TactConstEvalError, throwCompilationError, @@ -8,7 +7,7 @@ import { evalConstantExpression } from "../constEval"; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; import { MapFunctions, StructFunctions, GlobalFunctions } from "./abi"; import { getExpType } from "../types/resolveExpression"; -import { FunctionGen } from "./function"; +import { FunctionGen, CodegenContext } from "."; import { cast, funcIdOf, ops } from "./util"; import { printTypeRef, @@ -70,12 +69,12 @@ export class ExpressionGen { * @param tactExpr Expression to translate. */ private constructor( - private ctx: CompilerContext, + private ctx: CodegenContext, private tactExpr: AstExpression, ) {} static fromTact( - ctx: CompilerContext, + ctx: CodegenContext, tactExpr: AstExpression, ): ExpressionGen { return new ExpressionGen(ctx, tactExpr); @@ -141,7 +140,7 @@ export class ExpressionGen { public writeExpression(): FuncAstExpr { // literals and constant expressions are covered here try { - const value = evalConstantExpression(this.tactExpr, this.ctx); + const value = evalConstantExpression(this.tactExpr, this.ctx.ctx); return ExpressionGen.writeValue(value); } catch (error) { if (!(error instanceof TactConstEvalError) || error.fatal) @@ -152,14 +151,14 @@ export class ExpressionGen { // ID Reference // if (this.tactExpr.kind === "id") { - const t = getExpType(this.ctx, this.tactExpr); + const t = getExpType(this.ctx.ctx, this.tactExpr); // Handle packed type if (t.kind === "ref") { - const tt = getType(this.ctx, t.name); + const tt = getType(this.ctx.ctx, t.name); if (tt.kind === "contract" || tt.kind === "struct") { const value = resolveFuncTypeUnpack( - this.ctx, + this.ctx.ctx, t, funcIdOf(this.tactExpr.text), ); @@ -168,10 +167,10 @@ export class ExpressionGen { } if (t.kind === "ref_bounced") { - const tt = getType(this.ctx, t.name); + const tt = getType(this.ctx.ctx, t.name); if (tt.kind === "struct") { const value = resolveFuncTypeUnpack( - this.ctx, + this.ctx.ctx, t, funcIdOf(this.tactExpr.text), false, @@ -181,8 +180,8 @@ export class ExpressionGen { } // Handle constant - if (hasStaticConstant(this.ctx, this.tactExpr.text)) { - const c = getStaticConstant(this.ctx, this.tactExpr.text); + if (hasStaticConstant(this.ctx.ctx, this.tactExpr.text)) { + const c = getStaticConstant(this.ctx.ctx, this.tactExpr.text); return ExpressionGen.writeValue(c.value!); } @@ -218,8 +217,8 @@ export class ExpressionGen { } // Special case for address - const lt = getExpType(this.ctx, this.tactExpr.left); - const rt = getExpType(this.ctx, this.tactExpr.right); + const lt = getExpType(this.ctx.ctx, this.tactExpr.left); + const rt = getExpType(this.ctx.ctx, this.tactExpr.right); // Case for addresses equality if ( @@ -437,9 +436,9 @@ export class ExpressionGen { // NOTE: Assert function that ensures that the value is not null case "!!": { - const t = getExpType(this.ctx, this.tactExpr.operand); + const t = getExpType(this.ctx.ctx, this.tactExpr.operand); if (t.kind === "ref") { - const tt = getType(this.ctx, t.name); + const tt = getType(this.ctx.ctx, t.name); if (tt.kind === "struct") { return makeCall(ops.typeNotNull(tt.name), [ this.makeExpr(this.tactExpr.operand), @@ -459,7 +458,7 @@ export class ExpressionGen { // if (this.tactExpr.kind === "field_access") { // Resolve the type of the expression - const src = getExpType(this.ctx, this.tactExpr.aggregate); + const src = getExpType(this.ctx.ctx, this.tactExpr.aggregate); if ( (src.kind !== "ref" || src.optional) && src.kind !== "ref_bounced" @@ -469,7 +468,7 @@ export class ExpressionGen { this.tactExpr.loc, ); } - const srcT = getType(this.ctx, src.name); + const srcT = getType(this.ctx.ctx, src.name); // Resolve field let fields: FieldDescription[]; @@ -498,11 +497,11 @@ export class ExpressionGen { // Special case for structs if (field.type.kind === "ref") { - const ft = getType(this.ctx, field.type.name); + const ft = getType(this.ctx.ctx, field.type.name); if (ft.kind === "struct" || ft.kind === "contract") { return makeId( resolveFuncTypeUnpack( - this.ctx, + this.ctx.ctx, field.type, idd.value, ), @@ -530,14 +529,14 @@ export class ExpressionGen { return GlobalFunctions.get( idText(this.tactExpr.function), )!.generate( - this.tactExpr.args.map((v) => getExpType(this.ctx, v)), + this.tactExpr.args.map((v) => getExpType(this.ctx.ctx, v)), this.tactExpr.args, this.tactExpr.loc, ); } const sf = getStaticFunction( - this.ctx, + this.ctx.ctx, idText(this.tactExpr.function), ); // if (sf.ast.kind === "native_function_decl") { @@ -555,42 +554,34 @@ export class ExpressionGen { return { kind: "call_expr", fun, args }; } + // // + // // Struct Constructor + // // + // if (this.tactExpr.kind === "struct_instance") { + // const src = getType(this.ctx.ctx, this.tactExpr.type); // - // // - // // Struct Constructor - // // - // - // if (f.kind === "struct_instance") { - // const src = getType(wCtx.ctx, f.type); - // - // // Write a constructor - // const id = writeStructConstructor( - // src, - // f.args.map((v) => idText(v.field)), - // wCtx, - // ); - // wCtx.used(id); - // - // // Write an expression - // const expressions = f.args.map( - // (v) => - // writeCastedExpression( - // v.initializer, - // src.fields.find((v2) => eqNames(v2.name, v.field))! - // .type, - // wCtx, - // ), - // wCtx, - // ); - // return `${id}(${expressions.join(", ")})`; - // } + // // Write a constructor + // // const id = FunctionGen.fromTact(this.ctx.ctx).writeStructConstructor( + // // src, + // // this.tactExpr.args.map((v) => v.field), + // // ); // + // // Write an expression + // const args = this.tactExpr.args.map((v) => + // this.makeCastedExpr( + // v.initializer, + // src.fields.find((v2) => eqNames(v2.name, v.field))!.type, + // ), + // ); + // return makeCall(id, args); + // } + // // Object-based function call // if (this.tactExpr.kind === "method_call") { // Resolve source type - const src = getExpType(this.ctx, this.tactExpr.self); + const src = getExpType(this.ctx.ctx, this.tactExpr.self); // Reference type if (src.kind === "ref") { @@ -602,7 +593,7 @@ export class ExpressionGen { } // Render function call - const methodTy = getType(this.ctx, src.name); + const methodTy = getType(this.ctx.ctx, src.name); // Check struct ABI if (methodTy.kind === "struct") { @@ -615,7 +606,7 @@ export class ExpressionGen { // wCtx, // [ // src, - // ...this.tactExpr.args.map((v) => getExpType(this.ctx, v)), + // ...this.tactExpr.args.map((v) => getExpType(this.ctx.ctx, v)), // ], // [this.tactExpr.self, ...this.tactExpr.args], // this.tactExpr.loc, @@ -652,9 +643,9 @@ export class ExpressionGen { // func would convert (int) type to just int and break mutating functions if (methodFun.isMutating) { if (this.tactExpr.args.length === 1) { - const t = getExpType(this.ctx, this.tactExpr.args[0]!); + const t = getExpType(this.ctx.ctx, this.tactExpr.args[0]!); if (t.kind === "ref") { - const tt = getType(this.ctx, t.name); + const tt = getType(this.ctx.ctx, t.name); if ( (tt.kind === "contract" || tt.kind === "struct") && @@ -718,7 +709,7 @@ export class ExpressionGen { [ src, ...this.tactExpr.args.map((v) => - getExpType(this.ctx, v), + getExpType(this.ctx.ctx, v), ), ], [this.tactExpr.self, ...this.tactExpr.args], @@ -766,8 +757,8 @@ export class ExpressionGen { } public writeCastedExpression(to: TypeRef): FuncAstExpr { - const expr = getExpType(this.ctx, this.tactExpr); - return cast(this.ctx, expr, to, this.writeExpression()); + const expr = getExpType(this.ctx.ctx, this.tactExpr); + return cast(this.ctx.ctx, expr, to, this.writeExpression()); } private makeCastedExpr(src: AstExpression, to: TypeRef): FuncAstExpr { diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 045082c25..97b729cf7 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -1,8 +1,6 @@ -import { CompilerContext } from "../context"; import { enabledInline } from "../config/features"; import { getType, resolveTypeRef } from "../types/resolveDescriptors"; import { ops, funcIdOf } from "./util"; -import { ExpressionGen } from "./expression"; import { AstId } from "../grammar/ast"; import { TypeDescription, FunctionDescription, TypeRef } from "../types/types"; import { @@ -18,7 +16,7 @@ import { makeReturn, makeFunction, } from "../func/syntaxUtils"; -import { StatementGen } from "./statement"; +import { StatementGen, ExpressionGen , CodegenContext } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; /** @@ -28,9 +26,9 @@ export class FunctionGen { /** * @param tactFun Type description of the Tact function. */ - private constructor(private ctx: CompilerContext) {} + private constructor(private ctx: CodegenContext) {} - static fromTact(ctx: CompilerContext): FunctionGen { + static fromTact(ctx: CodegenContext): FunctionGen { return new FunctionGen(ctx); } @@ -39,13 +37,13 @@ export class FunctionGen { ): boolean { // String if (typeof descriptor === "string") { - return this.resolveFuncPrimitive(getType(this.ctx, descriptor)); + return this.resolveFuncPrimitive(getType(this.ctx.ctx, descriptor)); } // TypeRef if (descriptor.kind === "ref") { return this.resolveFuncPrimitive( - getType(this.ctx, descriptor.name), + getType(this.ctx.ctx, descriptor.name), ); } if (descriptor.kind === "map") { @@ -97,24 +95,24 @@ export class FunctionGen { throw new Error(`Unknown function kind: ${tactFun.ast.kind}`); } - let returnTy = resolveFuncType(this.ctx, tactFun.returns); + let returnTy = resolveFuncType(this.ctx.ctx, tactFun.returns); // let returnsStr: string | null; const self: TypeDescription | undefined = tactFun.self - ? getType(this.ctx, tactFun.self) + ? getType(this.ctx.ctx, tactFun.self) : undefined; if (self !== undefined && tactFun.isMutating) { // Add `self` to the method signature as it is mutating in the body. - const selfTy = resolveFuncType(this.ctx, self); + const selfTy = resolveFuncType(this.ctx.ctx, self); returnTy = { kind: "tensor", value: [selfTy, returnTy] }; // returnsStr = resolveFuncTypeUnpack(ctx, self, funcIdOf("self")); } const params: [string, FuncType][] = tactFun.params.reduce( (acc, a) => { - acc.push([funcIdOf(a.name), resolveFuncType(this.ctx, a.type)]); + acc.push([funcIdOf(a.name), resolveFuncType(this.ctx.ctx, a.type)]); return acc; }, - self ? [[funcIdOf("self"), resolveFuncType(this.ctx, self)]] : [], + self ? [[funcIdOf("self"), resolveFuncType(this.ctx.ctx, self)]] : [], ); // TODO: handle native functions delcs. should be in a separatre funciton @@ -125,7 +123,7 @@ export class FunctionGen { // Prepare function attributes let attrs: FuncAstFunctionAttribute[] = ["impure"]; - if (enabledInline(this.ctx) || tactFun.isInline) { + if (enabledInline(this.ctx.ctx) || tactFun.isInline) { attrs.push("inline"); } // TODO: handle stdlib @@ -139,7 +137,7 @@ export class FunctionGen { // Add arguments if (self) { const varName = resolveFuncTypeUnpack( - this.ctx, + this.ctx.ctx, self, funcIdOf("self"), ); @@ -155,10 +153,10 @@ export class FunctionGen { }); } for (const a of tactFun.ast.params) { - if (!this.resolveFuncPrimitive(resolveTypeRef(this.ctx, a.type))) { + if (!this.resolveFuncPrimitive(resolveTypeRef(this.ctx.ctx, a.type))) { const name = resolveFuncTypeUnpack( - this.ctx, - resolveTypeRef(this.ctx, a.type), + this.ctx.ctx, + resolveTypeRef(this.ctx.ctx, a.type), funcIdOf(a.name), ); const init: FuncAstExpr = { @@ -171,7 +169,7 @@ export class FunctionGen { const selfName = self !== undefined - ? resolveFuncTypeUnpack(this.ctx, self, funcIdOf("self")) + ? resolveFuncTypeUnpack(this.ctx.ctx, self, funcIdOf("self")) : undefined; // Process statements tactFun.ast.statements.forEach((stmt) => { @@ -204,7 +202,7 @@ export class FunctionGen { type.name, args.map((a) => a.text), ); - const returnTy = resolveFuncType(this.ctx, type); + const returnTy = resolveFuncType(this.ctx.ctx, type); // Rename a struct constructor formal parameter to avoid // name clashes with FunC keywords, e.g. `struct Foo {type: Int}` // is a perfectly fine Tact structure, but its constructor would @@ -213,7 +211,7 @@ export class FunctionGen { const params: [string, FuncType][] = args.map((arg: AstId) => [ avoidFunCKeywordNameClash(arg.text), resolveFuncType( - this.ctx, + this.ctx.ctx, type.fields.find((v2) => v2.name === arg.text)!.type, ), ]); diff --git a/src/codegen/index.ts b/src/codegen/index.ts index cdc3b3db3..48ab5d4fd 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -1,4 +1,5 @@ +export { CodegenContext } from "./context"; export { ContractGen } from "./contract"; export { FunctionGen } from "./function"; export { StatementGen } from "./statement"; -export { ExpressionGen } from "./expression"; +export { ExpressionGen, writePathExpression } from "./expression"; diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index 0ff25374b..7878802a6 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -1,4 +1,3 @@ -import { CompilerContext } from "../context"; import { throwInternalCompilerError } from "../errors"; import { funcIdOf } from "./util"; import { getType, resolveTypeRef } from "../types/resolveDescriptors"; @@ -11,7 +10,7 @@ import { isWildcard, tryExtractPath, } from "../grammar/ast"; -import { ExpressionGen, writePathExpression } from "./expression"; +import { ExpressionGen, writePathExpression, CodegenContext } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; import { FuncAstStmt, @@ -32,14 +31,14 @@ export class StatementGen { * @param returns The return value of the return statement. */ private constructor( - private ctx: CompilerContext, + private ctx: CodegenContext, private tactStmt: AstStatement, private selfName?: string, private returns?: TypeRef, ) {} static fromTact( - ctx: CompilerContext, + ctx: CodegenContext, tactStmt: AstStatement, selfVarName?: string, returns?: TypeRef, @@ -128,11 +127,11 @@ export class StatementGen { // Contract/struct case const t = this.tactStmt.type === null - ? getExpType(this.ctx, this.tactStmt.expression) - : resolveTypeRef(this.ctx, this.tactStmt.type); + ? getExpType(this.ctx.ctx, this.tactStmt.expression) + : resolveTypeRef(this.ctx.ctx, this.tactStmt.type); if (t.kind === "ref") { - const tt = getType(this.ctx, t.name); + const tt = getType(this.ctx.ctx, t.name); if (tt.kind === "contract" || tt.kind === "struct") { if (t.optional) { const name = funcIdOf(this.tactStmt.name); @@ -148,7 +147,7 @@ export class StatementGen { }; } else { const name = resolveFuncTypeUnpack( - this.ctx, + this.ctx.ctx, t, funcIdOf(this.tactStmt.name), ); @@ -166,7 +165,7 @@ export class StatementGen { } } - const ty = resolveFuncType(this.ctx, t); + const ty = resolveFuncType(this.ctx.ctx, t); const name = funcIdOf(this.tactStmt.name); const init = this.makeCastedExpr(this.tactStmt.expression, t); return { kind: "var_def_stmt", name, ty, init }; @@ -185,12 +184,12 @@ export class StatementGen { const path = writePathExpression(lvaluePath); // Contract/struct case - const t = getExpType(this.ctx, this.tactStmt.path); + const t = getExpType(this.ctx.ctx, this.tactStmt.path); if (t.kind === "ref") { - const tt = getType(this.ctx, t.name); + const tt = getType(this.ctx.ctx, t.name); if (tt.kind === "contract" || tt.kind === "struct") { const lhs = makeId( - resolveFuncTypeUnpack(this.ctx, t, path.value), + resolveFuncTypeUnpack(this.ctx.ctx, t, path.value), ); const rhs = this.makeCastedExpr( this.tactStmt.expression, diff --git a/src/pipeline/compile.ts b/src/pipeline/compile.ts index e73bd693b..f517d9dab 100644 --- a/src/pipeline/compile.ts +++ b/src/pipeline/compile.ts @@ -1,7 +1,7 @@ import { CompilerContext } from "../context"; import { createABI } from "../generator/createABI"; import { writeProgram } from "../generator/writeProgram"; -import { ContractGen } from "../codegen"; +import { ContractGen, CodegenContext } from "../codegen"; import { FuncFormatter } from "../func/formatter"; export type CompilationOutput = { @@ -28,12 +28,13 @@ export async function compile( ): Promise { const abi = createABI(ctx, contractName); if (process.env.NEW_CODEGEN === "1") { - const funcAst = ContractGen.fromTact( - ctx, + const codegenCtx = new CodegenContext(ctx); + const funcContract = ContractGen.fromTact( + codegenCtx, contractName, abiName, ).generate(); - const output = FuncFormatter.dump(funcAst); + const output = FuncFormatter.dump(funcContract); throw new Error(`output:\n${output}`); // return { output, ctx }; } else { From 7d5e5f3ff18bd6126505751dff571b85c72dae0a Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 01:10:36 +0000 Subject: [PATCH 015/162] feat(codegen): Calls to constructor functions + context-related logic --- src/codegen/context.ts | 19 ++++++++++++++++++- src/codegen/expression.ts | 39 ++++++++++++++++++++------------------- src/codegen/function.ts | 2 +- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index ac9f8abec..bf357659d 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -1,6 +1,12 @@ import { CompilerContext } from "../context"; import { FuncAstFunction } from "../func/syntax"; +type ContextValues = { + constructor: FuncAstFunction; +}; + +export type ContextValueKind = keyof ContextValues; + /** * The context containing the objects generated from the bottom-up in the generation * process and other intermediate information. @@ -9,9 +15,20 @@ export class CodegenContext { public ctx: CompilerContext; /** Generated struct constructors. */ - public constructors: FuncAstFunction[] = []; + private constructors: FuncAstFunction[] = []; constructor(ctx: CompilerContext) { this.ctx = ctx; } + + public add( + kind: K, + value: ContextValues[K], + ): void { + switch (kind) { + case "constructor": + this.constructors.push(value as FuncAstFunction); + break; + } + } } diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 8ba9f74f8..79aaa283a 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -554,27 +554,28 @@ export class ExpressionGen { return { kind: "call_expr", fun, args }; } - // // - // // Struct Constructor - // // - // if (this.tactExpr.kind === "struct_instance") { - // const src = getType(this.ctx.ctx, this.tactExpr.type); // - // // Write a constructor - // // const id = FunctionGen.fromTact(this.ctx.ctx).writeStructConstructor( - // // src, - // // this.tactExpr.args.map((v) => v.field), - // // ); + // Struct Constructor // - // // Write an expression - // const args = this.tactExpr.args.map((v) => - // this.makeCastedExpr( - // v.initializer, - // src.fields.find((v2) => eqNames(v2.name, v.field))!.type, - // ), - // ); - // return makeCall(id, args); - // } + if (this.tactExpr.kind === "struct_instance") { + const src = getType(this.ctx.ctx, this.tactExpr.type); + + // Write a constructor + const constructor = FunctionGen.fromTact(this.ctx).writeStructConstructor( + src, + this.tactExpr.args.map((v) => v.field), + ); + this.ctx.add("constructor", constructor); + + // Write an expression + const args = this.tactExpr.args.map((v) => + this.makeCastedExpr( + v.initializer, + src.fields.find((v2) => eqNames(v2.name, v.field))!.type, + ), + ); + return makeCall(constructor.name, args); + } // // Object-based function call diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 97b729cf7..76f288925 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -193,7 +193,7 @@ export class FunctionGen { * } * ``` */ - private writeStructConstructor( + public writeStructConstructor( type: TypeDescription, args: AstId[], ): FuncAstFunction { From b0f0dc434da0ef86d1367d68eb28bb369a8d6236 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 01:22:22 +0000 Subject: [PATCH 016/162] feat(codegen): Support struct values/objects --- src/codegen/expression.ts | 73 ++++++++++++++++++++------------------- src/codegen/function.ts | 34 +++++++++++------- 2 files changed, 60 insertions(+), 47 deletions(-) diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 79aaa283a..59607f907 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -4,17 +4,12 @@ import { idTextErr, } from "../errors"; import { evalConstantExpression } from "../constEval"; -import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; +import { resolveFuncTypeUnpack } from "./type"; import { MapFunctions, StructFunctions, GlobalFunctions } from "./abi"; import { getExpType } from "../types/resolveExpression"; import { FunctionGen, CodegenContext } from "."; import { cast, funcIdOf, ops } from "./util"; -import { - printTypeRef, - TypeRef, - Value, - FieldDescription, -} from "../types/types"; +import { printTypeRef, TypeRef, Value, FieldDescription } from "../types/types"; import { getStaticConstant, getType, @@ -54,6 +49,7 @@ function negate(expr: FuncAstExpr): FuncAstExpr { /** * Creates a Func identifier in the following format: a'b'c. + * TODO: make it a static method */ export function writePathExpression(path: AstId[]): FuncAstIdExpr { return makeId( @@ -83,7 +79,7 @@ export class ExpressionGen { /*** * Generates FunC literals from Tact ones. */ - static writeValue(val: Value): FuncAstExpr { + static writeValue(ctx: CodegenContext, val: Value): FuncAstExpr { if (typeof val === "bigint") { return { kind: "number_expr", value: val }; } @@ -113,27 +109,29 @@ export class ExpressionGen { // wCtx.used(id); // return `${id}()`; // } - // if (typeof val === "object" && "$tactStruct" in val) { - // // this is a struct value - // const structDescription = getType( - // wCtx.ctx, - // val["$tactStruct"] as string, - // ); - // const fields = structDescription.fields.map((field) => field.name); - // const id = writeStructConstructor(structDescription, fields, wCtx); - // wCtx.used(id); - // const fieldValues = structDescription.fields.map((field) => { - // if (field.name in val) { - // return writeValue(val[field.name]!, wCtx); - // } else { - // throw Error( - // `Struct value is missing a field: ${field.name}`, - // val, - // ); - // } - // }); - // return `${id}(${fieldValues.join(", ")})`; - // } + if (typeof val === "object" && "$tactStruct" in val) { + // this is a struct value + const structDescription = getType( + ctx.ctx, + val["$tactStruct"] as string, + ); + const fields = structDescription.fields.map((field) => field.name); + const constructor = FunctionGen.fromTact( + ctx, + ).writeStructConstructor(structDescription, fields); + ctx.add("constructor", constructor); + const fieldValues = structDescription.fields.map((field) => { + if (field.name in val) { + return ExpressionGen.writeValue(ctx, val[field.name]!); + } else { + throw Error( + `Struct value is missing a field: ${field.name}`, + val, + ); + } + }); + return makeCall(constructor.name, fieldValues); + } throw Error(`Invalid value: ${val}`); } @@ -141,7 +139,7 @@ export class ExpressionGen { // literals and constant expressions are covered here try { const value = evalConstantExpression(this.tactExpr, this.ctx.ctx); - return ExpressionGen.writeValue(value); + return ExpressionGen.writeValue(this.ctx,value); } catch (error) { if (!(error instanceof TactConstEvalError) || error.fatal) throw error; @@ -182,7 +180,7 @@ export class ExpressionGen { // Handle constant if (hasStaticConstant(this.ctx.ctx, this.tactExpr.text)) { const c = getStaticConstant(this.ctx.ctx, this.tactExpr.text); - return ExpressionGen.writeValue(c.value!); + return ExpressionGen.writeValue(this.ctx, c.value!); } return makeId(funcIdOf(this.tactExpr.text)); @@ -516,7 +514,7 @@ export class ExpressionGen { this.makeExpr(this.tactExpr.aggregate), ]); } else { - return ExpressionGen.writeValue(cst!.value!); + return ExpressionGen.writeValue(this.ctx, cst!.value!); } } @@ -561,9 +559,11 @@ export class ExpressionGen { const src = getType(this.ctx.ctx, this.tactExpr.type); // Write a constructor - const constructor = FunctionGen.fromTact(this.ctx).writeStructConstructor( + const constructor = FunctionGen.fromTact( + this.ctx, + ).writeStructConstructor( src, - this.tactExpr.args.map((v) => v.field), + this.tactExpr.args.map((v) => v.field.text), ); this.ctx.add("constructor", constructor); @@ -644,7 +644,10 @@ export class ExpressionGen { // func would convert (int) type to just int and break mutating functions if (methodFun.isMutating) { if (this.tactExpr.args.length === 1) { - const t = getExpType(this.ctx.ctx, this.tactExpr.args[0]!); + const t = getExpType( + this.ctx.ctx, + this.tactExpr.args[0]!, + ); if (t.kind === "ref") { const tt = getType(this.ctx.ctx, t.name); if ( diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 76f288925..d080d1984 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -16,7 +16,7 @@ import { makeReturn, makeFunction, } from "../func/syntaxUtils"; -import { StatementGen, ExpressionGen , CodegenContext } from "."; +import { StatementGen, ExpressionGen, CodegenContext } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; /** @@ -109,10 +109,15 @@ export class FunctionGen { const params: [string, FuncType][] = tactFun.params.reduce( (acc, a) => { - acc.push([funcIdOf(a.name), resolveFuncType(this.ctx.ctx, a.type)]); + acc.push([ + funcIdOf(a.name), + resolveFuncType(this.ctx.ctx, a.type), + ]); return acc; }, - self ? [[funcIdOf("self"), resolveFuncType(this.ctx.ctx, self)]] : [], + self + ? [[funcIdOf("self"), resolveFuncType(this.ctx.ctx, self)]] + : [], ); // TODO: handle native functions delcs. should be in a separatre funciton @@ -153,7 +158,9 @@ export class FunctionGen { }); } for (const a of tactFun.ast.params) { - if (!this.resolveFuncPrimitive(resolveTypeRef(this.ctx.ctx, a.type))) { + if ( + !this.resolveFuncPrimitive(resolveTypeRef(this.ctx.ctx, a.type)) + ) { const name = resolveFuncTypeUnpack( this.ctx.ctx, resolveTypeRef(this.ctx.ctx, a.type), @@ -192,15 +199,18 @@ export class FunctionGen { * return ($f1, $f2); * } * ``` + * + * @param type Type description of the struct for which the constructor is generated + * @param args Names of the arguments */ public writeStructConstructor( type: TypeDescription, - args: AstId[], + args: string[], ): FuncAstFunction { const attrs: FuncAstFunctionAttribute[] = ["inline"]; const name = ops.typeConstructor( type.name, - args.map((a) => a.text), + args.map((a) => a), ); const returnTy = resolveFuncType(this.ctx.ctx, type); // Rename a struct constructor formal parameter to avoid @@ -208,20 +218,20 @@ export class FunctionGen { // is a perfectly fine Tact structure, but its constructor would // have the wrong parameter name: `$Foo$_constructor_type(int type)` const avoidFunCKeywordNameClash = (p: string) => `$${p}`; - const params: [string, FuncType][] = args.map((arg: AstId) => [ - avoidFunCKeywordNameClash(arg.text), + const params: [string, FuncType][] = args.map((arg: string) => [ + avoidFunCKeywordNameClash(arg), resolveFuncType( this.ctx.ctx, - type.fields.find((v2) => v2.name === arg.text)!.type, + type.fields.find((v2) => v2.name === arg)!.type, ), ]); // Create expressions used in actual arguments const values: FuncAstExpr[] = type.fields.map((v) => { - const arg = args.find((v2) => v2.text === v.name); + const arg = args.find((v2) => v2 === v.name); if (arg) { - return makeId(avoidFunCKeywordNameClash(arg.text)); + return makeId(avoidFunCKeywordNameClash(arg)); } else if (v.default !== undefined) { - return ExpressionGen.writeValue(v.default); + return ExpressionGen.writeValue(this.ctx, v.default); } else { throw Error( `Missing argument for field "${v.name}" in struct "${type.name}"`, From a7f85c52fab2a0a2dfc405beec4c947204d8563c Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 01:41:55 +0000 Subject: [PATCH 017/162] fix(codegen): Minor errors --- package.json | 2 ++ src/codegen/contract.ts | 5 +++-- src/codegen/statement.ts | 9 ++++----- src/func/formatter.ts | 4 +++- src/pipeline/compile.ts | 2 +- yarn.lock | 17 +++++++++++++++++ 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 556ce28db..9774c5a84 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,11 @@ "@tact-lang/opcode": "^0.0.14", "@ton/core": "0.56.3", "@ton/crypto": "^3.2.0", + "@types/json-bigint": "^1.0.4", "blockstore-core": "1.0.5", "change-case": "^4.1.2", "ipfs-unixfs-importer": "9.0.10", + "json-bigint": "^1.0.0", "meow": "^13.2.0", "mkdirp": "^2.1.3", "multiformats": "^13.1.0", diff --git a/src/codegen/contract.ts b/src/codegen/contract.ts index 84af8dd95..87ee95c00 100644 --- a/src/codegen/contract.ts +++ b/src/codegen/contract.ts @@ -15,7 +15,7 @@ export class ContractGen { ) {} static fromTact( - ctx: CodegenContext , + ctx: CodegenContext, contractName: string, abiName: string, ): ContractGen { @@ -65,6 +65,7 @@ export class ContractGen { const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( tactFun, ); + m.entries.push(funcFun); } } @@ -79,7 +80,7 @@ export class ContractGen { m.entries.push(c); } - public generate(): FuncAstModule { + public writeProgram(): FuncAstModule { const m: FuncAstModule = { kind: "module", entries: [] }; const allTypes = Object.values(getAllTypes(this.ctx.ctx)); diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index 7878802a6..5230620cc 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -19,7 +19,7 @@ import { FuncAstTupleExpr, FuncAstUnitExpr, } from "../func/syntax"; -import { makeId, makeExprStmt } from "../func/syntaxUtils"; +import { makeId, makeExprStmt, makeReturn } from "../func/syntaxUtils"; /** * Encapsulates generation of Func statements from the Tact statement. @@ -94,9 +94,8 @@ export class StatementGen { public writeStatement(): FuncAstStmt { switch (this.tactStmt.kind) { case "statement_return": { - const kind = "return_stmt"; const selfVar = this.selfName - ? { kind: "id", value: this.selfName } + ? makeId(this.selfName) : undefined; const getValue = (expr: FuncAstExpr): FuncAstExpr => this.selfName @@ -110,10 +109,10 @@ export class StatementGen { this.tactStmt.expression, this.returns!, ); - return { kind, value: getValue(castedReturns) }; + return makeReturn(getValue(castedReturns)); } else { const unit = { kind: "unit_expr" } as FuncAstUnitExpr; - return { kind, value: getValue(unit) }; + return makeReturn(getValue(unit)); } } case "statement_let": { diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 381dbf755..8ff15c560 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -36,6 +36,8 @@ import { FuncAstPrimitiveTypeExpr, } from "./syntax"; +import JSONbig from "json-bigint"; + /** * Provides utilities to print the generated Func AST. */ @@ -122,7 +124,7 @@ export class FuncFormatter { node as FuncAstPrimitiveTypeExpr, ); default: - throw new Error(`Unsupported node kind: ${node}`); + throw new Error(`Unsupported node: ${JSONbig.stringify(node, null, 2)}`); } } diff --git a/src/pipeline/compile.ts b/src/pipeline/compile.ts index f517d9dab..fe61f35a8 100644 --- a/src/pipeline/compile.ts +++ b/src/pipeline/compile.ts @@ -33,7 +33,7 @@ export async function compile( codegenCtx, contractName, abiName, - ).generate(); + ).writeProgram(); const output = FuncFormatter.dump(funcContract); throw new Error(`output:\n${output}`); // return { output, ctx }; diff --git a/yarn.lock b/yarn.lock index fedbb35c6..50d09a4db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1416,6 +1416,11 @@ resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.9.tgz#cd82382c4f902fed9691a2ed79ec68c5898af4c2" integrity sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg== +"@types/json-bigint@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@types/json-bigint/-/json-bigint-1.0.4.tgz#250d29e593375499d8ba6efaab22d094c3199ef3" + integrity sha512-ydHooXLbOmxBbubnA7Eh+RpBzuaIiQjh8WGJYQB50JFGFrdxW7JzVlyEV7fAXw0T2sqJ1ysTneJbiyNLqZRAag== + "@types/json-schema@^7.0.15": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" @@ -1841,6 +1846,11 @@ big-integer@^1.6.44: resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.52.tgz#60a887f3047614a8e1bffe5d7173490a97dc8c85" integrity sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg== +bignumber.js@^9.0.0: + version "9.1.2" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c" + integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug== + bl@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" @@ -4458,6 +4468,13 @@ jsesc@^2.5.1: resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== +json-bigint@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-1.0.0.tgz#ae547823ac0cad8398667f8cd9ef4730f5b01ff1" + integrity sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ== + dependencies: + bignumber.js "^9.0.0" + json-buffer@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" From e3e0715da51cefe350e03f02e24e57a826423725 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 01:45:59 +0000 Subject: [PATCH 018/162] feat(ast): Multiline comments --- src/func/formatter.ts | 2 +- src/func/syntax.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 8ff15c560..f5a93b17a 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -310,7 +310,7 @@ export class FuncFormatter { } private static formatComment(node: FuncAstComment): string { - return `;; ${node.value}`; + return node.values.map((v) => `;; ${v}`).join('\n'); } private static formatType(node: FuncType): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 8e35987a2..3ab124754 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -276,7 +276,7 @@ export type FuncAstFunction = { export type FuncAstComment = { kind: "comment"; - value: string; + values: string[]; // Represents multiline comments }; export type FuncAstInclude = { From ee6d514e2c55da45001686cfd24dff738d1d8688 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 01:54:39 +0000 Subject: [PATCH 019/162] fix(formatter): Function signatures --- src/func/formatter.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index f5a93b17a..9b399a1d7 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -136,11 +136,11 @@ export class FuncFormatter { const attrs = node.attrs.join(" "); const name = node.name; const params = node.params - .map((param) => `${param.ty} ${param.name}`) + .map((param) => `${this.dump(param.ty)} ${param.name}`) .join(", "); - const returnType = node.returnTy; + const returnType = this.dump(node.returnTy); const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); - return `${attrs} ${name} ${params} -> ${returnType} {\n${body}\n}`; + return `${returnType} ${name}(${params}) ${attrs} {\n${body}\n}`; } private static formatVarDefStmt(node: FuncAstVarDefStmt): string { @@ -324,9 +324,9 @@ export class FuncFormatter { case "type": return node.kind; case "tensor": - return `tensor(${node.value.map((t) => this.formatType(t)).join(", ")})`; + return `(${node.value.map((t) => this.formatType(t)).join(", ")})`; default: - throw new Error(`Unsupported type kind: ${node}`); + throw new Error(`Unsupported type kind: ${JSONbig.stringify(node, null, 2)}`); } } } From 271f3c85dd4774b659cf5229ad1630e55d182e69 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 01:59:52 +0000 Subject: [PATCH 020/162] feat(formatter): Indentation --- src/func/formatter.ts | 130 +++++++++++++++++++++------------------- src/pipeline/compile.ts | 2 +- 2 files changed, 68 insertions(+), 64 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 9b399a1d7..a5f49eeef 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -42,7 +42,15 @@ import JSONbig from "json-bigint"; * Provides utilities to print the generated Func AST. */ export class FuncFormatter { - public static dump(node: FuncAstNode): string { + private indent: number; + private currentIndent: number; + + constructor(indent: number = 4) { + this.indent = indent; + this.currentIndent = 0; + } + + public dump(node: FuncAstNode): string { switch (node.kind) { case "id_expr": return this.formatIdExpr(node as FuncAstIdExpr); @@ -92,9 +100,7 @@ export class FuncFormatter { case "assign_expr": return this.formatAssignExpr(node as FuncAstAssignExpr); case "augmented_assign_expr": - return this.formatAugmentedAssignExpr( - node as FuncAstAugmentedAssignExpr, - ); + return this.formatAugmentedAssignExpr(node as FuncAstAugmentedAssignExpr); case "ternary_expr": return this.formatTernaryExpr(node as FuncAstTernaryExpr); case "binary_expr": @@ -120,200 +126,188 @@ export class FuncFormatter { case "hole_expr": return this.formatHoleExpr(node as FuncAstHoleExpr); case "primitive_type_expr": - return this.formatPrimitiveTypeExpr( - node as FuncAstPrimitiveTypeExpr, - ); + return this.formatPrimitiveTypeExpr(node as FuncAstPrimitiveTypeExpr); default: throw new Error(`Unsupported node: ${JSONbig.stringify(node, null, 2)}`); } } - private static formatModule(node: FuncAstModule): string { + private formatModule(node: FuncAstModule): string { return node.entries.map((entry) => this.dump(entry)).join("\n"); } - private static formatFunction(node: FuncAstFunction): string { + private formatFunction(node: FuncAstFunction): string { const attrs = node.attrs.join(" "); const name = node.name; - const params = node.params - .map((param) => `${this.dump(param.ty)} ${param.name}`) - .join(", "); + const params = node.params.map((param) => `${this.dump(param.ty)} ${param.name}`).join(", "); const returnType = this.dump(node.returnTy); - const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); return `${returnType} ${name}(${params}) ${attrs} {\n${body}\n}`; } - private static formatVarDefStmt(node: FuncAstVarDefStmt): string { + private formatVarDefStmt(node: FuncAstVarDefStmt): string { const type = node.ty ? `${this.dump(node.ty)} ` : ""; const init = node.init ? ` = ${this.dump(node.init)}` : ""; return `var ${node.name}: ${type}${init};`; } - private static formatReturnStmt(node: FuncAstReturnStmt): string { + private formatReturnStmt(node: FuncAstReturnStmt): string { const value = node.value ? ` ${this.dump(node.value)}` : ""; return `return${value};`; } - private static formatBlockStmt(node: FuncAstBlockStmt): string { - const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + private formatBlockStmt(node: FuncAstBlockStmt): string { + const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); return `{\n${body}\n}`; } - private static formatRepeatStmt(node: FuncAstRepeatStmt): string { + private formatRepeatStmt(node: FuncAstRepeatStmt): string { const condition = this.dump(node.condition); - const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); return `repeat ${condition} {\n${body}\n}`; } - private static formatConditionStmt(node: FuncAstConditionStmt): string { + private formatConditionStmt(node: FuncAstConditionStmt): string { const condition = node.condition ? this.dump(node.condition) : ""; const ifnot = node.ifnot ? "ifnot" : "if"; - const thenBlock = node.body.map((stmt) => this.dump(stmt)).join("\n"); - const elseBlock = node.else ? this.formatConditionStmt(node.else) : ""; - return `${ifnot} ${condition} {\n${thenBlock}\n}${elseBlock ? ` else {\n${elseBlock}\n}` : ""}`; + const bodyBlock = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); + const elseBlock = node.else ? ` else {\n${this.formatIndentedBlock(this.dump(node.else))}\n}` : ""; + return `${ifnot} ${condition} {\n${bodyBlock}\n}${elseBlock}`; } - private static formatDoUntilStmt(node: FuncAstDoUntilStmt): string { + private formatDoUntilStmt(node: FuncAstDoUntilStmt): string { const condition = this.dump(node.condition); - const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); return `do {\n${body}\n} until ${condition};`; } - private static formatWhileStmt(node: FuncAstWhileStmt): string { + private formatWhileStmt(node: FuncAstWhileStmt): string { const condition = this.dump(node.condition); - const body = node.body.map((stmt) => this.dump(stmt)).join("\n"); + const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); return `while ${condition} {\n${body}\n}`; } - private static formatExprStmt(node: FuncAstExprStmt): string { + private formatExprStmt(node: FuncAstExprStmt): string { return `${this.dump(node.expr)};`; } - private static formatTryCatchStmt(node: FuncAstTryCatchStmt): string { - const tryBlock = node.tryBlock - .map((stmt) => this.dump(stmt)) - .join("\n"); - const catchBlock = node.catchBlock - .map((stmt) => this.dump(stmt)) - .join("\n"); + private formatTryCatchStmt(node: FuncAstTryCatchStmt): string { + const tryBlock = this.formatIndentedBlock(node.tryBlock.map((stmt) => this.dump(stmt)).join("\n")); + const catchBlock = this.formatIndentedBlock(node.catchBlock.map((stmt) => this.dump(stmt)).join("\n")); const catchVar = node.catchVar ? ` (${node.catchVar})` : ""; return `try {\n${tryBlock}\n} catch${catchVar} {\n${catchBlock}\n}`; } - private static formatConstant(node: FuncAstConstant): string { + private formatConstant(node: FuncAstConstant): string { const type = this.dump(node.ty); const init = this.dump(node.init); return `const ${type} = ${init};`; } - private static formatGlobalVariable(node: FuncAstGlobalVariable): string { + private formatGlobalVariable(node: FuncAstGlobalVariable): string { const type = this.dump(node.ty); return `global ${type} ${node.name};`; } - private static formatCallExpr(node: FuncAstCallExpr): string { + private formatCallExpr(node: FuncAstCallExpr): string { const fun = this.dump(node.fun); const args = node.args.map((arg) => this.dump(arg)).join(", "); return `${fun}(${args})`; } - private static formatAssignExpr(node: FuncAstAssignExpr): string { + private formatAssignExpr(node: FuncAstAssignExpr): string { const lhs = this.dump(node.lhs); const rhs = this.dump(node.rhs); return `${lhs} = ${rhs}`; } - private static formatAugmentedAssignExpr( - node: FuncAstAugmentedAssignExpr, - ): string { + private formatAugmentedAssignExpr(node: FuncAstAugmentedAssignExpr): string { const lhs = this.dump(node.lhs); const rhs = this.dump(node.rhs); return `${lhs} ${node.op} ${rhs}`; } - private static formatTernaryExpr(node: FuncAstTernaryExpr): string { + private formatTernaryExpr(node: FuncAstTernaryExpr): string { const cond = this.dump(node.cond); const body = this.dump(node.trueExpr); const elseExpr = this.dump(node.falseExpr); return `${cond} ? ${body} : ${elseExpr}`; } - private static formatBinaryExpr(node: FuncAstBinaryExpr): string { + private formatBinaryExpr(node: FuncAstBinaryExpr): string { const lhs = this.dump(node.lhs); const rhs = this.dump(node.rhs); return `${lhs} ${node.op} ${rhs}`; } - private static formatUnaryExpr(node: FuncAstUnaryExpr): string { + private formatUnaryExpr(node: FuncAstUnaryExpr): string { const value = this.dump(node.value); return `${node.op}${value}`; } - private static formatNumberExpr(node: FuncAstNumberExpr): string { + private formatNumberExpr(node: FuncAstNumberExpr): string { return node.value.toString(); } - private static formatBoolExpr(node: FuncAstBoolExpr): string { + private formatBoolExpr(node: FuncAstBoolExpr): string { return node.value.toString(); } - private static formatStringExpr(node: FuncAstStringExpr): string { + private formatStringExpr(node: FuncAstStringExpr): string { return `"${node.value}"`; } - private static formatNilExpr(_: FuncAstNilExpr): string { + private formatNilExpr(_: FuncAstNilExpr): string { return "nil"; } - private static formatApplyExpr(node: FuncAstApplyExpr): string { + private formatApplyExpr(node: FuncAstApplyExpr): string { const lhs = this.dump(node.lhs); const rhs = this.dump(node.rhs); return `${lhs} ${rhs}`; } - private static formatTupleExpr(node: FuncAstTupleExpr): string { + private formatTupleExpr(node: FuncAstTupleExpr): string { const values = node.values.map((value) => this.dump(value)).join(", "); return `[${values}]`; } - private static formatTensorExpr(node: FuncAstTensorExpr): string { + private formatTensorExpr(node: FuncAstTensorExpr): string { const values = node.values.map((value) => this.dump(value)).join(", "); return `(${values})`; } - private static formatUnitExpr(_: FuncAstUnitExpr): string { + private formatUnitExpr(_: FuncAstUnitExpr): string { return "()"; } - private static formatHoleExpr(node: FuncAstHoleExpr): string { + private formatHoleExpr(node: FuncAstHoleExpr): string { const id = node.id ? node.id : "_"; const init = this.dump(node.init); return `${id} = ${init}`; } - private static formatPrimitiveTypeExpr( - node: FuncAstPrimitiveTypeExpr, - ): string { + private formatPrimitiveTypeExpr(node: FuncAstPrimitiveTypeExpr): string { return node.ty.kind; } - private static formatIdExpr(node: FuncAstIdExpr): string { + private formatIdExpr(node: FuncAstIdExpr): string { return node.value; } - private static formatInclude(node: FuncAstInclude): string { + private formatInclude(node: FuncAstInclude): string { return `#include ${node.kind}`; } - private static formatPragma(node: FuncAstPragma): string { + private formatPragma(node: FuncAstPragma): string { return `#pragma ${node.kind}`; } - private static formatComment(node: FuncAstComment): string { - return node.values.map((v) => `;; ${v}`).join('\n'); + private formatComment(node: FuncAstComment): string { + return node.values.map((v) => `;; ${v}`).join("\n"); } - private static formatType(node: FuncType): string { + private formatType(node: FuncType): string { switch (node.kind) { case "int": case "cell": @@ -329,4 +323,14 @@ export class FuncFormatter { throw new Error(`Unsupported type kind: ${JSONbig.stringify(node, null, 2)}`); } } + + private formatIndentedBlock(content: string): string { + this.currentIndent += this.indent; + const indentedContent = content + .split("\n") + .map(line => " ".repeat(this.currentIndent) + line) + .join("\n"); + this.currentIndent -= this.indent; + return indentedContent; + } } diff --git a/src/pipeline/compile.ts b/src/pipeline/compile.ts index fe61f35a8..772c8b5fa 100644 --- a/src/pipeline/compile.ts +++ b/src/pipeline/compile.ts @@ -34,7 +34,7 @@ export async function compile( contractName, abiName, ).writeProgram(); - const output = FuncFormatter.dump(funcContract); + const output = new FuncFormatter().dump(funcContract); throw new Error(`output:\n${output}`); // return { output, ctx }; } else { From bd067c1ce9f8366be7ab0f7a85b9fccb70e2e024 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 02:01:11 +0000 Subject: [PATCH 021/162] chore(formatter): Extra newlines --- src/func/formatter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index a5f49eeef..9abbab2cb 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -133,7 +133,7 @@ export class FuncFormatter { } private formatModule(node: FuncAstModule): string { - return node.entries.map((entry) => this.dump(entry)).join("\n"); + return node.entries.map((entry) => this.dump(entry)).join("\n\n"); } private formatFunction(node: FuncAstFunction): string { From 03f73281b2da770485fbe58deea7433360fc84f1 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 02:17:10 +0000 Subject: [PATCH 022/162] feat(codegen): Comments, pragmas, includes in the generated contract --- src/codegen/contract.ts | 22 ++++++++++++ src/func/formatter.ts | 78 +++++++++++++++++++++++++++++++---------- src/func/syntax.ts | 2 ++ src/func/syntaxUtils.ts | 15 ++++++++ 4 files changed, 98 insertions(+), 19 deletions(-) diff --git a/src/codegen/contract.ts b/src/codegen/contract.ts index 87ee95c00..b50a12d98 100644 --- a/src/codegen/contract.ts +++ b/src/codegen/contract.ts @@ -2,8 +2,14 @@ import { getAllTypes } from "../types/resolveDescriptors"; import { TypeDescription } from "../types/types"; import { getSortedTypes } from "../storage/resolveAllocation"; import { FuncAstModule, FuncAstComment } from "../func/syntax"; +import { makeComment, makePragma, makeInclude } from "../func/syntaxUtils"; import { FunctionGen, CodegenContext } from "."; +/** + * Func version used to compile the generated code. + */ +export const CODEGEN_FUNC_VERSION = "0.4.4"; + /** * Encapsulates generation of Func contracts from the Tact contract. */ @@ -22,6 +28,18 @@ export class ContractGen { return new ContractGen(ctx, contractName, abiName); } + private addPragmas(m: FuncAstModule): void { + m.entries.push(makePragma(`version =${CODEGEN_FUNC_VERSION}`)); + m.entries.push(makePragma("allow-post-modification")); + m.entries.push(makePragma("compute-asm-ltr")); + } + + private addIncludes(m: FuncAstModule): void { + m.entries.push(makeInclude(`${this.abiName}.headers.fc`)); + m.entries.push(makeInclude(`${this.abiName}.stdlib.fc`)); + m.entries.push(makeInclude(`${this.abiName}.storage.fc`)); + } + /** * Adds stdlib definitions to the generated module. */ @@ -60,6 +78,8 @@ export class ContractGen { * TODO: Why do we need function from *all* the contracts? */ private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { + m.entries.push(makeComment("", `Contract ${c.name} functions` ,"")); + // TODO: Generate init for (const tactFun of c.functions.values()) { const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( @@ -90,6 +110,8 @@ export class ContractGen { throw Error(`Contract "${this.contractName}" not found`); } + this.addPragmas(m); + this.addIncludes(m); this.addStdlib(m); this.addSerializers(m); this.addAccessors(m); diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 9abbab2cb..a675fbe6a 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -100,7 +100,9 @@ export class FuncFormatter { case "assign_expr": return this.formatAssignExpr(node as FuncAstAssignExpr); case "augmented_assign_expr": - return this.formatAugmentedAssignExpr(node as FuncAstAugmentedAssignExpr); + return this.formatAugmentedAssignExpr( + node as FuncAstAugmentedAssignExpr, + ); case "ternary_expr": return this.formatTernaryExpr(node as FuncAstTernaryExpr); case "binary_expr": @@ -126,22 +128,40 @@ export class FuncFormatter { case "hole_expr": return this.formatHoleExpr(node as FuncAstHoleExpr); case "primitive_type_expr": - return this.formatPrimitiveTypeExpr(node as FuncAstPrimitiveTypeExpr); + return this.formatPrimitiveTypeExpr( + node as FuncAstPrimitiveTypeExpr, + ); default: - throw new Error(`Unsupported node: ${JSONbig.stringify(node, null, 2)}`); + throw new Error( + `Unsupported node: ${JSONbig.stringify(node, null, 2)}`, + ); } } private formatModule(node: FuncAstModule): string { - return node.entries.map((entry) => this.dump(entry)).join("\n\n"); + return node.entries + .map((entry, index) => { + const previousEntry = node.entries[index - 1]; + const isSequentialPragmaOrInclude = + previousEntry && + previousEntry.kind === entry.kind && + (entry.kind === "include" || entry.kind === "pragma"); + const separator = isSequentialPragmaOrInclude ? "\n" : "\n\n"; + return (index > 0 ? separator : "") + this.dump(entry); + }) + .join(""); } private formatFunction(node: FuncAstFunction): string { const attrs = node.attrs.join(" "); const name = node.name; - const params = node.params.map((param) => `${this.dump(param.ty)} ${param.name}`).join(", "); + const params = node.params + .map((param) => `${this.dump(param.ty)} ${param.name}`) + .join(", "); const returnType = this.dump(node.returnTy); - const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); + const body = this.formatIndentedBlock( + node.body.map((stmt) => this.dump(stmt)).join("\n"), + ); return `${returnType} ${name}(${params}) ${attrs} {\n${body}\n}`; } @@ -157,33 +177,45 @@ export class FuncFormatter { } private formatBlockStmt(node: FuncAstBlockStmt): string { - const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); + const body = this.formatIndentedBlock( + node.body.map((stmt) => this.dump(stmt)).join("\n"), + ); return `{\n${body}\n}`; } private formatRepeatStmt(node: FuncAstRepeatStmt): string { const condition = this.dump(node.condition); - const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); + const body = this.formatIndentedBlock( + node.body.map((stmt) => this.dump(stmt)).join("\n"), + ); return `repeat ${condition} {\n${body}\n}`; } private formatConditionStmt(node: FuncAstConditionStmt): string { const condition = node.condition ? this.dump(node.condition) : ""; const ifnot = node.ifnot ? "ifnot" : "if"; - const bodyBlock = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); - const elseBlock = node.else ? ` else {\n${this.formatIndentedBlock(this.dump(node.else))}\n}` : ""; + const bodyBlock = this.formatIndentedBlock( + node.body.map((stmt) => this.dump(stmt)).join("\n"), + ); + const elseBlock = node.else + ? ` else {\n${this.formatIndentedBlock(this.dump(node.else))}\n}` + : ""; return `${ifnot} ${condition} {\n${bodyBlock}\n}${elseBlock}`; } private formatDoUntilStmt(node: FuncAstDoUntilStmt): string { const condition = this.dump(node.condition); - const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); + const body = this.formatIndentedBlock( + node.body.map((stmt) => this.dump(stmt)).join("\n"), + ); return `do {\n${body}\n} until ${condition};`; } private formatWhileStmt(node: FuncAstWhileStmt): string { const condition = this.dump(node.condition); - const body = this.formatIndentedBlock(node.body.map((stmt) => this.dump(stmt)).join("\n")); + const body = this.formatIndentedBlock( + node.body.map((stmt) => this.dump(stmt)).join("\n"), + ); return `while ${condition} {\n${body}\n}`; } @@ -192,8 +224,12 @@ export class FuncFormatter { } private formatTryCatchStmt(node: FuncAstTryCatchStmt): string { - const tryBlock = this.formatIndentedBlock(node.tryBlock.map((stmt) => this.dump(stmt)).join("\n")); - const catchBlock = this.formatIndentedBlock(node.catchBlock.map((stmt) => this.dump(stmt)).join("\n")); + const tryBlock = this.formatIndentedBlock( + node.tryBlock.map((stmt) => this.dump(stmt)).join("\n"), + ); + const catchBlock = this.formatIndentedBlock( + node.catchBlock.map((stmt) => this.dump(stmt)).join("\n"), + ); const catchVar = node.catchVar ? ` (${node.catchVar})` : ""; return `try {\n${tryBlock}\n} catch${catchVar} {\n${catchBlock}\n}`; } @@ -221,7 +257,9 @@ export class FuncFormatter { return `${lhs} = ${rhs}`; } - private formatAugmentedAssignExpr(node: FuncAstAugmentedAssignExpr): string { + private formatAugmentedAssignExpr( + node: FuncAstAugmentedAssignExpr, + ): string { const lhs = this.dump(node.lhs); const rhs = this.dump(node.rhs); return `${lhs} ${node.op} ${rhs}`; @@ -296,11 +334,11 @@ export class FuncFormatter { } private formatInclude(node: FuncAstInclude): string { - return `#include ${node.kind}`; + return `#include "${node.value}"`; } private formatPragma(node: FuncAstPragma): string { - return `#pragma ${node.kind}`; + return `#pragma ${node.value}`; } private formatComment(node: FuncAstComment): string { @@ -320,7 +358,9 @@ export class FuncFormatter { case "tensor": return `(${node.value.map((t) => this.formatType(t)).join(", ")})`; default: - throw new Error(`Unsupported type kind: ${JSONbig.stringify(node, null, 2)}`); + throw new Error( + `Unsupported type kind: ${JSONbig.stringify(node, null, 2)}`, + ); } } @@ -328,7 +368,7 @@ export class FuncFormatter { this.currentIndent += this.indent; const indentedContent = content .split("\n") - .map(line => " ".repeat(this.currentIndent) + line) + .map((line) => " ".repeat(this.currentIndent) + line) .join("\n"); this.currentIndent -= this.indent; return indentedContent; diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 3ab124754..65c782f4f 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -281,10 +281,12 @@ export type FuncAstComment = { export type FuncAstInclude = { kind: "include"; + value: string, }; export type FuncAstPragma = { kind: "pragma"; + value: string, }; export type FuncAstGlobalVariable = { diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index 1b168ca21..1281dfb9d 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -1,8 +1,11 @@ import { FuncAstExpr, FuncAstIdExpr, + FuncAstPragma, + FuncAstInclude, FuncAstFunctionAttribute, FuncAstFormalFunctionParam, + FuncAstComment, FuncAstFunction, FuncType, FuncAstCallExpr, @@ -61,3 +64,15 @@ export function makeFunction( }); return { kind: "function", attrs, name, params, returnTy, body }; } + +export function makeComment(...values: string[]): FuncAstComment { + return { kind: "comment", values }; +} + +export function makePragma(value: string): FuncAstPragma { + return { kind: "pragma", value }; +} + +export function makeInclude(value: string): FuncAstInclude { + return { kind: "include", value }; +} From 583bec22229eff5f6f5deebc7e2f1f32f99e25bb Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 02:19:42 +0000 Subject: [PATCH 023/162] fix(formatter): VarDef w/ local type inference --- src/func/formatter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index a675fbe6a..3524c8397 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -166,9 +166,9 @@ export class FuncFormatter { } private formatVarDefStmt(node: FuncAstVarDefStmt): string { - const type = node.ty ? `${this.dump(node.ty)} ` : ""; + const type = node.ty ? `: ${this.dump(node.ty)} ` : ""; const init = node.init ? ` = ${this.dump(node.init)}` : ""; - return `var ${node.name}: ${type}${init};`; + return `var ${node.name}${type}${init};`; } private formatReturnStmt(node: FuncAstReturnStmt): string { From ca0b09460e20ca22b71817375d43303f1766ebf6 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 02:32:57 +0000 Subject: [PATCH 024/162] fix(codegen): tuples=>tensors as return values of functions --- src/codegen/contract.ts | 1 + src/codegen/function.ts | 10 ++-------- src/codegen/statement.ts | 16 +++++++++------- src/func/syntaxUtils.ts | 5 +++++ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/codegen/contract.ts b/src/codegen/contract.ts index b50a12d98..77e432ed5 100644 --- a/src/codegen/contract.ts +++ b/src/codegen/contract.ts @@ -81,6 +81,7 @@ export class ContractGen { m.entries.push(makeComment("", `Contract ${c.name} functions` ,"")); // TODO: Generate init + for (const tactFun of c.functions.values()) { const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( tactFun, diff --git a/src/codegen/function.ts b/src/codegen/function.ts index d080d1984..67706233e 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -146,10 +146,7 @@ export class FunctionGen { self, funcIdOf("self"), ); - const init: FuncAstExpr = { - kind: "id_expr", - value: funcIdOf("self"), - }; + const init: FuncAstExpr = makeId(funcIdOf("self")); body.push({ kind: "var_def_stmt", name: varName, @@ -166,10 +163,7 @@ export class FunctionGen { resolveTypeRef(this.ctx.ctx, a.type), funcIdOf(a.name), ); - const init: FuncAstExpr = { - kind: "id_expr", - value: funcIdOf(a.name), - }; + const init: FuncAstExpr = makeId(funcIdOf(a.name)); body.push({ kind: "var_def_stmt", name, init, ty: undefined }); } } diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index 5230620cc..dbd794936 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -19,7 +19,14 @@ import { FuncAstTupleExpr, FuncAstUnitExpr, } from "../func/syntax"; -import { makeId, makeExprStmt, makeReturn } from "../func/syntaxUtils"; +import { + makeId, + makeExprStmt, + makeReturn, + makeTensorExpr, +} from "../func/syntaxUtils"; + +import JSONbig from "json-bigint"; /** * Encapsulates generation of Func statements from the Tact statement. @@ -98,12 +105,7 @@ export class StatementGen { ? makeId(this.selfName) : undefined; const getValue = (expr: FuncAstExpr): FuncAstExpr => - this.selfName - ? ({ - kind: "tuple_expr", - values: [selfVar!, expr], - } as FuncAstTupleExpr) - : expr; + this.selfName ? makeTensorExpr(selfVar!, expr) : expr; if (this.tactStmt.expression) { const castedReturns = this.makeCastedExpr( this.tactStmt.expression, diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index 1281dfb9d..8af67792e 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -2,6 +2,7 @@ import { FuncAstExpr, FuncAstIdExpr, FuncAstPragma, + FuncAstTensorExpr, FuncAstInclude, FuncAstFunctionAttribute, FuncAstFormalFunctionParam, @@ -76,3 +77,7 @@ export function makePragma(value: string): FuncAstPragma { export function makeInclude(value: string): FuncAstInclude { return { kind: "include", value }; } + +export function makeTensorExpr(...values: FuncAstExpr[]): FuncAstTensorExpr { + return { kind: "tensor_expr", values }; +} From 515e89e7d206b51dc65ec9de4ad08fa5b79291bf Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 02:43:03 +0000 Subject: [PATCH 025/162] feat(codegen): contract=>module; draft main contract generation logic --- src/codegen/contract.ts | 128 -------------------- src/codegen/index.ts | 2 +- src/codegen/module.ts | 252 ++++++++++++++++++++++++++++++++++++++++ src/pipeline/compile.ts | 4 +- 4 files changed, 255 insertions(+), 131 deletions(-) delete mode 100644 src/codegen/contract.ts create mode 100644 src/codegen/module.ts diff --git a/src/codegen/contract.ts b/src/codegen/contract.ts deleted file mode 100644 index 77e432ed5..000000000 --- a/src/codegen/contract.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { getAllTypes } from "../types/resolveDescriptors"; -import { TypeDescription } from "../types/types"; -import { getSortedTypes } from "../storage/resolveAllocation"; -import { FuncAstModule, FuncAstComment } from "../func/syntax"; -import { makeComment, makePragma, makeInclude } from "../func/syntaxUtils"; -import { FunctionGen, CodegenContext } from "."; - -/** - * Func version used to compile the generated code. - */ -export const CODEGEN_FUNC_VERSION = "0.4.4"; - -/** - * Encapsulates generation of Func contracts from the Tact contract. - */ -export class ContractGen { - private constructor( - private ctx: CodegenContext, - private contractName: string, - private abiName: string, - ) {} - - static fromTact( - ctx: CodegenContext, - contractName: string, - abiName: string, - ): ContractGen { - return new ContractGen(ctx, contractName, abiName); - } - - private addPragmas(m: FuncAstModule): void { - m.entries.push(makePragma(`version =${CODEGEN_FUNC_VERSION}`)); - m.entries.push(makePragma("allow-post-modification")); - m.entries.push(makePragma("compute-asm-ltr")); - } - - private addIncludes(m: FuncAstModule): void { - m.entries.push(makeInclude(`${this.abiName}.headers.fc`)); - m.entries.push(makeInclude(`${this.abiName}.stdlib.fc`)); - m.entries.push(makeInclude(`${this.abiName}.storage.fc`)); - } - - /** - * Adds stdlib definitions to the generated module. - */ - private addStdlib(m: FuncAstModule): void { - // TODO - } - - private addSerializers(m: FuncAstModule): void { - const sortedTypes = getSortedTypes(this.ctx.ctx); - for (const t of sortedTypes) { - } - } - - private addAccessors(m: FuncAstModule): void { - // TODO - } - - private addInitSerializer(m: FuncAstModule): void { - // TODO - } - - private addStorageFunctions(m: FuncAstModule): void { - // TODO - } - - private addStaticFunctions(m: FuncAstModule): void { - // TODO - } - - private addExtensions(m: FuncAstModule): void { - // TODO - } - - /** - * Adds functions defined within the Tact contract to the generated Func module. - * TODO: Why do we need function from *all* the contracts? - */ - private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { - m.entries.push(makeComment("", `Contract ${c.name} functions` ,"")); - - // TODO: Generate init - - for (const tactFun of c.functions.values()) { - const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( - tactFun, - ); - m.entries.push(funcFun); - } - } - - private addMain(m: FuncAstModule): void { - // TODO - } - - /** - * Adds a comment entry to the module. - */ - private addComment(m: FuncAstModule, c: FuncAstComment): void { - m.entries.push(c); - } - - public writeProgram(): FuncAstModule { - const m: FuncAstModule = { kind: "module", entries: [] }; - - const allTypes = Object.values(getAllTypes(this.ctx.ctx)); - const contracts = allTypes.filter((v) => v.kind === "contract"); - const contract = contracts.find((v) => v.name === this.contractName); - if (contract === undefined) { - throw Error(`Contract "${this.contractName}" not found`); - } - - this.addPragmas(m); - this.addIncludes(m); - this.addStdlib(m); - this.addSerializers(m); - this.addAccessors(m); - this.addInitSerializer(m); - this.addStorageFunctions(m); - this.addStaticFunctions(m); - this.addExtensions(m); - contracts.forEach((c) => this.addContractFunctions(m, c)); - this.addMain(m); - - return m; - } -} diff --git a/src/codegen/index.ts b/src/codegen/index.ts index 48ab5d4fd..bb9f85773 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -1,5 +1,5 @@ export { CodegenContext } from "./context"; -export { ContractGen } from "./contract"; +export { ModuleGen } from "./module"; export { FunctionGen } from "./function"; export { StatementGen } from "./statement"; export { ExpressionGen, writePathExpression } from "./expression"; diff --git a/src/codegen/module.ts b/src/codegen/module.ts new file mode 100644 index 000000000..4d2f3167e --- /dev/null +++ b/src/codegen/module.ts @@ -0,0 +1,252 @@ +import { getAllTypes } from "../types/resolveDescriptors"; +import { TypeDescription } from "../types/types"; +import { getSortedTypes } from "../storage/resolveAllocation"; +import { FuncAstModule, FuncAstComment } from "../func/syntax"; +import { makeComment, makePragma, makeInclude } from "../func/syntaxUtils"; +import { FunctionGen, CodegenContext } from "."; + +/** + * Func version used to compile the generated code. + */ +export const CODEGEN_FUNC_VERSION = "0.4.4"; + +/** + * Encapsulates generation of Func compilation module from the Tact module. + */ +export class ModuleGen { + private constructor( + private ctx: CodegenContext, + private contractName: string, + private abiName: string, + ) {} + + static fromTact( + ctx: CodegenContext, + contractName: string, + abiName: string, + ): ModuleGen { + return new ModuleGen(ctx, contractName, abiName); + } + + private addPragmas(m: FuncAstModule): void { + m.entries.push(makePragma(`version =${CODEGEN_FUNC_VERSION}`)); + m.entries.push(makePragma("allow-post-modification")); + m.entries.push(makePragma("compute-asm-ltr")); + } + + private addIncludes(m: FuncAstModule): void { + m.entries.push(makeInclude(`${this.abiName}.headers.fc`)); + m.entries.push(makeInclude(`${this.abiName}.stdlib.fc`)); + m.entries.push(makeInclude(`${this.abiName}.storage.fc`)); + } + + /** + * Adds stdlib definitions to the generated module. + */ + private addStdlib(m: FuncAstModule): void { + // TODO + } + + private addSerializers(m: FuncAstModule): void { + const sortedTypes = getSortedTypes(this.ctx.ctx); + for (const t of sortedTypes) { + } + } + + private addAccessors(m: FuncAstModule): void { + // TODO + } + + private addInitSerializer(m: FuncAstModule): void { + // TODO + } + + private addStorageFunctions(m: FuncAstModule): void { + // TODO + } + + private addStaticFunctions(m: FuncAstModule): void { + // TODO + } + + private addExtensions(m: FuncAstModule): void { + // TODO + } + + /** + * Adds functions defined within the Tact contract to the generated Func module. + * TODO: Why do we need function from *all* the contracts? + */ + private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { + m.entries.push(makeComment("", `Contract ${c.name} functions`, "")); + + // TODO: Generate init + + for (const tactFun of c.functions.values()) { + const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( + tactFun, + ); + m.entries.push(funcFun); + } + } + + /** + * Adds entries from the main Tact contract. + */ + private addMainContract(m: FuncAstModule, c: TypeDescription): void { + // XXX see: writeMainContract + m.entries.push( + makeComment("", `Receivers of a Contract ${c.name}`, ""), + ); + + // // Write receivers + // for (const r of Object.values(c.receivers)) { + // this.writeReceiver(type, r, ctx); + // } + + m.entries.push( + makeComment("", `Get methods of a Contract ${c.name}`, ""), + ); + + // // Getters + // for (const f of type.functions.values()) { + // if (f.isGetter) { + // writeGetter(f, ctx); + // } + // } + + // // Interfaces + // writeInterfaces(type, ctx); + + // // ABI + // ctx.append(`_ get_abi_ipfs() method_id {`); + // ctx.inIndent(() => { + // ctx.append(`return "${abiLink}";`); + // }); + // ctx.append(`}`); + // ctx.append(); + + // // Deployed + // ctx.append(`_ lazy_deployment_completed() method_id {`); + // ctx.inIndent(() => { + // ctx.append(`return get_data().begin_parse().load_int(1);`); + // }); + // ctx.append(`}`); + // ctx.append(); + + // Comments + m.entries.push(makeComment("", `Routing of a Contract ${c.name}`, "")); + + // // Render body + // const hasExternal = type.receivers.find((v) => + // v.selector.kind.startsWith("external-"), + // ); + // writeRouter(type, "internal", ctx); + // if (hasExternal) { + // writeRouter(type, "external", ctx); + // } + + // // Render internal receiver + // ctx.append( + // `() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure {`, + // ); + // ctx.inIndent(() => { + // // Load context + // ctx.append(); + // ctx.append(`;; Context`); + // ctx.append(`var cs = in_msg_cell.begin_parse();`); + // ctx.append(`var msg_flags = cs~load_uint(4);`); // int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + // ctx.append(`var msg_bounced = -(msg_flags & 1);`); + // ctx.append( + // `slice msg_sender_addr = ${ctx.used("__tact_verify_address")}(cs~load_msg_addr());`, + // ); + // ctx.append( + // `__tact_context = (msg_bounced, msg_sender_addr, msg_value, cs);`, + // ); + // ctx.append(`__tact_context_sender = msg_sender_addr;`); + // ctx.append(); + // + // // Load self + // ctx.append(`;; Load contract data`); + // ctx.append(`var self = ${ops.contractLoad(type.name, ctx)}();`); + // ctx.append(); + // + // // Process operation + // ctx.append(`;; Handle operation`); + // ctx.append( + // `int handled = self~${ops.contractRouter(type.name, "internal")}(msg_bounced, in_msg);`, + // ); + // ctx.append(); + // + // // Throw if not handled + // ctx.append(`;; Throw if not handled`); + // ctx.append( + // `throw_unless(${contractErrors.invalidMessage.id}, handled);`, + // ); + // ctx.append(); + // + // // Persist state + // ctx.append(`;; Persist state`); + // ctx.append(`${ops.contractStore(type.name, ctx)}(self);`); + // }); + // ctx.append("}"); + // ctx.append(); + // + // // Render external receiver + // if (hasExternal) { + // ctx.append(`() recv_external(slice in_msg) impure {`); + // ctx.inIndent(() => { + // // Load self + // ctx.append(`;; Load contract data`); + // ctx.append(`var self = ${ops.contractLoad(type.name, ctx)}();`); + // ctx.append(); + // + // // Process operation + // ctx.append(`;; Handle operation`); + // ctx.append( + // `int handled = self~${ops.contractRouter(type.name, "external")}(in_msg);`, + // ); + // ctx.append(); + // + // // Throw if not handled + // ctx.append(`;; Throw if not handled`); + // ctx.append( + // `throw_unless(handled, ${contractErrors.invalidMessage.id});`, + // ); + // ctx.append(); + // + // // Persist state + // ctx.append(`;; Persist state`); + // ctx.append(`${ops.contractStore(type.name, ctx)}(self);`); + // }); + // ctx.append("}"); + // ctx.append(); + // } + // }); + } + + public writeProgram(): FuncAstModule { + const m: FuncAstModule = { kind: "module", entries: [] }; + + const allTypes = Object.values(getAllTypes(this.ctx.ctx)); + const contracts = allTypes.filter((v) => v.kind === "contract"); + const contract = contracts.find((v) => v.name === this.contractName); + if (contract === undefined) { + throw Error(`Contract "${this.contractName}" not found`); + } + + this.addPragmas(m); + this.addIncludes(m); + this.addStdlib(m); + this.addSerializers(m); + this.addAccessors(m); + this.addInitSerializer(m); + this.addStorageFunctions(m); + this.addStaticFunctions(m); + this.addExtensions(m); + contracts.forEach((c) => this.addContractFunctions(m, c)); + this.addMainContract(m, contract); + + return m; + } +} diff --git a/src/pipeline/compile.ts b/src/pipeline/compile.ts index 772c8b5fa..0de6994bc 100644 --- a/src/pipeline/compile.ts +++ b/src/pipeline/compile.ts @@ -1,7 +1,7 @@ import { CompilerContext } from "../context"; import { createABI } from "../generator/createABI"; import { writeProgram } from "../generator/writeProgram"; -import { ContractGen, CodegenContext } from "../codegen"; +import { ModuleGen, CodegenContext } from "../codegen"; import { FuncFormatter } from "../func/formatter"; export type CompilationOutput = { @@ -29,7 +29,7 @@ export async function compile( const abi = createABI(ctx, contractName); if (process.env.NEW_CODEGEN === "1") { const codegenCtx = new CodegenContext(ctx); - const funcContract = ContractGen.fromTact( + const funcContract = ModuleGen.fromTact( codegenCtx, contractName, abiName, From 063e2e3d9dd1ed417cdbb15e4d9fb16d12627bd4 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 14 Jul 2024 07:03:21 +0000 Subject: [PATCH 026/162] feat(codegen): Support `init_of` and ternary expressions --- src/codegen/expression.ts | 47 +++++++++++++++++++++++++-------------- src/func/syntaxUtils.ts | 9 ++++++++ 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 59607f907..6261941a6 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -29,7 +29,12 @@ import { FuncAstIdExpr, FuncAstTernaryExpr, } from "../func/syntax"; -import { makeId, makeCall, makeBinop } from "../func/syntaxUtils"; +import { + makeId, + makeCall, + makeBinop, + makeTernaryExpr, +} from "../func/syntaxUtils"; function isNull(f: AstExpression): boolean { return f.kind === "null"; @@ -76,7 +81,7 @@ export class ExpressionGen { return new ExpressionGen(ctx, tactExpr); } - /*** + /** * Generates FunC literals from Tact ones. */ static writeValue(ctx: CodegenContext, val: Value): FuncAstExpr { @@ -139,7 +144,7 @@ export class ExpressionGen { // literals and constant expressions are covered here try { const value = evalConstantExpression(this.tactExpr, this.ctx.ctx); - return ExpressionGen.writeValue(this.ctx,value); + return ExpressionGen.writeValue(this.ctx, value); } catch (error) { if (!(error instanceof TactConstEvalError) || error.fatal) throw error; @@ -732,23 +737,31 @@ export class ExpressionGen { } // - // // - // // Init of - // // + // Init of // - // if (f.kind === "init_of") { - // const type = getType(wCtx.ctx, f.contract); - // return `${ops.contractInitChild(idText(f.contract), wCtx)}(${["__tact_context_sys", ...f.args.map((a, i) => writeCastedExpression(a, type.init!.params[i]!.type, wCtx))].join(", ")})`; - // } - // - // // - // // Ternary operator - // // + if (this.tactExpr.kind === "init_of") { + const type = getType(this.ctx.ctx, this.tactExpr.contract); + return makeCall( + ops.contractInitChild(idText(this.tactExpr.contract)), + [ + makeId("__tact_context_sys"), + ...this.tactExpr.args.map((a, i) => + this.makeCastedExpr(a, type.init!.params[i]!.type), + ), + ], + ); + } + // - // if (f.kind === "conditional") { - // return `(${writeExpression(f.condition, wCtx)} ? ${writeExpression(f.thenBranch, wCtx)} : ${writeExpression(f.elseBranch, wCtx)})`; - // } + // Ternary operator // + if (this.tactExpr.kind === "conditional") { + return makeTernaryExpr( + this.makeExpr(this.tactExpr.condition), + this.makeExpr(this.tactExpr.thenBranch), + this.makeExpr(this.tactExpr.elseBranch), + ); + } // // Unreachable diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index 8af67792e..e5782f196 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -1,6 +1,7 @@ import { FuncAstExpr, FuncAstIdExpr, + FuncAstTernaryExpr, FuncAstPragma, FuncAstTensorExpr, FuncAstInclude, @@ -81,3 +82,11 @@ export function makeInclude(value: string): FuncAstInclude { export function makeTensorExpr(...values: FuncAstExpr[]): FuncAstTensorExpr { return { kind: "tensor_expr", values }; } + +export function makeTernaryExpr( + cond: FuncAstExpr, + trueExpr: FuncAstExpr, + falseExpr: FuncAstExpr, +): FuncAstTernaryExpr { + return { kind: "ternary_expr", cond, trueExpr, falseExpr }; +} From 75bcb7006f83d6e3b65f427a165c4b37198cc8fa Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Mon, 15 Jul 2024 02:05:58 +0000 Subject: [PATCH 027/162] feat(syntax): Function definition/declaration --- src/func/formatter.ts | 52 ++++++++++++++++++++++++++++++++++------- src/func/syntax.ts | 17 ++++++++++---- src/func/syntaxUtils.ts | 19 ++++++++++++--- 3 files changed, 72 insertions(+), 16 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 3524c8397..42d9f874a 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -1,5 +1,7 @@ import { FuncAstNode, + FuncAstFormalFunctionParam, + FuncAstFunctionAttribute, FuncType, FuncAstIdExpr, FuncAstAssignExpr, @@ -7,7 +9,8 @@ import { FuncAstComment, FuncAstInclude, FuncAstModule, - FuncAstFunction, + FuncAstFunctionDefinition, + FuncAstFunctionDeclaration, FuncAstVarDefStmt, FuncAstReturnStmt, FuncAstBlockStmt, @@ -71,8 +74,14 @@ export class FuncFormatter { return this.formatType(node as FuncType); case "module": return this.formatModule(node as FuncAstModule); - case "function": - return this.formatFunction(node as FuncAstFunction); + case "function_declaration": + return this.formatFunctionDeclaration( + node as FuncAstFunctionDeclaration, + ); + case "function_definition": + return this.formatFunctionDefinition( + node as FuncAstFunctionDefinition, + ); case "var_def_stmt": return this.formatVarDefStmt(node as FuncAstVarDefStmt); case "return_stmt": @@ -152,17 +161,42 @@ export class FuncFormatter { .join(""); } - private formatFunction(node: FuncAstFunction): string { - const attrs = node.attrs.join(" "); - const name = node.name; - const params = node.params + private formatFunctionSignature( + name: string, + attrs: FuncAstFunctionAttribute[], + params: FuncAstFormalFunctionParam[], + returnTy: FuncType, + ): string { + const attrsStr = attrs.join(" "); + const nameStr = name; + const paramsStr = params .map((param) => `${this.dump(param.ty)} ${param.name}`) .join(", "); - const returnType = this.dump(node.returnTy); + const returnTypeStr = this.dump(returnTy); + return `${returnTypeStr} ${nameStr}(${paramsStr}) ${attrsStr}`; + } + + private formatFunctionDeclaration(node: FuncAstFunctionDefinition): string { + const signature = this.formatFunctionSignature( + node.name, + node.attrs, + node.params, + node.returnTy, + ); + return `${signature};`; + } + + private formatFunctionDefinition(node: FuncAstFunctionDefinition): string { + const signature = this.formatFunctionSignature( + node.name, + node.attrs, + node.params, + node.returnTy, + ); const body = this.formatIndentedBlock( node.body.map((stmt) => this.dump(stmt)).join("\n"), ); - return `${returnType} ${name}(${params}) ${attrs} {\n${body}\n}`; + return `${signature} {\n${body}\n}`; } private formatVarDefStmt(node: FuncAstVarDefStmt): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 65c782f4f..feb8bfc93 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -257,7 +257,7 @@ export type FuncAstTryCatchStmt = { catchVar: string | null; }; -export type FuncAstFunctionAttribute = "impure" | "inline"; +export type FuncAstFunctionAttribute = "impure" | "inline" | "inline_ref"; export type FuncAstFormalFunctionParam = { kind: "function_param"; @@ -265,8 +265,16 @@ export type FuncAstFormalFunctionParam = { ty: FuncType; }; -export type FuncAstFunction = { - kind: "function"; +export type FuncAstFunctionDeclaration = { + kind: "function_declaration"; + name: string, + attrs: FuncAstFunctionAttribute[]; + params: FuncAstFormalFunctionParam[]; + returnTy: FuncType; +}; + +export type FuncAstFunctionDefinition = { + kind: "function_definition"; name: string, attrs: FuncAstFunctionAttribute[]; params: FuncAstFormalFunctionParam[]; @@ -298,7 +306,8 @@ export type FuncAstGlobalVariable = { export type FuncAstModuleEntry = | FuncAstInclude | FuncAstPragma - | FuncAstFunction + | FuncAstFunctionDefinition + | FuncAstFunctionDeclaration | FuncAstComment | FuncAstConstant | FuncAstGlobalVariable; diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index e5782f196..2641a8279 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -8,7 +8,8 @@ import { FuncAstFunctionAttribute, FuncAstFormalFunctionParam, FuncAstComment, - FuncAstFunction, + FuncAstFunctionDefinition, + FuncAstFunctionDeclaration, FuncType, FuncAstCallExpr, FuncAstBinaryOp, @@ -56,7 +57,7 @@ export function makeFunction( paramValues: [string, FuncType][], returnTy: FuncType, body: FuncAstStmt[], -): FuncAstFunction { +): FuncAstFunctionDefinition { const params = paramValues.map(([name, ty]) => { return { kind: "function_param", @@ -64,7 +65,19 @@ export function makeFunction( ty, } as FuncAstFormalFunctionParam; }); - return { kind: "function", attrs, name, params, returnTy, body }; + return { kind: "function_definition", attrs, name, params, returnTy, body }; +} + +export function declarationFromDefinition( + def: FuncAstFunctionDefinition, +): FuncAstFunctionDeclaration { + return { + kind: "function_declaration", + attrs: def.attrs, + name: def.name, + params: def.params, + returnTy: def.returnTy, + }; } export function makeComment(...values: string[]): FuncAstComment { From cd22057ee386194bdfbf7fe40a0f0be4999fcc10 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Mon, 15 Jul 2024 10:38:53 +0000 Subject: [PATCH 028/162] feat(codegen): Support multi-file generation --- src/codegen/context.ts | 15 +- src/codegen/function.ts | 9 +- src/codegen/generator.ts | 355 +++++++++++++++++++++++++++++++++++++++ src/codegen/index.ts | 1 + src/codegen/module.ts | 35 +--- src/func/formatter.ts | 2 +- src/func/syntax.ts | 3 + src/func/syntaxUtils.ts | 6 + src/pipeline/compile.ts | 24 ++- 9 files changed, 398 insertions(+), 52 deletions(-) create mode 100644 src/codegen/generator.ts diff --git a/src/codegen/context.ts b/src/codegen/context.ts index bf357659d..e3d87298b 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -1,8 +1,8 @@ import { CompilerContext } from "../context"; -import { FuncAstFunction } from "../func/syntax"; +import { FuncAstFunctionDefinition } from "../func/syntax"; type ContextValues = { - constructor: FuncAstFunction; + constructor: FuncAstFunctionDefinition; }; export type ContextValueKind = keyof ContextValues; @@ -15,7 +15,7 @@ export class CodegenContext { public ctx: CompilerContext; /** Generated struct constructors. */ - private constructors: FuncAstFunction[] = []; + private constructors: FuncAstFunctionDefinition[] = []; constructor(ctx: CompilerContext) { this.ctx = ctx; @@ -27,8 +27,15 @@ export class CodegenContext { ): void { switch (kind) { case "constructor": - this.constructors.push(value as FuncAstFunction); + this.constructors.push(value as FuncAstFunctionDefinition); break; } } + + /** + * Returns all the generated functions. + */ + public getFunctions(): FuncAstFunctionDefinition[] { + return this.constructors; + } } diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 67706233e..43e00f7a9 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -1,10 +1,9 @@ import { enabledInline } from "../config/features"; import { getType, resolveTypeRef } from "../types/resolveDescriptors"; import { ops, funcIdOf } from "./util"; -import { AstId } from "../grammar/ast"; -import { TypeDescription, FunctionDescription, TypeRef } from "../types/types"; +import { TypeDescription, FunctionDescription, InitDescription, TypeRef } from "../types/types"; import { - FuncAstFunction, + FuncAstFunctionDefinition, FuncAstStmt, FuncAstFunctionAttribute, FuncAstExpr, @@ -90,7 +89,7 @@ export class FunctionGen { /** * Generates Func function from the Tact funciton description. */ - public writeFunction(tactFun: FunctionDescription): FuncAstFunction { + public writeFunction(tactFun: FunctionDescription): FuncAstFunctionDefinition { if (tactFun.ast.kind !== "function_def") { throw new Error(`Unknown function kind: ${tactFun.ast.kind}`); } @@ -200,7 +199,7 @@ export class FunctionGen { public writeStructConstructor( type: TypeDescription, args: string[], - ): FuncAstFunction { + ): FuncAstFunctionDefinition { const attrs: FuncAstFunctionAttribute[] = ["inline"]; const name = ops.typeConstructor( type.name, diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts new file mode 100644 index 000000000..aef89d6be --- /dev/null +++ b/src/codegen/generator.ts @@ -0,0 +1,355 @@ +import { CompilationOutput } from "../pipeline/compile"; +import { CompilerContext } from "../context"; +import { CodegenContext, ModuleGen } from "."; +import { topologicalSort } from "../utils/utils"; +import { ContractABI } from "@ton/core"; +import { FuncFormatter } from "../func/formatter"; +import { FuncAstModule, FuncAstFunctionDefinition } from "../func/syntax"; +import { + makeComment, + makeModule, + makePragma, + makeInclude, + declarationFromDefinition, +} from "../func/syntaxUtils"; +import { calculateIPFSlink } from "../utils/calculateIPFSlink"; + +export type GeneratedFilesInfo = { + files: { name: string; code: string }[]; + imported: string[]; +}; + +/** + * Func version used to compile the generated code. + */ +export const CODEGEN_FUNC_VERSION = "0.4.4"; + +/** + * Generates Func files that correspond to the input Tact project. + */ +export class FuncGenerator { + private tactCtx: CompilerContext; + /** An ABI structure of the project generated by the Tact compiler. */ + private abiSrc: ContractABI; + /** Basename used e.g. to name the generated Func files. */ + private basename: string; + private funcCtx: CodegenContext; + + private constructor( + tactCtx: CompilerContext, + abiSrc: ContractABI, + basename: string, + ) { + this.tactCtx = tactCtx; + this.abiSrc = abiSrc; + this.basename = basename; + this.funcCtx = new CodegenContext(tactCtx); + } + + static fromTactProject( + tactCtx: CompilerContext, + abiSrc: ContractABI, + basename: string, + ): FuncGenerator { + return new FuncGenerator(tactCtx, abiSrc, basename); + } + + /** + * Translates the whole Tact project to Func. + * @returns Information about generated Func files and their code. + */ + public async writeProgram(): Promise { + const abi = JSON.stringify(this.abiSrc); + const abiLink = await calculateIPFSlink(Buffer.from(abi)); + + const generated: GeneratedFilesInfo = { files: [], imported: [] }; + const mainContract = this.generateMainContract( + this.abiSrc.name!, + abiLink, + ); + const functions = this.extractFunctions(mainContract); + this.generateHeaders(generated, functions); + this.generateStdlib(generated, functions); + this.generateNative(generated); + this.generateConstants(generated, functions); + this.generateStorage(generated, functions); + + // TODO: Everything must be already included to the main contract; otherwise we should add entries from the context + // + // const remainingFunctions = tryExtractModule(functions, null, imported); + // const header: string[] = []; + // header.push("#pragma version =0.4.4;"); + // header.push("#pragma allow-post-modification;"); + // header.push("#pragma compute-asm-ltr;"); + // header.push(""); + // for (const i of files.map((v) => `#include "${v.name}";`)) { + // header.push(i); + + // Finalize and dump the main contract, as we have just obtained the structure of the project + mainContract.entries.unshift( + ...generated.files.map((f) => makeInclude(f.name)), + ); + mainContract.entries.unshift( + ...[ + `version =${CODEGEN_FUNC_VERSION}`, + "allow-post-modification", + "compute-asm-ltr", + ].map(makePragma), + ); + generated.files.push({ + name: `${this.basename}.code.fc`, + code: new FuncFormatter().dump(mainContract), + }); + + // header.push(""); + // header.push(";;"); + // header.push(`;; Contract ${abiSrc.name} functions`); + // header.push(";;"); + // header.push(""); + // const code = emit({ + // header: header.join("\n"), + // functions: remainingFunctions, + // }); + // files.push({ + // name: basename + ".code.fc", + // code, + // }); + + return { + entrypoint: `${this.basename}.code.fc`, + files: generated.files, + abi, + }; + } + + /** + * Runs the generation of the main contract. + * This generates some entries from the bottom-up saving them in CodegenContext. + */ + private generateMainContract( + mainContractName: string, + abiLink: string, + ): FuncAstModule { + const m = ModuleGen.fromTact( + this.funcCtx, + mainContractName, + ).writeAll(); + return m; + } + + /** + * Extract information about the generated functions from the contract module. + */ + private extractFunctions( + mainContract: FuncAstModule, + ): FuncAstFunctionDefinition[] { + const contractFunctions = mainContract.entries.reduce((acc, e) => { + if ( + e.kind === + "function_definition" /* TODO: || e.kind === "function_declaration" */ + ) { + acc.push(e); + } + return acc; + }, [] as FuncAstFunctionDefinition[]); + const generatedFunctions = this.funcCtx.getFunctions(); + return [...contractFunctions, ...generatedFunctions]; + + // // Check dependencies + // const missing: Map = new Map(); + // for (const f of contract.entries.values()) { + // for (const d of f.depends) { + // if (!this.#functions.has(d)) { + // if (!missing.has(d)) { + // missing.set(d, [f.name]); + // } else { + // missing.set(d, [...missing.get(d)!, f.name]); + // } + // } + // } + // } + // if (missing.size > 0) { + // throw new Error( + // `Functions ${Array.from(missing.keys()) + // .map((v) => `"${v}"`) + // .join(", ")} wasn't rendered`, + // ); + // } + + // // All functions + // let all = Array.from(this.#functions.values()); + + // // Remove unused + // if (!debug) { + // const used: Set = new Set(); + // const visit = (name: string) => { + // used.add(name); + // const f = this.#functions.get(name)!; + // for (const d of f.depends) { + // visit(d); + // } + // }; + // visit("$main"); + // all = all.filter((v) => used.has(v.name)); + // } + + // Sort functions + // const sorted = topologicalSort(all, (f) => + // Array.from(f.depends).map((v) => this.#functions.get(v)!), + // ); + // return sorted; + } + + /** + * Generates a file that contains declarations of all the generated Func functions. + */ + private generateHeaders( + generated: GeneratedFilesInfo, + functions: FuncAstFunctionDefinition[], + ): void { + const m = makeModule(); + m.entries.push( + makeComment( + "", + `Header files for ${this.abiSrc.name}`, + "NOTE: declarations are sorted for optimal order", + "", + ), + ); + functions.forEach((f) => { + // if (f.code.kind === "generic") { + m.entries.push(makeComment(f.name)); + if ( + f.attrs.find((attr) => attr !== "impure" && attr !== "inline") + ) { + f.attrs.push("inline_ref"); + } + m.entries.push(declarationFromDefinition(f)); + // } + }); + generated.files.push({ + name: `${this.basename}.headers.fc`, + code: new FuncFormatter().dump(m), + }); + } + + private generateStdlib( + generated: GeneratedFilesInfo, + functions: FuncAstFunctionDefinition[], + ): void { + // const stdlibHeader = trimIndent(` + // global (int, slice, int, slice) __tact_context; + // global slice __tact_context_sender; + // global cell __tact_context_sys; + // global int __tact_randomized; + // `); + // + // const stdlibFunctions = tryExtractModule(functions, "stdlib", []); + // if (stdlibFunctions) { + // generated.imported.push("stdlib"); + // } + // + // const stdlib = emit({ + // header: stdlibHeader, + // functions: stdlibFunctions, + // }); + // + // generated.files.push({ + // name: this.basename + ".stdlib.fc", + // code: stdlib, + // }); + } + + private generateNative(generated: GeneratedFilesInfo): void { + // const nativeSources = getRawAST(ctx).funcSources; + // if (nativeSources.length > 0) { + // generated.imported.push("native"); + // generated.files.push({ + // name: this.basename + ".native.fc", + // code: emit({ + // header: [...nativeSources.map((v) => v.code)].join("\n\n"), + // }), + // }); + // } + } + + private generateConstants( + generated: GeneratedFilesInfo, + functions: FuncAstFunctionDefinition[], + ): void { + // const constantsFunctions = tryExtractModule( + // functions, + // "constants", + // imported, + // ); + // if (constantsFunctions) { + // generated.imported.push("constants"); + // generated.files.push({ + // name: this.basename + ".constants.fc", + // code: emit({ functions: constantsFunctions }), + // }); + // } + } + + private generateStorage( + generated: GeneratedFilesInfo, + functions: FuncAstFunctionDefinition[], + ): void { + // const emittedTypes: string[] = []; + // const types = getSortedTypes(ctx); + // for (const t of types) { + // const ffs: WrittenFunction[] = []; + // if ( + // t.kind === "struct" || + // t.kind === "contract" || + // t.kind == "trait" + // ) { + // const typeFunctions = tryExtractModule( + // functions, + // "type:" + t.name, + // generated.imported, + // ); + // if (typeFunctions) { + // generated.imported.push("type:" + t.name); + // ffs.push(...typeFunctions); + // } + // } + // if (t.kind === "contract") { + // const typeFunctions = tryExtractModule( + // functions, + // "type:" + t.name + "$init", + // generated.imported, + // ); + // if (typeFunctions) { + // generated.imported.push("type:" + t.name + "$init"); + // ffs.push(...typeFunctions); + // } + // } + // if (ffs.length > 0) { + // const header: string[] = []; + // header.push(";;"); + // header.push(`;; Type: ${t.name}`); + // if (t.header !== null) { + // header.push(`;; Header: 0x${idToHex(t.header)}`); + // } + // if (t.tlb) { + // header.push(`;; TLB: ${t.tlb}`); + // } + // header.push(";;"); + // + // emittedTypes.push( + // emit({ + // functions: ffs, + // header: header.join("\n"), + // }), + // ); + // } + // } + // if (emittedTypes.length > 0) { + // generated.files.push({ + // name: this.basename + ".storage.fc", + // code: [...emittedTypes].join("\n\n"), + // }); + // } + } +} diff --git a/src/codegen/index.ts b/src/codegen/index.ts index bb9f85773..ed3f15c9e 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -3,3 +3,4 @@ export { ModuleGen } from "./module"; export { FunctionGen } from "./function"; export { StatementGen } from "./statement"; export { ExpressionGen, writePathExpression } from "./expression"; +export { FuncGenerator } from "./generator"; diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 4d2f3167e..ebf1b3ad1 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,43 +1,24 @@ import { getAllTypes } from "../types/resolveDescriptors"; import { TypeDescription } from "../types/types"; import { getSortedTypes } from "../storage/resolveAllocation"; -import { FuncAstModule, FuncAstComment } from "../func/syntax"; -import { makeComment, makePragma, makeInclude } from "../func/syntaxUtils"; +import { FuncAstModule } from "../func/syntax"; +import { makeComment, makeModule } from "../func/syntaxUtils"; import { FunctionGen, CodegenContext } from "."; /** - * Func version used to compile the generated code. - */ -export const CODEGEN_FUNC_VERSION = "0.4.4"; - -/** - * Encapsulates generation of Func compilation module from the Tact module. + * Encapsulates generation of the main Func compilation module from the main Tact module. */ export class ModuleGen { private constructor( private ctx: CodegenContext, private contractName: string, - private abiName: string, ) {} static fromTact( ctx: CodegenContext, contractName: string, - abiName: string, ): ModuleGen { - return new ModuleGen(ctx, contractName, abiName); - } - - private addPragmas(m: FuncAstModule): void { - m.entries.push(makePragma(`version =${CODEGEN_FUNC_VERSION}`)); - m.entries.push(makePragma("allow-post-modification")); - m.entries.push(makePragma("compute-asm-ltr")); - } - - private addIncludes(m: FuncAstModule): void { - m.entries.push(makeInclude(`${this.abiName}.headers.fc`)); - m.entries.push(makeInclude(`${this.abiName}.stdlib.fc`)); - m.entries.push(makeInclude(`${this.abiName}.storage.fc`)); + return new ModuleGen(ctx, contractName); } /** @@ -80,8 +61,6 @@ export class ModuleGen { private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { m.entries.push(makeComment("", `Contract ${c.name} functions`, "")); - // TODO: Generate init - for (const tactFun of c.functions.values()) { const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( tactFun, @@ -225,8 +204,8 @@ export class ModuleGen { // }); } - public writeProgram(): FuncAstModule { - const m: FuncAstModule = { kind: "module", entries: [] }; + public writeAll(): FuncAstModule { + const m: FuncAstModule = makeModule(); const allTypes = Object.values(getAllTypes(this.ctx.ctx)); const contracts = allTypes.filter((v) => v.kind === "contract"); @@ -235,8 +214,6 @@ export class ModuleGen { throw Error(`Contract "${this.contractName}" not found`); } - this.addPragmas(m); - this.addIncludes(m); this.addStdlib(m); this.addSerializers(m); this.addAccessors(m); diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 42d9f874a..2bbbf1348 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -176,7 +176,7 @@ export class FuncFormatter { return `${returnTypeStr} ${nameStr}(${paramsStr}) ${attrsStr}`; } - private formatFunctionDeclaration(node: FuncAstFunctionDefinition): string { + private formatFunctionDeclaration(node: FuncAstFunctionDeclaration): string { const signature = this.formatFunctionSignature( node.name, node.attrs, diff --git a/src/func/syntax.ts b/src/func/syntax.ts index feb8bfc93..a392c1e03 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -312,6 +312,9 @@ export type FuncAstModuleEntry = | FuncAstConstant | FuncAstGlobalVariable; +/** + * Represents a single Func file. + */ export type FuncAstModule = { kind: "module"; entries: FuncAstModuleEntry[]; diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index 2641a8279..034ed71c8 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -1,6 +1,8 @@ import { FuncAstExpr, FuncAstIdExpr, + FuncAstModuleEntry, + FuncAstModule, FuncAstTernaryExpr, FuncAstPragma, FuncAstTensorExpr, @@ -103,3 +105,7 @@ export function makeTernaryExpr( ): FuncAstTernaryExpr { return { kind: "ternary_expr", cond, trueExpr, falseExpr }; } + +export function makeModule(entries: FuncAstModuleEntry[] = []): FuncAstModule { + return { kind: "module", entries }; +} diff --git a/src/pipeline/compile.ts b/src/pipeline/compile.ts index 0de6994bc..0b98e854a 100644 --- a/src/pipeline/compile.ts +++ b/src/pipeline/compile.ts @@ -1,8 +1,7 @@ import { CompilerContext } from "../context"; import { createABI } from "../generator/createABI"; import { writeProgram } from "../generator/writeProgram"; -import { ModuleGen, CodegenContext } from "../codegen"; -import { FuncFormatter } from "../func/formatter"; +import { FuncGenerator } from "../codegen"; export type CompilationOutput = { entrypoint: string; @@ -27,20 +26,19 @@ export async function compile( abiName: string, ): Promise { const abi = createABI(ctx, contractName); + let output: CompilationOutput; if (process.env.NEW_CODEGEN === "1") { - const codegenCtx = new CodegenContext(ctx); - const funcContract = ModuleGen.fromTact( - codegenCtx, - contractName, + output = await FuncGenerator.fromTactProject( + ctx, + abi, abiName, ).writeProgram(); - const output = new FuncFormatter().dump(funcContract); - throw new Error(`output:\n${output}`); - // return { output, ctx }; } else { - const output = await writeProgram(ctx, abi, abiName); - console.log(`${contractName} output:`); - output.files.forEach((o) => console.log(`---------------\nname=${o.name}; code:\n${o.code}\n`)); - return { output, ctx }; + output = await writeProgram(ctx, abi, abiName); } + console.log(`${contractName} output:`); + output.files.forEach((o) => + console.log(`---------------\nname=${o.name}; code:\n${o.code}\n`), + ); + return { output, ctx }; } From 77d7b641d196390807dd53a0596bcb188a39cb71 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Mon, 15 Jul 2024 11:24:22 +0000 Subject: [PATCH 029/162] feat(codegen): `lazy_deployment_completed` and `get_abi_ipfs` --- src/codegen/generator.ts | 13 ++------ src/codegen/module.ts | 67 ++++++++++++++++++++++++++++------------ src/func/formatter.ts | 3 ++ src/func/syntax.ts | 17 ++++++---- src/func/syntaxUtils.ts | 13 ++++++++ 5 files changed, 76 insertions(+), 37 deletions(-) diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index aef89d6be..b6639b5ee 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -74,17 +74,6 @@ export class FuncGenerator { this.generateConstants(generated, functions); this.generateStorage(generated, functions); - // TODO: Everything must be already included to the main contract; otherwise we should add entries from the context - // - // const remainingFunctions = tryExtractModule(functions, null, imported); - // const header: string[] = []; - // header.push("#pragma version =0.4.4;"); - // header.push("#pragma allow-post-modification;"); - // header.push("#pragma compute-asm-ltr;"); - // header.push(""); - // for (const i of files.map((v) => `#include "${v.name}";`)) { - // header.push(i); - // Finalize and dump the main contract, as we have just obtained the structure of the project mainContract.entries.unshift( ...generated.files.map((f) => makeInclude(f.name)), @@ -133,6 +122,7 @@ export class FuncGenerator { const m = ModuleGen.fromTact( this.funcCtx, mainContractName, + abiLink, ).writeAll(); return m; } @@ -207,6 +197,7 @@ export class FuncGenerator { generated: GeneratedFilesInfo, functions: FuncAstFunctionDefinition[], ): void { + // FIXME: We should add only contract methods and special methods here => add attribute and register them in the context const m = makeModule(); m.entries.push( makeComment( diff --git a/src/codegen/module.ts b/src/codegen/module.ts index ebf1b3ad1..0e4f0246a 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,8 +1,16 @@ import { getAllTypes } from "../types/resolveDescriptors"; import { TypeDescription } from "../types/types"; import { getSortedTypes } from "../storage/resolveAllocation"; -import { FuncAstModule } from "../func/syntax"; -import { makeComment, makeModule } from "../func/syntaxUtils"; +import { FuncAstModule, FuncAstFunctionDefinition } from "../func/syntax"; +import { + makeComment, + makeModule, + makeNumberExpr, + makeCall, + makeFunction, + makeReturn, + makeStringExpr, +} from "../func/syntaxUtils"; import { FunctionGen, CodegenContext } from "."; /** @@ -12,13 +20,15 @@ export class ModuleGen { private constructor( private ctx: CodegenContext, private contractName: string, + private abiLink: string, ) {} static fromTact( ctx: CodegenContext, contractName: string, + abiLink: string, ): ModuleGen { - return new ModuleGen(ctx, contractName); + return new ModuleGen(ctx, contractName, abiLink); } /** @@ -72,8 +82,7 @@ export class ModuleGen { /** * Adds entries from the main Tact contract. */ - private addMainContract(m: FuncAstModule, c: TypeDescription): void { - // XXX see: writeMainContract + private writeMainContract(m: FuncAstModule, c: TypeDescription): void { m.entries.push( makeComment("", `Receivers of a Contract ${c.name}`, ""), ); @@ -97,21 +106,39 @@ export class ModuleGen { // // Interfaces // writeInterfaces(type, ctx); - // // ABI - // ctx.append(`_ get_abi_ipfs() method_id {`); - // ctx.inIndent(() => { - // ctx.append(`return "${abiLink}";`); - // }); - // ctx.append(`}`); - // ctx.append(); + // ABI: + // _ get_abi_ipfs() method_id { + // return "${abiLink}"; + // } + m.entries.push( + makeFunction(["method_id"], "get_abi_ipfs", [], { kind: "hole" }, [ + makeReturn(makeStringExpr(this.abiLink)), + ]), + ); - // // Deployed - // ctx.append(`_ lazy_deployment_completed() method_id {`); - // ctx.inIndent(() => { - // ctx.append(`return get_data().begin_parse().load_int(1);`); - // }); - // ctx.append(`}`); - // ctx.append(); + // Deployed + //_ lazy_deployment_completed() method_id { + // return get_data().begin_parse().load_int(1); + // } + m.entries.push( + makeFunction( + ["method_id"], + "lazy_deployment_completed", + [], + { kind: "hole" }, + [ + makeReturn( + makeCall( + makeCall( + makeCall("load_init", [makeNumberExpr(1)]), + [], + ), + [], + ), + ), + ], + ), + ); // Comments m.entries.push(makeComment("", `Routing of a Contract ${c.name}`, "")); @@ -222,7 +249,7 @@ export class ModuleGen { this.addStaticFunctions(m); this.addExtensions(m); contracts.forEach((c) => this.addContractFunctions(m, c)); - this.addMainContract(m, contract); + this.writeMainContract(m, contract); return m; } diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 2bbbf1348..ad98e4d80 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -64,6 +64,7 @@ export class FuncFormatter { case "comment": return this.formatComment(node as FuncAstComment); case "int": + case "hole": case "cell": case "slice": case "builder": @@ -381,6 +382,8 @@ export class FuncFormatter { private formatType(node: FuncType): string { switch (node.kind) { + case "hole": + return "_"; case "int": case "cell": case "slice": diff --git a/src/func/syntax.ts b/src/func/syntax.ts index a392c1e03..2e8d087de 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -25,6 +25,7 @@ export type FuncType = | { kind: "cont" } | { kind: "tuple" } | { kind: "tensor"; value: FuncTensorType } + | { kind: "hole" } // hole type (`_`) filled in local type inference | { kind: "type" }; export type FuncAstUnaryOp = "-" | "~" | "+"; @@ -107,7 +108,7 @@ export type FuncAstIdExpr = { export type FuncAstCallExpr = { kind: "call_expr"; - fun: FuncAstExpr; + fun: FuncAstExpr; // function name or an expression returning a function args: FuncAstExpr[]; }; @@ -257,7 +258,11 @@ export type FuncAstTryCatchStmt = { catchVar: string | null; }; -export type FuncAstFunctionAttribute = "impure" | "inline" | "inline_ref"; +export type FuncAstFunctionAttribute = + | "impure" + | "inline" + | "inline_ref" + | "method_id"; export type FuncAstFormalFunctionParam = { kind: "function_param"; @@ -267,7 +272,7 @@ export type FuncAstFormalFunctionParam = { export type FuncAstFunctionDeclaration = { kind: "function_declaration"; - name: string, + name: string; attrs: FuncAstFunctionAttribute[]; params: FuncAstFormalFunctionParam[]; returnTy: FuncType; @@ -275,7 +280,7 @@ export type FuncAstFunctionDeclaration = { export type FuncAstFunctionDefinition = { kind: "function_definition"; - name: string, + name: string; attrs: FuncAstFunctionAttribute[]; params: FuncAstFormalFunctionParam[]; returnTy: FuncType; @@ -289,12 +294,12 @@ export type FuncAstComment = { export type FuncAstInclude = { kind: "include"; - value: string, + value: string; }; export type FuncAstPragma = { kind: "pragma"; - value: string, + value: string; }; export type FuncAstGlobalVariable = { diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index 034ed71c8..015521dc0 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -1,6 +1,8 @@ import { FuncAstExpr, FuncAstIdExpr, + FuncAstStringExpr, + FuncAstNumberExpr, FuncAstModuleEntry, FuncAstModule, FuncAstTernaryExpr, @@ -22,6 +24,17 @@ export function makeId(value: string): FuncAstIdExpr { return { kind: "id_expr", value }; } +export function makeStringExpr(value: string): FuncAstStringExpr { + return { kind: "string_expr", value }; +} + +export function makeNumberExpr(num: bigint | number): FuncAstNumberExpr { + return { + kind: "number_expr", + value: typeof num === "bigint" ? num : BigInt(num), + }; +} + export function makeCall( fun: FuncAstExpr | string, args: FuncAstExpr[], From 1e3e435e61b29a35696991f8101e117c10ffbc18 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Mon, 15 Jul 2024 11:52:03 +0000 Subject: [PATCH 030/162] feat(syntax): Support string literal types --- src/func/formatter.ts | 3 ++- src/func/syntax.ts | 6 ++++++ src/func/syntaxUtils.ts | 8 ++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index ad98e4d80..9552f2c44 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -327,7 +327,8 @@ export class FuncFormatter { } private formatStringExpr(node: FuncAstStringExpr): string { - return `"${node.value}"`; + const ty = node.ty ? node.ty : ""; + return `"${node.value}"${ty}`; } private formatNilExpr(_: FuncAstNilExpr): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 2e8d087de..97ad109e3 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -156,9 +156,15 @@ export type FuncAstBoolExpr = { value: boolean; }; +/** + * An additional modifier. See: https://docs.ton.org/develop/func/literals_identifiers#string-literals + */ +export type FuncStringLiteralType = "s" | "a" | "u" | "h" | "H" | "c"; + export type FuncAstStringExpr = { kind: "string_expr"; value: string; + ty: FuncStringLiteralType | undefined; }; export type FuncAstNilExpr = { diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index 015521dc0..b54f73dae 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -3,6 +3,7 @@ import { FuncAstIdExpr, FuncAstStringExpr, FuncAstNumberExpr, + FuncStringLiteralType, FuncAstModuleEntry, FuncAstModule, FuncAstTernaryExpr, @@ -24,8 +25,11 @@ export function makeId(value: string): FuncAstIdExpr { return { kind: "id_expr", value }; } -export function makeStringExpr(value: string): FuncAstStringExpr { - return { kind: "string_expr", value }; +export function makeStringExpr( + value: string, + ty?: FuncStringLiteralType, +): FuncAstStringExpr { + return { kind: "string_expr", value, ty }; } export function makeNumberExpr(num: bigint | number): FuncAstNumberExpr { From da80237ee5c4e29b95bcbbaa0b88aeab4341f9c9 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Mon, 15 Jul 2024 12:08:46 +0000 Subject: [PATCH 031/162] feat(codegen): Generate `supported_interfaces` --- src/codegen/module.ts | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 0e4f0246a..caf2f4d18 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,10 +1,17 @@ import { getAllTypes } from "../types/resolveDescriptors"; import { TypeDescription } from "../types/types"; import { getSortedTypes } from "../storage/resolveAllocation"; -import { FuncAstModule, FuncAstFunctionDefinition } from "../func/syntax"; +import { getSupportedInterfaces } from "../types/getSupportedInterfaces"; +import { + FuncAstModule, + FuncAstFunctionDefinition, + FuncAstExpr, +} from "../func/syntax"; import { makeComment, + makeTensorExpr, makeModule, + makeBinop, makeNumberExpr, makeCall, makeFunction, @@ -64,6 +71,34 @@ export class ModuleGen { // TODO } + /** + * Generates a method that returns the supported interfaces, e.g.: + * ``` + * _ supported_interfaces() method_id { + * return ( + * "org.ton.introspection.v0"H >> 128, + * "org.ton.abi.ipfs.v0"H >> 128, + * "org.ton.deploy.lazy.v0"H >> 128, + * "org.ton.chain.workchain.v0"H >> 128); + * } + * ``` + */ + private writeInterfaces(type: TypeDescription): FuncAstFunctionDefinition { + const supported: string[] = []; + supported.push("org.ton.introspection.v0"); + supported.push(...getSupportedInterfaces(type, this.ctx.ctx)); + const shiftExprs: FuncAstExpr[] = supported.map((item) => + makeBinop(makeStringExpr(item, "H"), ">>", makeNumberExpr(128)), + ); + return makeFunction( + ["method_id"], + "supported_interfaces", + [], + { kind: "hole" }, + [makeReturn(makeTensorExpr(...shiftExprs))], + ); + } + /** * Adds functions defined within the Tact contract to the generated Func module. * TODO: Why do we need function from *all* the contracts? @@ -103,8 +138,8 @@ export class ModuleGen { // } // } - // // Interfaces - // writeInterfaces(type, ctx); + // Interfaces + m.entries.push(this.writeInterfaces(c)); // ABI: // _ get_abi_ipfs() method_id { @@ -143,7 +178,7 @@ export class ModuleGen { // Comments m.entries.push(makeComment("", `Routing of a Contract ${c.name}`, "")); - // // Render body + // Render body // const hasExternal = type.receivers.find((v) => // v.selector.kind.startsWith("external-"), // ); From ad7d2ec2afb7948cdbee41a35dc8076e7189ed5f Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Tue, 16 Jul 2024 11:32:29 +0000 Subject: [PATCH 032/162] feat(syntax): Introduce `constructors` --- src/func/syntaxConstructors.ts | 396 +++++++++++++++++++++++++++++++++ 1 file changed, 396 insertions(+) create mode 100644 src/func/syntaxConstructors.ts diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts new file mode 100644 index 000000000..cf9d4aa9a --- /dev/null +++ b/src/func/syntaxConstructors.ts @@ -0,0 +1,396 @@ +import { + FuncAstNumberExpr, + FuncAstBoolExpr, + FuncAstStringExpr, + FuncAstNilExpr, + FuncAstIdExpr, + FuncAstCallExpr, + FuncAstAssignExpr, + FuncAstAugmentedAssignExpr, + FuncAstTernaryExpr, + FuncAstBinaryExpr, + FuncAstUnaryExpr, + FuncAstApplyExpr, + FuncAstTupleExpr, + FuncAstTensorExpr, + FuncAstUnitExpr, + FuncAstHoleExpr, + FuncAstPrimitiveTypeExpr, + FuncStringLiteralType, + FuncAstAugmentedAssignOp, + FuncAstBinaryOp, + FuncAstUnaryOp, + FuncAstVarDefStmt, + FuncAstReturnStmt, + FuncAstBlockStmt, + FuncAstRepeatStmt, + FuncAstConditionStmt, + FuncAstStmt, + FuncAstDoUntilStmt, + FuncAstWhileStmt, + FuncAstExprStmt, + FuncAstTryCatchStmt, + FuncAstExpr, + FuncType, + FuncAstConstant, + FuncAstFormalFunctionParam, + FuncAstFunctionAttribute, + FuncAstFunctionDeclaration, + FuncAstFunctionDefinition, + FuncAstComment, + FuncAstInclude, + FuncAstPragma, + FuncAstGlobalVariable, + FuncAstModuleEntry, + FuncAstModule, +} from "./syntax"; + +// +// Types +// +export class Type { + public static int(): FuncType { + return { kind: "int" }; + } + + public static cell(): FuncType { + return { kind: "cell" }; + } + + public static slice(): FuncType { + return { kind: "slice" }; + } + + public static builder(): FuncType { + return { kind: "builder" }; + } + + public static cont(): FuncType { + return { kind: "cont" }; + } + + public static tuple(): FuncType { + return { kind: "tuple" }; + } + + public static tensor(...value: FuncType[]): FuncType { + return { kind: "tensor", value }; + } + + public static hole(): FuncType { + return { kind: "hole" }; + } + + public static type(): FuncType { + return { kind: "type" }; + } +} + +// +// Expressions +// + +export const number = (num: bigint | number): FuncAstNumberExpr => ({ + kind: "number_expr", + value: typeof num === "bigint" ? num : BigInt(num), +}); + +export const bool = (value: boolean): FuncAstBoolExpr => ({ + kind: "bool_expr", + value, +}); + +export const string = ( + value: string, + ty?: FuncStringLiteralType, +): FuncAstStringExpr => ({ + kind: "string_expr", + value, + ty, +}); + +export const nil = (): FuncAstNilExpr => ({ + kind: "nil_expr", +}); + +export const id = (value: string): FuncAstIdExpr => ({ + kind: "id_expr", + value, +}); + +export const call = ( + fun: FuncAstExpr | string, + args: FuncAstExpr[], +): FuncAstCallExpr => ({ + kind: "call_expr", + fun: typeof fun === "string" ? id(fun) : fun, + args, +}); + +export const assign = ( + lhs: FuncAstExpr, + rhs: FuncAstExpr, +): FuncAstAssignExpr => ({ + kind: "assign_expr", + lhs, + rhs, +}); + +export const augmentedAssign = ( + lhs: FuncAstExpr, + op: FuncAstAugmentedAssignOp, + rhs: FuncAstExpr, +): FuncAstAugmentedAssignExpr => ({ + kind: "augmented_assign_expr", + lhs, + op, + rhs, +}); + +export const ternary = ( + cond: FuncAstExpr, + trueExpr: FuncAstExpr, + falseExpr: FuncAstExpr, +): FuncAstTernaryExpr => ({ + kind: "ternary_expr", + cond, + trueExpr, + falseExpr, +}); + +export const binop = ( + lhs: FuncAstExpr, + op: FuncAstBinaryOp, + rhs: FuncAstExpr, +): FuncAstBinaryExpr => ({ + kind: "binary_expr", + lhs, + op, + rhs, +}); + +export const unop = ( + op: FuncAstUnaryOp, + value: FuncAstExpr, +): FuncAstUnaryExpr => ({ + kind: "unary_expr", + op, + value, +}); + +export const apply = ( + lhs: FuncAstExpr, + rhs: FuncAstExpr, +): FuncAstApplyExpr => ({ + kind: "apply_expr", + lhs, + rhs, +}); + +export const tuple = (values: FuncAstExpr[]): FuncAstTupleExpr => ({ + kind: "tuple_expr", + values, +}); + +export const tensor = (...values: FuncAstExpr[]): FuncAstTensorExpr => ({ + kind: "tensor_expr", + values, +}); + +export const unit = (): FuncAstUnitExpr => ({ + kind: "unit_expr", +}); + +export const hole = ( + id: string | undefined, + init: FuncAstExpr, +): FuncAstHoleExpr => ({ + kind: "hole_expr", + id, + init, +}); + +export const primitiveType = (ty: FuncType): FuncAstPrimitiveTypeExpr => ({ + kind: "primitive_type_expr", + ty, +}); + +// +// Statements +// + +export const varDef = ( + ty: FuncType | undefined, + name: string, + init?: FuncAstExpr, +): FuncAstVarDefStmt => ({ + kind: "var_def_stmt", + name, + ty, + init, +}); + +export const ret = (value?: FuncAstExpr): FuncAstReturnStmt => ({ + kind: "return_stmt", + value, +}); + +export const block = (body: FuncAstStmt[]): FuncAstBlockStmt => ({ + kind: "block_stmt", + body, +}); + +export const repeat = ( + condition: FuncAstExpr, + body: FuncAstStmt[], +): FuncAstRepeatStmt => ({ + kind: "repeat_stmt", + condition, + body, +}); + +export const condition = ( + condition: FuncAstExpr | undefined, + ifnot: boolean, + body: FuncAstStmt[], + elseStmt?: FuncAstConditionStmt, +): FuncAstConditionStmt => ({ + kind: "condition_stmt", + condition, + ifnot, + body, + else: elseStmt, +}); + +export const doUntil = ( + body: FuncAstStmt[], + condition: FuncAstExpr, +): FuncAstDoUntilStmt => ({ + kind: "do_until_stmt", + body, + condition, +}); + +export const while_ = ( + condition: FuncAstExpr, + body: FuncAstStmt[], +): FuncAstWhileStmt => ({ + kind: "while_stmt", + condition, + body, +}); + +export const expr = (expr: FuncAstExpr): FuncAstExprStmt => ({ + kind: "expr_stmt", + expr, +}); + +export const tryCatch = ( + tryBlock: FuncAstStmt[], + catchBlock: FuncAstStmt[], + catchVar: string | null, +): FuncAstTryCatchStmt => ({ + kind: "try_catch_stmt", + tryBlock, + catchBlock, + catchVar, +}); + +// Other top-level elements + +export const comment = (...values: string[]): FuncAstComment => ({ + kind: "comment", + values, +}); + +export const constant = (ty: FuncType, init: FuncAstExpr): FuncAstConstant => ({ + kind: "constant", + ty, + init, +}); + +export const functionParam = ( + name: string, + ty: FuncType, +): FuncAstFormalFunctionParam => ({ + kind: "function_param", + name, + ty, +}); + +export const functionDeclaration = ( + name: string, + attrs: FuncAstFunctionAttribute[], + params: FuncAstFormalFunctionParam[], + returnTy: FuncType, +): FuncAstFunctionDeclaration => ({ + kind: "function_declaration", + name, + attrs, + params, + returnTy, +}); + +export const fun = ( + attrs: FuncAstFunctionAttribute[], + name: string, + paramValues: [string, FuncType][], + returnTy: FuncType, + body: FuncAstStmt[], +): FuncAstFunctionDefinition => { + const params = paramValues.map( + ([name, ty]) => + ({ + kind: "function_param", + name, + ty, + }) as FuncAstFormalFunctionParam, + ); + return { + kind: "function_definition", + name, + attrs, + params, + returnTy, + body, + }; +}; + +export function toDeclaration( + def: FuncAstFunctionDefinition, +): FuncAstFunctionDeclaration { + return { + kind: "function_declaration", + attrs: def.attrs, + name: def.name, + params: def.params, + returnTy: def.returnTy, + }; +} + +export const include = (value: string): FuncAstInclude => ({ + kind: "include", + value, +}); + +export const pragma = (value: string): FuncAstPragma => ({ + kind: "pragma", + value, +}); + +export const globalVariable = ( + name: string, + ty: FuncType, +): FuncAstGlobalVariable => ({ + kind: "global_variable", + name, + ty, +}); + +export const moduleEntry = (entry: FuncAstModuleEntry): FuncAstModuleEntry => + entry; + +export const module = (...entries: FuncAstModuleEntry[]): FuncAstModule => ({ + kind: "module", + entries, +}); From 0b0383dfcb33f6242631f49b1242f744ad080ea5 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Wed, 17 Jul 2024 01:47:02 +0000 Subject: [PATCH 033/162] feat(syntax+fmt): Support hex int literals; refactor --- src/func/formatter.ts | 11 +++- src/func/syntax.ts | 101 ++++++++++++++++++++------------- src/func/syntaxConstructors.ts | 6 ++ 3 files changed, 76 insertions(+), 42 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 9552f2c44..164cb56d4 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -28,6 +28,7 @@ import { FuncAstBinaryExpr, FuncAstUnaryExpr, FuncAstNumberExpr, + FuncAstHexNumberExpr, FuncAstBoolExpr, FuncAstStringExpr, FuncAstNilExpr, @@ -121,6 +122,8 @@ export class FuncFormatter { return this.formatUnaryExpr(node as FuncAstUnaryExpr); case "number_expr": return this.formatNumberExpr(node as FuncAstNumberExpr); + case "hex_number_expr": + return this.formatHexNumberExpr(node as FuncAstHexNumberExpr); case "bool_expr": return this.formatBoolExpr(node as FuncAstBoolExpr); case "string_expr": @@ -177,7 +180,9 @@ export class FuncFormatter { return `${returnTypeStr} ${nameStr}(${paramsStr}) ${attrsStr}`; } - private formatFunctionDeclaration(node: FuncAstFunctionDeclaration): string { + private formatFunctionDeclaration( + node: FuncAstFunctionDeclaration, + ): string { const signature = this.formatFunctionSignature( node.name, node.attrs, @@ -322,6 +327,10 @@ export class FuncFormatter { return node.value.toString(); } + private formatHexNumberExpr(node: FuncAstHexNumberExpr): string { + return node.value; + } + private formatBoolExpr(node: FuncAstBoolExpr): string { return node.value.toString(); } diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 97ad109e3..092977f56 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -95,11 +95,35 @@ interface FuncAstVarDescrFlags { NotNull: boolean; } -export type FuncAstConstant = { - kind: "constant"; - ty: FuncType; - init: FuncAstExpr; -}; +// +// Expressions +// + +export type FuncAstLiteralExpr = + | FuncAstNumberExpr + | FuncAstHexNumberExpr + | FuncAstBoolExpr + | FuncAstStringExpr + | FuncAstNilExpr; +export type FuncAstSimpleExpr = + | FuncAstIdExpr + | FuncAstTupleExpr + | FuncAstTensorExpr + | FuncAstUnitExpr + | FuncAstHoleExpr + | FuncAstPrimitiveTypeExpr; +export type FuncAstCompositeExpr = + | FuncAstCallExpr + | FuncAstAssignExpr + | FuncAstAugmentedAssignExpr + | FuncAstTernaryExpr + | FuncAstBinaryExpr + | FuncAstUnaryExpr + | FuncAstApplyExpr; +export type FuncAstExpr = + | FuncAstLiteralExpr + | FuncAstSimpleExpr + | FuncAstCompositeExpr; export type FuncAstIdExpr = { kind: "id_expr"; @@ -151,6 +175,11 @@ export type FuncAstNumberExpr = { value: bigint; }; +export type FuncAstHexNumberExpr = { + kind: "hex_number_expr"; + value: string; +}; + export type FuncAstBoolExpr = { kind: "bool_expr"; value: boolean; @@ -206,6 +235,22 @@ export type FuncAstPrimitiveTypeExpr = { ty: FuncType; }; +// +// Statements +// + +export type FuncAstStmt = + | FuncAstComment // a comment appearing among statements + | FuncAstBlockStmt + | FuncAstVarDefStmt + | FuncAstReturnStmt + | FuncAstRepeatStmt + | FuncAstConditionStmt + | FuncAstDoUntilStmt + | FuncAstWhileStmt + | FuncAstExprStmt + | FuncAstTryCatchStmt; + // Local variable definition: // int x = 2; // ty = int // var x = 2; // ty is undefined @@ -264,6 +309,16 @@ export type FuncAstTryCatchStmt = { catchVar: string | null; }; +// +// Other and top-level elements +// + +export type FuncAstConstant = { + kind: "constant"; + ty: FuncType; + init: FuncAstExpr; +}; + export type FuncAstFunctionAttribute = | "impure" | "inline" @@ -331,42 +386,6 @@ export type FuncAstModule = { entries: FuncAstModuleEntry[]; }; -export type FuncAstLiteralExpr = - | FuncAstNumberExpr - | FuncAstBoolExpr - | FuncAstStringExpr - | FuncAstNilExpr; -export type FuncAstSimpleExpr = - | FuncAstIdExpr - | FuncAstTupleExpr - | FuncAstTensorExpr - | FuncAstUnitExpr - | FuncAstHoleExpr - | FuncAstPrimitiveTypeExpr; -export type FuncAstCompositeExpr = - | FuncAstCallExpr - | FuncAstAssignExpr - | FuncAstAugmentedAssignExpr - | FuncAstTernaryExpr - | FuncAstBinaryExpr - | FuncAstUnaryExpr - | FuncAstApplyExpr; -export type FuncAstExpr = - | FuncAstLiteralExpr - | FuncAstSimpleExpr - | FuncAstCompositeExpr; - -export type FuncAstStmt = - | FuncAstBlockStmt - | FuncAstVarDefStmt - | FuncAstReturnStmt - | FuncAstRepeatStmt - | FuncAstConditionStmt - | FuncAstDoUntilStmt - | FuncAstWhileStmt - | FuncAstExprStmt - | FuncAstTryCatchStmt; - export type FuncAstNode = | FuncAstStmt | FuncAstExpr diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index cf9d4aa9a..49ba98dab 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -1,5 +1,6 @@ import { FuncAstNumberExpr, + FuncAstHexNumberExpr, FuncAstBoolExpr, FuncAstStringExpr, FuncAstNilExpr, @@ -95,6 +96,11 @@ export const number = (num: bigint | number): FuncAstNumberExpr => ({ value: typeof num === "bigint" ? num : BigInt(num), }); +export const hexnumber = (value: string): FuncAstHexNumberExpr => ({ + kind: "hex_number_expr", + value, +}); + export const bool = (value: boolean): FuncAstBoolExpr => ({ kind: "bool_expr", value, From 6c86d618d7eaaab2ee35c652ead2e477a4f41073 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Wed, 17 Jul 2024 01:57:22 +0000 Subject: [PATCH 034/162] fix(fmt): Missing semicolons --- src/func/formatter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 164cb56d4..997f3676b 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -379,11 +379,11 @@ export class FuncFormatter { } private formatInclude(node: FuncAstInclude): string { - return `#include "${node.value}"`; + return `#include "${node.value}";`; } private formatPragma(node: FuncAstPragma): string { - return `#pragma ${node.value}`; + return `#pragma ${node.value};`; } private formatComment(node: FuncAstComment): string { From 3f0ed5bb8882e6305d6cbf87c81b7f6e8c7156ee Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Wed, 17 Jul 2024 01:57:45 +0000 Subject: [PATCH 035/162] feat(codegen): Routers; handlers for receivers --- src/codegen/module.ts | 369 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 369 insertions(+) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index caf2f4d18..d21283b5f 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -114,6 +114,375 @@ export class ModuleGen { } } + private commentPseudoOpcode(comment: string): string { + return beginCell() + .storeUint(0, 32) + .storeBuffer(Buffer.from(comment, "utf8")) + .endCell() + .hash() + .toString("hex", 0, 64); + } + + // TODO: refactor this bs asap: + // + two different functions depending on `kind` + // + extract methods + // + separate file + private writeRouter( + type: TypeDescription, + kind: "internal" | "external", + ): FuncAstFunctionDefinition { + const internal = kind === "internal"; + const attrs: FuncAstFunctionAttribute[] = ["impure", "inline_ref"]; + const name = ops.contractRouter(type.name, kind); + const returnTy = Type.tensor( + resolveFuncType(this.ctx.ctx, type), + Type.int(), + ); + const paramValues: [string, FuncType][] = internal + ? [ + ["self", resolveFuncType(this.ctx.ctx, type)], + ["msg_bounced", Type.int()], + ["in_msg", Type.slice()], + ] + : [ + ["self", resolveFuncType(this.ctx.ctx, type)], + ["in_msg", Type.slice()], + ]; + const functionBody: FuncAstStmt[] = []; + + // ;; Handle bounced messages + // if (msg_bounced) { + // ... + // } + if (internal) { + const body: FuncAstStmt[] = []; + body.push(comment("Handle bounced messages")); + const bounceReceivers = type.receivers.filter((r) => { + return r.selector.kind === "bounce-binary"; + }); + + const fallbackReceiver = type.receivers.find((r) => { + return r.selector.kind === "bounce-fallback"; + }); + + const condBody: FuncAstStmt[] = []; + if (fallbackReceiver ?? bounceReceivers.length > 0) { + // ;; Skip 0xFFFFFFFF + // in_msg~skip_bits(32); + condBody.push(comment("Skip 0xFFFFFFFF")); + condBody.push(expr(call("in_msg~skip_bits", [number(32)]))); + } + + if (bounceReceivers.length > 0) { + // ;; Parse op + // int op = 0; + // if (slice_bits(in_msg) >= 32) { + // op = in_msg.preload_uint(32); + // } + condBody.push(comment("Parse op")); + condBody.push(varDef(Type.int(), "op", number(0))); + condBody.push( + condition( + binop( + call("slice_bits", [id("in_msg")]), + ">=", + number(30), + ), + [ + expr( + assign( + id("op"), + call(id("in_msg.preload_uint"), [ + number(32), + ]), + ), + ), + ], + ), + ); + } + + for (const r of bounceReceivers) { + const selector = r.selector; + if (selector.kind !== "bounce-binary") + throw Error(`Invalid selector type: ${selector.kind}`); // Should not happen + body.push( + comment(`Bounced handler for ${selector.type} message`), + ); + // XXX: We assert `header` to be non-null only in the new backend; otherwise it could be a compiler bug + body.push( + condition( + binop( + id("op"), + "==", + number( + getType(this.ctx.ctx, selector.type).header!, + ), + ), + [ + varDef( + undefined, + "msg", + call( + id( + `in_msg~${selector.bounced ? ops.readerBounced(selector.type) : ops.reader(selector.type)}`, + ), + [], + ), + ), + expr( + call( + id( + `self~${ops.receiveTypeBounce(type.name, selector.type)}`, + ), + [id("msg")], + ), + ), + ret(tensor(id("self"), bool(true))), + ], + ), + ); + } + + if (fallbackReceiver) { + const selector = fallbackReceiver.selector; + if (selector.kind !== "bounce-fallback") + throw Error("Invalid selector type: " + selector.kind); + body.push(comment("Fallback bounce receiver")); + body.push( + expr( + call(id(`self~${ops.receiveBounceAny(type.name)}`), [ + id("in_msg"), + ]), + ), + ); + body.push(ret(tensor(id("self"), bool(true)))); + } else { + body.push(ret(tensor(id("self"), bool(true)))); + } + const cond = condition(id("msg_bounced"), body); + functionBody.push(cond); + } + + // ;; Parse incoming message + // int op = 0; + // if (slice_bits(in_msg) >= 32) { + // op = in_msg.preload_uint(32); + // } + functionBody.push(comment("Parse incoming message")); + functionBody.push(varDef(Type.int(), "op", number(0))); + functionBody.push( + condition( + binop(call(id("slice_bits"), [id("in_msg")]), ">=", number(32)), + [ + expr( + assign( + id("op"), + call("in_msg.preload_unit", [number(32)]), + ), + ), + ], + ), + ); + + // Non-empty receivers + for (const f of type.receivers) { + const selector = f.selector; + + // Generic receiver + if ( + selector.kind === + (internal ? "internal-binary" : "external-binary") + ) { + const allocation = getType(this.ctx.ctx, selector.type); + if (!allocation.header) { + throw Error(`Invalid allocation: ${selector.type}`); + } + functionBody.push(comment(`Receive ${selector.type} message`)); + functionBody.push( + condition( + binop(id("op"), "==", number(allocation.header)), + [ + varDef( + undefined, + "msg", + call(`in_msg~${ops.reader(selector.type)}`, []), + ), + expr( + call( + `self~${ops.receiveType(type.name, kind, selector.type)}`, + [id("msg")], + ), + ), + ], + ), + ); + } + + if ( + selector.kind === + (internal ? "internal-empty" : "external-empty") + ) { + // ;; Receive empty message + // if ((op == 0) & (slice_bits(in_msg) <= 32)) { + // self~${ops.receiveEmpty(type.name, kind)}(); + // return (self, true); + // } + functionBody.push(comment("Receive empty message")); + functionBody.push( + condition( + binop( + binop(id("op"), "==", number(0)), + "&", + binop( + call("slice_bits", [id("in_msg")]), + "<=", + number(32), + ), + ), + [ + expr( + call( + `self~${ops.receiveEmpty(type.name, kind)}`, + [], + ), + ), + ret(tensor(id("self"), bool(true))), + ], + ), + ); + } + } + + // Text resolvers + const hasComments = !!type.receivers.find((v) => + internal + ? v.selector.kind === "internal-comment" || + v.selector.kind === "internal-comment-fallback" + : v.selector.kind === "external-comment" || + v.selector.kind === "external-comment-fallback", + ); + if (hasComments) { + // ;; Text Receivers + // if (op == 0) { + // ... + // } + functionBody.push(comment("Text Receivers")); + const cond = binop(id("op"), "==", number(0)); + const condBody: FuncAstStmt[] = []; + if ( + type.receivers.find( + (v) => + v.selector.kind === + (internal ? "internal-comment" : "external-comment"), + ) + ) { + // var text_op = slice_hash(in_msg); + condBody.push( + varDef( + undefined, + "text_op", + call("slice_hash", [id("in_msg")]), + ), + ); + for (const r of type.receivers) { + if ( + r.selector.kind === + (internal ? "internal-comment" : "external-comment") + ) { + // ;; Receive "increment" message + // if (text_op == 0xc4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae) { + // self~$A$_internal_text_c4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae(); + // return (self, true); + // } + const hash = this.commentPseudoOpcode( + r.selector.comment, + ); + condBody.push( + comment(`Receive "${r.selector.comment}" message`), + ); + condBody.push( + condition( + binop( + id("text_op"), + "==", + hexnumber(`0x${hash}`), + ), + [ + expr( + call( + `self~${ops.receiveText(type.name, kind, hash)}`, + [], + ), + ), + ret(tensor(id("self"), bool(true))), + ], + ), + ); + } + } + } + + // Comment fallback resolver + const fallback = type.receivers.find( + (v) => + v.selector.kind === + (internal + ? "internal-comment-fallback" + : "external-comment-fallback"), + ); + if (fallback) { + condBody.push( + condition( + binop( + call("slice_bits", [id("in_msg")]), + ">=", + number(32), + ), + [ + expr( + call( + id( + `self~${ops.receiveAnyText(type.name, kind)}`, + ), + [call("in_msg.skip_bits", [number(32)])], + ), + ), + ret(tensor(id("self"), bool(true))), + ], + ), + ); + } + functionBody.push(condition(cond, condBody)); + } + + // Fallback + const fallbackReceiver = type.receivers.find( + (v) => + v.selector.kind === + (internal ? "internal-fallback" : "external-fallback"), + ); + if (fallbackReceiver) { + // ;; Receiver fallback + // self~${ops.receiveAny(type.name, kind)}(in_msg); + // return (self, true); + functionBody.push(comment("Receiver fallback")); + functionBody.push( + expr( + call(`self~${ops.receiveAny(type.name, kind)}`, [ + id("in_msg"), + ]), + ), + ); + functionBody.push(ret(tensor(id("self"), bool(true)))); + } else { + // return (self, false); + functionBody.push(ret(tensor(id("self"), bool(false)))); + } + + return fun(attrs, name, paramValues, returnTy, functionBody); + } + /** * Adds entries from the main Tact contract. */ From 9ccdbffea06930dfaaf3df94144a67101564a6d9 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Wed, 17 Jul 2024 01:58:10 +0000 Subject: [PATCH 036/162] feat(syntax+codegen): Support new AST constructors --- src/codegen/expression.ts | 103 +++++++++++++------------- src/codegen/function.ts | 27 ++++--- src/codegen/generator.ts | 24 +++---- src/codegen/module.ts | 110 ++++++++++++++-------------- src/codegen/statement.ts | 81 +++++++-------------- src/codegen/type.ts | 37 +++++----- src/codegen/util.ts | 9 +-- src/func/syntaxConstructors.ts | 58 +++++++-------- src/func/syntaxUtils.ts | 128 --------------------------------- 9 files changed, 205 insertions(+), 372 deletions(-) delete mode 100644 src/func/syntaxUtils.ts diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 6261941a6..deee4f96d 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -29,12 +29,7 @@ import { FuncAstIdExpr, FuncAstTernaryExpr, } from "../func/syntax"; -import { - makeId, - makeCall, - makeBinop, - makeTernaryExpr, -} from "../func/syntaxUtils"; +import { id, call, binop, ternary } from "../func/syntaxConstructors"; function isNull(f: AstExpression): boolean { return f.kind === "null"; @@ -57,7 +52,7 @@ function negate(expr: FuncAstExpr): FuncAstExpr { * TODO: make it a static method */ export function writePathExpression(path: AstId[]): FuncAstIdExpr { - return makeId( + return id( [funcIdOf(idText(path[0]!)), ...path.slice(1).map(idText)].join(`'`), ); } @@ -135,7 +130,7 @@ export class ExpressionGen { ); } }); - return makeCall(constructor.name, fieldValues); + return call(constructor.name, fieldValues); } throw Error(`Invalid value: ${val}`); } @@ -165,7 +160,7 @@ export class ExpressionGen { t, funcIdOf(this.tactExpr.text), ); - return makeId(value); + return id(value); } } @@ -188,7 +183,7 @@ export class ExpressionGen { return ExpressionGen.writeValue(this.ctx, c.value!); } - return makeId(funcIdOf(this.tactExpr.text)); + return id(funcIdOf(this.tactExpr.text)); } // NOTE: We always wrap in parentheses to avoid operator precedence issues @@ -204,18 +199,22 @@ export class ExpressionGen { isNull(this.tactExpr.left) && !isNull(this.tactExpr.right) ) { - const call = makeCall("null?", [ + const callExpr = call("null?", [ this.makeExpr(this.tactExpr.right), ]); - return this.tactExpr.op === "==" ? call : negate(call); + return this.tactExpr.op === "==" + ? callExpr + : negate(callExpr); } else if ( !isNull(this.tactExpr.left) && isNull(this.tactExpr.right) ) { - const call = makeCall("null?", [ + const callExpr = call("null?", [ this.makeExpr(this.tactExpr.left), ]); - return this.tactExpr.op === "==" ? call : negate(call); + return this.tactExpr.op === "==" + ? callExpr + : negate(callExpr); } } @@ -238,7 +237,7 @@ export class ExpressionGen { }; if (lt.optional && rt.optional) { return maybeNegate( - makeCall("__tact_slice_eq_bits_nullable", [ + call("__tact_slice_eq_bits_nullable", [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]), @@ -246,7 +245,7 @@ export class ExpressionGen { } if (lt.optional && !rt.optional) { return maybeNegate( - makeCall("__tact_slice_eq_bits_nullable_one", [ + call("__tact_slice_eq_bits_nullable_one", [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]), @@ -254,14 +253,14 @@ export class ExpressionGen { } if (!lt.optional && rt.optional) { return maybeNegate( - makeCall("__tact_slice_eq_bits_nullable_one", [ + call("__tact_slice_eq_bits_nullable_one", [ this.makeExpr(this.tactExpr.right), this.makeExpr(this.tactExpr.left), ]), ); } return maybeNegate( - makeCall("__tact_slice_eq_bits", [ + call("__tact_slice_eq_bits", [ this.makeExpr(this.tactExpr.right), this.makeExpr(this.tactExpr.left), ]), @@ -277,24 +276,24 @@ export class ExpressionGen { ) { const op = this.tactExpr.op === "==" ? "eq" : "neq"; if (lt.optional && rt.optional) { - return makeCall(`__tact_cell_${op}_nullable`, [ + return call(`__tact_cell_${op}_nullable`, [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]); } if (lt.optional && !rt.optional) { - return makeCall(`__tact_cell_${op}_nullable_one`, [ + return call(`__tact_cell_${op}_nullable_one`, [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]); } if (!lt.optional && rt.optional) { - return makeCall(`__tact_cell_${op}_nullable_one`, [ + return call(`__tact_cell_${op}_nullable_one`, [ this.makeExpr(this.tactExpr.right), this.makeExpr(this.tactExpr.left), ]); } - return makeCall(`__tact_cell_${op}`, [ + return call(`__tact_cell_${op}`, [ this.makeExpr(this.tactExpr.right), this.makeExpr(this.tactExpr.left), ]); @@ -309,24 +308,24 @@ export class ExpressionGen { ) { const op = this.tactExpr.op === "==" ? "eq" : "neq"; if (lt.optional && rt.optional) { - return makeCall(`__tact_slice_${op}_nullable`, [ + return call(`__tact_slice_${op}_nullable`, [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]); } if (lt.optional && !rt.optional) { - return makeCall(`__tact_slice_${op}_nullable_one`, [ + return call(`__tact_slice_${op}_nullable_one`, [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]); } if (!lt.optional && rt.optional) { - return makeCall(`__tact_slice_${op}_nullable_one`, [ + return call(`__tact_slice_${op}_nullable_one`, [ this.makeExpr(this.tactExpr.right), this.makeExpr(this.tactExpr.left), ]); } - return makeCall(`__tact_slice_${op}`, [ + return call(`__tact_slice_${op}`, [ this.makeExpr(this.tactExpr.right), this.makeExpr(this.tactExpr.left), ]); @@ -335,7 +334,7 @@ export class ExpressionGen { // Case for maps equality if (lt.kind === "map" && rt.kind === "map") { const op = this.tactExpr.op === "==" ? "eq" : "neq"; - return makeCall(`__tact_cell_${op}_nullable`, [ + return call(`__tact_cell_${op}_nullable`, [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]); @@ -359,27 +358,26 @@ export class ExpressionGen { if (this.tactExpr.op === "==" || this.tactExpr.op === "!=") { const op = this.tactExpr.op === "==" ? "eq" : "neq"; if (lt.optional && rt.optional) { - return makeCall(`__tact_int_${op}_nullable`, [ + return call(`__tact_int_${op}_nullable`, [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]); } if (lt.optional && !rt.optional) { - return makeCall(`__tact_int_${op}_nullable_one`, [ + return call(`__tact_int_${op}_nullable_one`, [ this.makeExpr(this.tactExpr.left), this.makeExpr(this.tactExpr.right), ]); } if (!lt.optional && rt.optional) { - return makeCall(`__tact_int_${op}_nullable_one`, [ + return call(`__tact_int_${op}_nullable_one`, [ this.makeExpr(this.tactExpr.right), this.makeExpr(this.tactExpr.left), ]); } - const binop = this.tactExpr.op === "==" ? "==" : "!="; - return makeBinop( + return binop( this.makeExpr(this.tactExpr.left), - binop, + this.tactExpr.op === "==" ? "==" : "!=", this.makeExpr(this.tactExpr.right), ); } @@ -411,7 +409,7 @@ export class ExpressionGen { } // Other ops - return makeBinop( + return binop( this.makeExpr(this.tactExpr.left), this.tactExpr.op, this.makeExpr(this.tactExpr.right), @@ -443,12 +441,12 @@ export class ExpressionGen { if (t.kind === "ref") { const tt = getType(this.ctx.ctx, t.name); if (tt.kind === "struct") { - return makeCall(ops.typeNotNull(tt.name), [ + return call(ops.typeNotNull(tt.name), [ this.makeExpr(this.tactExpr.operand), ]); } } - return makeCall("__tact_not_null", [ + return call("__tact_not_null", [ this.makeExpr(this.tactExpr.operand), ]); } @@ -502,7 +500,7 @@ export class ExpressionGen { if (field.type.kind === "ref") { const ft = getType(this.ctx.ctx, field.type.name); if (ft.kind === "struct" || ft.kind === "contract") { - return makeId( + return id( resolveFuncTypeUnpack( this.ctx.ctx, field.type, @@ -515,7 +513,7 @@ export class ExpressionGen { } // Getter instead of direct field access - return makeCall(ops.typeField(srcT.name, field.name), [ + return call(ops.typeField(srcT.name, field.name), [ this.makeExpr(this.tactExpr.aggregate), ]); } else { @@ -550,7 +548,7 @@ export class ExpressionGen { // } else { // // wCtx.used(n); // } - const fun = makeId(ops.global(idText(this.tactExpr.function))); + const fun = id(ops.global(idText(this.tactExpr.function))); const args = this.tactExpr.args.map((argAst, i) => this.makeCastedExpr(argAst, sf.params[i]!.type), ); @@ -579,7 +577,7 @@ export class ExpressionGen { src.fields.find((v2) => eqNames(v2.name, v.field))!.type, ), ); - return makeCall(constructor.name, args); + return call(constructor.name, args); } // @@ -661,7 +659,7 @@ export class ExpressionGen { methodFun.params[0]!.type.kind === "ref" && !methodFun.params[0]!.type.optional ) { - const fun = makeId(ops.typeTensorCast(tt.name)); + const fun = id(ops.typeTensorCast(tt.name)); argExprs = [ { kind: "call_expr", @@ -686,10 +684,10 @@ export class ExpressionGen { `Impossible self kind: ${selfExpr.kind}`, ); } - const fun = makeId(`${selfExpr}~${name}`); + const fun = id(`${selfExpr}~${name}`); return { kind: "call_expr", fun, args: argExprs }; } else { - const fun = makeId(ops.nonModifying(name)); + const fun = id(ops.nonModifying(name)); return { kind: "call_expr", fun, @@ -699,7 +697,7 @@ export class ExpressionGen { } else { return { kind: "call_expr", - fun: makeId(name), + fun: id(name), args: [selfExpr, ...argExprs], }; } @@ -741,22 +739,19 @@ export class ExpressionGen { // if (this.tactExpr.kind === "init_of") { const type = getType(this.ctx.ctx, this.tactExpr.contract); - return makeCall( - ops.contractInitChild(idText(this.tactExpr.contract)), - [ - makeId("__tact_context_sys"), - ...this.tactExpr.args.map((a, i) => - this.makeCastedExpr(a, type.init!.params[i]!.type), - ), - ], - ); + return call(ops.contractInitChild(idText(this.tactExpr.contract)), [ + id("__tact_context_sys"), + ...this.tactExpr.args.map((a, i) => + this.makeCastedExpr(a, type.init!.params[i]!.type), + ), + ]); } // // Ternary operator // if (this.tactExpr.kind === "conditional") { - return makeTernaryExpr( + return ternary( this.makeExpr(this.tactExpr.condition), this.makeExpr(this.tactExpr.thenBranch), this.makeExpr(this.tactExpr.elseBranch), diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 43e00f7a9..6566219a2 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -1,7 +1,7 @@ import { enabledInline } from "../config/features"; import { getType, resolveTypeRef } from "../types/resolveDescriptors"; import { ops, funcIdOf } from "./util"; -import { TypeDescription, FunctionDescription, InitDescription, TypeRef } from "../types/types"; +import { TypeDescription, FunctionDescription, TypeRef } from "../types/types"; import { FuncAstFunctionDefinition, FuncAstStmt, @@ -9,12 +9,7 @@ import { FuncAstExpr, FuncType, } from "../func/syntax"; -import { - makeId, - makeCall, - makeReturn, - makeFunction, -} from "../func/syntaxUtils"; +import { id, call, ret, fun } from "../func/syntaxConstructors"; import { StatementGen, ExpressionGen, CodegenContext } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; @@ -89,7 +84,9 @@ export class FunctionGen { /** * Generates Func function from the Tact funciton description. */ - public writeFunction(tactFun: FunctionDescription): FuncAstFunctionDefinition { + public writeFunction( + tactFun: FunctionDescription, + ): FuncAstFunctionDefinition { if (tactFun.ast.kind !== "function_def") { throw new Error(`Unknown function kind: ${tactFun.ast.kind}`); } @@ -145,7 +142,7 @@ export class FunctionGen { self, funcIdOf("self"), ); - const init: FuncAstExpr = makeId(funcIdOf("self")); + const init: FuncAstExpr = id(funcIdOf("self")); body.push({ kind: "var_def_stmt", name: varName, @@ -162,7 +159,7 @@ export class FunctionGen { resolveTypeRef(this.ctx.ctx, a.type), funcIdOf(a.name), ); - const init: FuncAstExpr = makeId(funcIdOf(a.name)); + const init: FuncAstExpr = id(funcIdOf(a.name)); body.push({ kind: "var_def_stmt", name, init, ty: undefined }); } } @@ -182,7 +179,7 @@ export class FunctionGen { body.push(funcStmt); }); - return makeFunction(attrs, name, params, returnTy, body); + return fun(attrs, name, params, returnTy, body); } /** @@ -222,7 +219,7 @@ export class FunctionGen { const values: FuncAstExpr[] = type.fields.map((v) => { const arg = args.find((v2) => v2 === v.name); if (arg) { - return makeId(avoidFunCKeywordNameClash(arg)); + return id(avoidFunCKeywordNameClash(arg)); } else if (v.default !== undefined) { return ExpressionGen.writeValue(this.ctx, v.default); } else { @@ -233,8 +230,8 @@ export class FunctionGen { }); const body = values.length === 0 && returnTy.kind === "tuple" - ? [makeReturn(makeCall("empty_tuple", []))] - : [makeReturn({ kind: "tensor_expr", values })]; - return makeFunction(attrs, name, params, returnTy, body); + ? [ret(call("empty_tuple", []))] + : [ret({ kind: "tensor_expr", values })]; + return fun(attrs, name, params, returnTy, body); } } diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index b6639b5ee..8cfe84b56 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -6,12 +6,12 @@ import { ContractABI } from "@ton/core"; import { FuncFormatter } from "../func/formatter"; import { FuncAstModule, FuncAstFunctionDefinition } from "../func/syntax"; import { - makeComment, - makeModule, - makePragma, - makeInclude, - declarationFromDefinition, -} from "../func/syntaxUtils"; + comment, + mod, + pragma, + include, + toDeclaration, +} from "../func/syntaxConstructors"; import { calculateIPFSlink } from "../utils/calculateIPFSlink"; export type GeneratedFilesInfo = { @@ -76,14 +76,14 @@ export class FuncGenerator { // Finalize and dump the main contract, as we have just obtained the structure of the project mainContract.entries.unshift( - ...generated.files.map((f) => makeInclude(f.name)), + ...generated.files.map((f) => include(f.name)), ); mainContract.entries.unshift( ...[ `version =${CODEGEN_FUNC_VERSION}`, "allow-post-modification", "compute-asm-ltr", - ].map(makePragma), + ].map(pragma), ); generated.files.push({ name: `${this.basename}.code.fc`, @@ -198,9 +198,9 @@ export class FuncGenerator { functions: FuncAstFunctionDefinition[], ): void { // FIXME: We should add only contract methods and special methods here => add attribute and register them in the context - const m = makeModule(); + const m = mod(); m.entries.push( - makeComment( + comment( "", `Header files for ${this.abiSrc.name}`, "NOTE: declarations are sorted for optimal order", @@ -209,13 +209,13 @@ export class FuncGenerator { ); functions.forEach((f) => { // if (f.code.kind === "generic") { - m.entries.push(makeComment(f.name)); + m.entries.push(comment(f.name)); if ( f.attrs.find((attr) => attr !== "impure" && attr !== "inline") ) { f.attrs.push("inline_ref"); } - m.entries.push(declarationFromDefinition(f)); + m.entries.push(toDeclaration(f)); // } }); generated.files.push({ diff --git a/src/codegen/module.ts b/src/codegen/module.ts index d21283b5f..cd833d069 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,24 +1,38 @@ -import { getAllTypes } from "../types/resolveDescriptors"; +import { getAllTypes, getType } from "../types/resolveDescriptors"; import { TypeDescription } from "../types/types"; import { getSortedTypes } from "../storage/resolveAllocation"; import { getSupportedInterfaces } from "../types/getSupportedInterfaces"; +import { ops } from "./util"; import { FuncAstModule, + FuncAstStmt, + FuncAstFunctionAttribute, + FuncType, FuncAstFunctionDefinition, FuncAstExpr, } from "../func/syntax"; import { - makeComment, - makeTensorExpr, - makeModule, - makeBinop, - makeNumberExpr, - makeCall, - makeFunction, - makeReturn, - makeStringExpr, -} from "../func/syntaxUtils"; + comment, + assign, + expr, + call, + binop, + bool, + number, + hexnumber, + string, + fun, + ret, + tensor, + Type, + varDef, + mod, + condition, + id, +} from "../func/syntaxConstructors"; +import { resolveFuncType } from "./type"; import { FunctionGen, CodegenContext } from "."; +import { beginCell } from "@ton/core"; /** * Encapsulates generation of the main Func compilation module from the main Tact module. @@ -41,33 +55,33 @@ export class ModuleGen { /** * Adds stdlib definitions to the generated module. */ - private addStdlib(m: FuncAstModule): void { + private addStdlib(_m: FuncAstModule): void { // TODO } - private addSerializers(m: FuncAstModule): void { + private addSerializers(_m: FuncAstModule): void { const sortedTypes = getSortedTypes(this.ctx.ctx); for (const t of sortedTypes) { } } - private addAccessors(m: FuncAstModule): void { + private addAccessors(_m: FuncAstModule): void { // TODO } - private addInitSerializer(m: FuncAstModule): void { + private addInitSerializer(_m: FuncAstModule): void { // TODO } - private addStorageFunctions(m: FuncAstModule): void { + private addStorageFunctions(_m: FuncAstModule): void { // TODO } - private addStaticFunctions(m: FuncAstModule): void { + private addStaticFunctions(_m: FuncAstModule): void { // TODO } - private addExtensions(m: FuncAstModule): void { + private addExtensions(_m: FuncAstModule): void { // TODO } @@ -88,14 +102,14 @@ export class ModuleGen { supported.push("org.ton.introspection.v0"); supported.push(...getSupportedInterfaces(type, this.ctx.ctx)); const shiftExprs: FuncAstExpr[] = supported.map((item) => - makeBinop(makeStringExpr(item, "H"), ">>", makeNumberExpr(128)), + binop(string(item, "H"), ">>", number(128)), ); - return makeFunction( + return fun( ["method_id"], "supported_interfaces", [], { kind: "hole" }, - [makeReturn(makeTensorExpr(...shiftExprs))], + [ret(tensor(...shiftExprs))], ); } @@ -104,7 +118,7 @@ export class ModuleGen { * TODO: Why do we need function from *all* the contracts? */ private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { - m.entries.push(makeComment("", `Contract ${c.name} functions`, "")); + m.entries.push(comment("", `Contract ${c.name} functions`, "")); for (const tactFun of c.functions.values()) { const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( @@ -486,9 +500,12 @@ export class ModuleGen { /** * Adds entries from the main Tact contract. */ - private writeMainContract(m: FuncAstModule, c: TypeDescription): void { + private writeMainContract( + m: FuncAstModule, + contractTy: TypeDescription, + ): void { m.entries.push( - makeComment("", `Receivers of a Contract ${c.name}`, ""), + comment("", `Receivers of a Contract ${contractTy.name}`, ""), ); // // Write receivers @@ -497,7 +514,7 @@ export class ModuleGen { // } m.entries.push( - makeComment("", `Get methods of a Contract ${c.name}`, ""), + comment("", `Get methods of a Contract ${contractTy.name}`, ""), ); // // Getters @@ -508,15 +525,15 @@ export class ModuleGen { // } // Interfaces - m.entries.push(this.writeInterfaces(c)); + m.entries.push(this.writeInterfaces(contractTy)); // ABI: // _ get_abi_ipfs() method_id { // return "${abiLink}"; // } m.entries.push( - makeFunction(["method_id"], "get_abi_ipfs", [], { kind: "hole" }, [ - makeReturn(makeStringExpr(this.abiLink)), + fun(["method_id"], "get_abi_ipfs", [], { kind: "hole" }, [ + ret(string(this.abiLink)), ]), ); @@ -525,36 +542,25 @@ export class ModuleGen { // return get_data().begin_parse().load_int(1); // } m.entries.push( - makeFunction( + fun( ["method_id"], "lazy_deployment_completed", [], { kind: "hole" }, - [ - makeReturn( - makeCall( - makeCall( - makeCall("load_init", [makeNumberExpr(1)]), - [], - ), - [], - ), - ), - ], + [ret(call(call(call("load_init", [number(1)]), []), []))], ), ); - // Comments - m.entries.push(makeComment("", `Routing of a Contract ${c.name}`, "")); - - // Render body - // const hasExternal = type.receivers.find((v) => - // v.selector.kind.startsWith("external-"), - // ); - // writeRouter(type, "internal", ctx); - // if (hasExternal) { - // writeRouter(type, "external", ctx); - // } + m.entries.push( + comment("", `Routing of a Contract ${contractTy.name}`, ""), + ); + const hasExternal = contractTy.receivers.find((v) => + v.selector.kind.startsWith("external-"), + ); + this.writeRouter(contractTy, "internal"); + if (hasExternal) { + this.writeRouter(contractTy, "external"); + } // // Render internal receiver // ctx.append( @@ -636,7 +642,7 @@ export class ModuleGen { } public writeAll(): FuncAstModule { - const m: FuncAstModule = makeModule(); + const m: FuncAstModule = mod(); const allTypes = Object.values(getAllTypes(this.ctx.ctx)); const contracts = allTypes.filter((v) => v.kind === "contract"); diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index dbd794936..4f7547d4c 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -16,17 +16,18 @@ import { FuncAstStmt, FuncAstConditionStmt, FuncAstExpr, - FuncAstTupleExpr, FuncAstUnitExpr, } from "../func/syntax"; import { - makeId, - makeExprStmt, - makeReturn, - makeTensorExpr, -} from "../func/syntaxUtils"; - -import JSONbig from "json-bigint"; + id, + expr, + ret, + tensor, + assign, + condition, + varDef, + Type, +} from "../func/syntaxConstructors"; /** * Encapsulates generation of Func statements from the Tact statement. @@ -75,54 +76,38 @@ export class StatementGen { this.selfName, this.returns, ).writeStatement(); - const condition = this.makeExpr(f.condition); + const cond = this.makeExpr(f.condition); const thenBlock = f.trueStatements.map(writeStmt); const elseStmt: FuncAstConditionStmt | undefined = f.falseStatements !== null && f.falseStatements.length > 0 - ? { - kind: "condition_stmt", - condition: undefined, - ifnot: false, - body: f.falseStatements.map(writeStmt), - else: undefined, - } + ? condition(undefined, f.falseStatements.map(writeStmt)) : f.elseif ? this.writeCondition(f.elseif) : undefined; - return { - kind: "condition_stmt", - condition, - ifnot: false, - body: thenBlock, - else: elseStmt, - }; + return condition(cond, thenBlock, false, elseStmt); } public writeStatement(): FuncAstStmt { switch (this.tactStmt.kind) { case "statement_return": { - const selfVar = this.selfName - ? makeId(this.selfName) - : undefined; + const selfVar = this.selfName ? id(this.selfName) : undefined; const getValue = (expr: FuncAstExpr): FuncAstExpr => - this.selfName ? makeTensorExpr(selfVar!, expr) : expr; + this.selfName ? tensor(selfVar!, expr) : expr; if (this.tactStmt.expression) { const castedReturns = this.makeCastedExpr( this.tactStmt.expression, this.returns!, ); - return makeReturn(getValue(castedReturns)); + return ret(getValue(castedReturns)); } else { const unit = { kind: "unit_expr" } as FuncAstUnitExpr; - return makeReturn(getValue(unit)); + return ret(getValue(unit)); } } case "statement_let": { // Underscore name case if (isWildcard(this.tactStmt.name)) { - return makeExprStmt( - this.makeExpr(this.tactStmt.expression), - ); + return expr(this.makeExpr(this.tactStmt.expression)); } // Contract/struct case @@ -140,12 +125,7 @@ export class StatementGen { this.tactStmt.expression, t, ); - return { - kind: "var_def_stmt", - name, - ty: { kind: "tuple" }, - init, - }; + return varDef(Type.tuple(), name, init); } else { const name = resolveFuncTypeUnpack( this.ctx.ctx, @@ -156,12 +136,7 @@ export class StatementGen { this.tactStmt.expression, t, ); - return { - kind: "var_def_stmt", - name, - ty: undefined, - init, - }; + return varDef(undefined, name, init); } } } @@ -169,7 +144,7 @@ export class StatementGen { const ty = resolveFuncType(this.ctx.ctx, t); const name = funcIdOf(this.tactStmt.name); const init = this.makeCastedExpr(this.tactStmt.expression, t); - return { kind: "var_def_stmt", name, ty, init }; + return varDef(ty, name, init); } case "statement_assign": { @@ -189,27 +164,19 @@ export class StatementGen { if (t.kind === "ref") { const tt = getType(this.ctx.ctx, t.name); if (tt.kind === "contract" || tt.kind === "struct") { - const lhs = makeId( + const lhs = id( resolveFuncTypeUnpack(this.ctx.ctx, t, path.value), ); const rhs = this.makeCastedExpr( this.tactStmt.expression, t, ); - return makeExprStmt({ - kind: "assign_expr", - lhs, - rhs, - }); + return expr(assign(lhs, rhs)); } } const rhs = this.makeCastedExpr(this.tactStmt.expression, t); - return makeExprStmt({ - kind: "assign_expr", - lhs: path, - rhs, - }); + return expr(assign(path, rhs)); } // case "statement_augmentedassign": { @@ -232,7 +199,7 @@ export class StatementGen { return this.writeCondition(this.tactStmt); } case "statement_expression": { - return makeExprStmt(this.makeExpr(this.tactStmt.expression)); + return expr(this.makeExpr(this.tactStmt.expression)); } // case "statement_while": { // ctx.append(`while (${writeExpression(f.condition, ctx)}) {`); diff --git a/src/codegen/type.ts b/src/codegen/type.ts index 74151719f..67639e2bd 100644 --- a/src/codegen/type.ts +++ b/src/codegen/type.ts @@ -2,6 +2,7 @@ import { CompilerContext } from "../context"; import { TypeDescription, TypeRef } from "../types/types"; import { getType } from "../types/resolveDescriptors"; import { FuncType, UNIT_TYPE } from "../func/syntax"; +import { Type } from "../func/syntaxConstructors"; /** * Unpacks string representation of a user-defined Tact type from its type description. @@ -132,7 +133,7 @@ export function resolveFuncType( ); } if (descriptor.kind === "map") { - return { kind: "cell" }; + return Type.cell(); } if (descriptor.kind === "ref_bounced") { return resolveFuncType(ctx, getType(ctx, descriptor.name), false, true); @@ -144,21 +145,21 @@ export function resolveFuncType( // TypeDescription if (descriptor.kind === "primitive_type_decl") { if (descriptor.name === "Int") { - return { kind: "int" }; + return Type.int(); } else if (descriptor.name === "Bool") { - return { kind: "int" }; + return Type.int(); } else if (descriptor.name === "Slice") { - return { kind: "slice" }; + return Type.slice(); } else if (descriptor.name === "Cell") { - return { kind: "cell" }; + return Type.cell(); } else if (descriptor.name === "Builder") { - return { kind: "builder" }; + return Type.builder(); } else if (descriptor.name === "Address") { - return { kind: "slice" }; + return Type.slice(); } else if (descriptor.name === "String") { - return { kind: "slice" }; + return Type.slice(); } else if (descriptor.name === "StringBuilder") { - return { kind: "tuple" }; + return Type.tuple(); } else { throw Error(`Unknown primitive type: ${descriptor.name}`); } @@ -167,25 +168,23 @@ export function resolveFuncType( ? descriptor.fields.slice(0, descriptor.partialFieldCount) : descriptor.fields; if (optional || fieldsToUse.length === 0) { - return { kind: "tuple" }; + return Type.tuple(); } else { - return { - kind: "tensor", - value: fieldsToUse.map((v) => + return Type.tensor( + ...fieldsToUse.map((v) => resolveFuncType(ctx, v.type, false, usePartialFields), ), - }; + ); } } else if (descriptor.kind === "contract") { if (optional || descriptor.fields.length === 0) { - return { kind: "tuple" }; + return Type.tuple(); } else { - return { - kind: "tensor", - value: descriptor.fields.map((v) => + return Type.tensor( + ...descriptor.fields.map((v) => resolveFuncType(ctx, v.type, false, usePartialFields), ), - }; + ); } } diff --git a/src/codegen/util.ts b/src/codegen/util.ts index 5d7dad693..8b209cca2 100644 --- a/src/codegen/util.ts +++ b/src/codegen/util.ts @@ -1,7 +1,8 @@ import { getType } from "../types/resolveDescriptors"; import { CompilerContext } from "../context"; import { TypeRef } from "../types/types"; -import { FuncAstExpr, FuncAstIdExpr } from "../func/syntax"; +import { FuncAstExpr } from "../func/syntax"; +import { id, call } from "../func/syntaxConstructors"; import { AstId, idText } from "../grammar/ast"; export const ops = { @@ -74,11 +75,7 @@ export function cast( if (!from.optional && to.optional) { const type = getType(ctx, from.name); if (type.kind === "struct") { - const fun = { - kind: "id_expr", - value: ops.typeAsOptional(type.name), - } as FuncAstIdExpr; - return { kind: "call_expr", fun, args: [expr] }; + return call(id(ops.typeAsOptional(type.name)), [expr]); } } } diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 49ba98dab..6c46bf812 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -50,41 +50,41 @@ import { // Types // export class Type { - public static int(): FuncType { - return { kind: "int" }; - } + public static int(): FuncType { + return { kind: "int" }; + } - public static cell(): FuncType { - return { kind: "cell" }; - } + public static cell(): FuncType { + return { kind: "cell" }; + } - public static slice(): FuncType { - return { kind: "slice" }; - } + public static slice(): FuncType { + return { kind: "slice" }; + } - public static builder(): FuncType { - return { kind: "builder" }; - } + public static builder(): FuncType { + return { kind: "builder" }; + } - public static cont(): FuncType { - return { kind: "cont" }; - } + public static cont(): FuncType { + return { kind: "cont" }; + } - public static tuple(): FuncType { - return { kind: "tuple" }; - } + public static tuple(): FuncType { + return { kind: "tuple" }; + } - public static tensor(...value: FuncType[]): FuncType { - return { kind: "tensor", value }; - } + public static tensor(...value: FuncType[]): FuncType { + return { kind: "tensor", value }; + } - public static hole(): FuncType { - return { kind: "hole" }; - } + public static hole(): FuncType { + return { kind: "hole" }; + } - public static type(): FuncType { - return { kind: "type" }; - } + public static type(): FuncType { + return { kind: "type" }; + } } // @@ -257,8 +257,8 @@ export const repeat = ( export const condition = ( condition: FuncAstExpr | undefined, - ifnot: boolean, body: FuncAstStmt[], + ifnot: boolean = false, elseStmt?: FuncAstConditionStmt, ): FuncAstConditionStmt => ({ kind: "condition_stmt", @@ -396,7 +396,7 @@ export const globalVariable = ( export const moduleEntry = (entry: FuncAstModuleEntry): FuncAstModuleEntry => entry; -export const module = (...entries: FuncAstModuleEntry[]): FuncAstModule => ({ +export const mod = (...entries: FuncAstModuleEntry[]): FuncAstModule => ({ kind: "module", entries, }); diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts deleted file mode 100644 index b54f73dae..000000000 --- a/src/func/syntaxUtils.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { - FuncAstExpr, - FuncAstIdExpr, - FuncAstStringExpr, - FuncAstNumberExpr, - FuncStringLiteralType, - FuncAstModuleEntry, - FuncAstModule, - FuncAstTernaryExpr, - FuncAstPragma, - FuncAstTensorExpr, - FuncAstInclude, - FuncAstFunctionAttribute, - FuncAstFormalFunctionParam, - FuncAstComment, - FuncAstFunctionDefinition, - FuncAstFunctionDeclaration, - FuncType, - FuncAstCallExpr, - FuncAstBinaryOp, - FuncAstStmt, -} from "./syntax"; - -export function makeId(value: string): FuncAstIdExpr { - return { kind: "id_expr", value }; -} - -export function makeStringExpr( - value: string, - ty?: FuncStringLiteralType, -): FuncAstStringExpr { - return { kind: "string_expr", value, ty }; -} - -export function makeNumberExpr(num: bigint | number): FuncAstNumberExpr { - return { - kind: "number_expr", - value: typeof num === "bigint" ? num : BigInt(num), - }; -} - -export function makeCall( - fun: FuncAstExpr | string, - args: FuncAstExpr[], -): FuncAstCallExpr { - return { - kind: "call_expr", - fun: typeof fun === "string" ? makeId(fun) : fun, - args, - }; -} - -export function makeExprStmt(expr: FuncAstExpr): FuncAstStmt { - return { kind: "expr_stmt", expr }; -} - -export function makeAssign(lhs: FuncAstExpr, rhs: FuncAstExpr): FuncAstExpr { - return { kind: "assign_expr", lhs, rhs }; -} - -export function makeBinop( - lhs: FuncAstExpr, - op: FuncAstBinaryOp, - rhs: FuncAstExpr, -): FuncAstExpr { - return { kind: "binary_expr", lhs, op, rhs }; -} - -export function makeReturn(value: FuncAstExpr | undefined): FuncAstStmt { - return { kind: "return_stmt", value }; -} - -export function makeFunction( - attrs: FuncAstFunctionAttribute[], - name: string, - paramValues: [string, FuncType][], - returnTy: FuncType, - body: FuncAstStmt[], -): FuncAstFunctionDefinition { - const params = paramValues.map(([name, ty]) => { - return { - kind: "function_param", - name, - ty, - } as FuncAstFormalFunctionParam; - }); - return { kind: "function_definition", attrs, name, params, returnTy, body }; -} - -export function declarationFromDefinition( - def: FuncAstFunctionDefinition, -): FuncAstFunctionDeclaration { - return { - kind: "function_declaration", - attrs: def.attrs, - name: def.name, - params: def.params, - returnTy: def.returnTy, - }; -} - -export function makeComment(...values: string[]): FuncAstComment { - return { kind: "comment", values }; -} - -export function makePragma(value: string): FuncAstPragma { - return { kind: "pragma", value }; -} - -export function makeInclude(value: string): FuncAstInclude { - return { kind: "include", value }; -} - -export function makeTensorExpr(...values: FuncAstExpr[]): FuncAstTensorExpr { - return { kind: "tensor_expr", values }; -} - -export function makeTernaryExpr( - cond: FuncAstExpr, - trueExpr: FuncAstExpr, - falseExpr: FuncAstExpr, -): FuncAstTernaryExpr { - return { kind: "ternary_expr", cond, trueExpr, falseExpr }; -} - -export function makeModule(entries: FuncAstModuleEntry[] = []): FuncAstModule { - return { kind: "module", entries }; -} From 96114762d61173f76a9fba4c3de9a153120270e1 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 18 Jul 2024 02:10:00 +0000 Subject: [PATCH 037/162] feat(syntax): Support different comment styles --- src/codegen/generator.ts | 2 +- src/codegen/module.ts | 4 ++-- src/func/formatter.ts | 23 ++++++++++++++++++++--- src/func/syntax.ts | 4 +++- src/func/syntaxConstructors.ts | 22 ++++++++++++++++++---- 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 8cfe84b56..f8690cf07 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -209,7 +209,7 @@ export class FuncGenerator { ); functions.forEach((f) => { // if (f.code.kind === "generic") { - m.entries.push(comment(f.name)); + m.entries.push(comment(f.name, { skipCR: true })); if ( f.attrs.find((attr) => attr !== "impure" && attr !== "inline") ) { diff --git a/src/codegen/module.ts b/src/codegen/module.ts index cd833d069..e554f5044 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -557,9 +557,9 @@ export class ModuleGen { const hasExternal = contractTy.receivers.find((v) => v.selector.kind.startsWith("external-"), ); - this.writeRouter(contractTy, "internal"); + m.entries.push(this.writeRouter(contractTy, "internal")); if (hasExternal) { - this.writeRouter(contractTy, "external"); + m.entries.push(this.writeRouter(contractTy, "external")); } // // Render internal receiver diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 997f3676b..95b2d7b7b 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -159,7 +159,14 @@ export class FuncFormatter { previousEntry && previousEntry.kind === entry.kind && (entry.kind === "include" || entry.kind === "pragma"); - const separator = isSequentialPragmaOrInclude ? "\n" : "\n\n"; + const isPreviousCommentSkipCR = + previousEntry && + previousEntry.kind === "comment" && + (previousEntry as FuncAstComment).skipCR; + const separator = + isSequentialPragmaOrInclude || isPreviousCommentSkipCR + ? "\n" + : "\n\n"; return (index > 0 ? separator : "") + this.dump(entry); }) .join(""); @@ -218,7 +225,17 @@ export class FuncFormatter { private formatBlockStmt(node: FuncAstBlockStmt): string { const body = this.formatIndentedBlock( - node.body.map((stmt) => this.dump(stmt)).join("\n"), + node.body + .map((stmt, index) => { + const previousStmt = node.body[index - 1]; + const isPreviousCommentSkipCR = + previousStmt && + previousStmt.kind === "comment" && + (previousStmt as FuncAstComment).skipCR; + const separator = isPreviousCommentSkipCR ? "" : "\n"; + return (index > 0 ? separator : "") + this.dump(stmt); + }) + .join(""), ); return `{\n${body}\n}`; } @@ -387,7 +404,7 @@ export class FuncFormatter { } private formatComment(node: FuncAstComment): string { - return node.values.map((v) => `;; ${v}`).join("\n"); + return node.values.map((v) => `${node.style} ${v}`).join("\n"); } private formatType(node: FuncType): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 092977f56..fea4d2f77 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -240,7 +240,7 @@ export type FuncAstPrimitiveTypeExpr = { // export type FuncAstStmt = - | FuncAstComment // a comment appearing among statements + | FuncAstComment // A comment appearing among statements | FuncAstBlockStmt | FuncAstVarDefStmt | FuncAstReturnStmt @@ -351,6 +351,8 @@ export type FuncAstFunctionDefinition = { export type FuncAstComment = { kind: "comment"; values: string[]; // Represents multiline comments + skipCR: boolean; // Skips CR before the next line + style: ";" | ";;"; }; export type FuncAstInclude = { diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 6c46bf812..51be1ddb5 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -304,10 +304,24 @@ export const tryCatch = ( // Other top-level elements -export const comment = (...values: string[]): FuncAstComment => ({ - kind: "comment", - values, -}); +export function comment( + ...args: (string | Partial<{ skipCR: boolean; style: ";" | ";;" }>)[] +): FuncAstComment { + let params: Partial<{ skipCR: boolean; style: ";" | ";;" }> = {}; + let values: string[]; + + if (args.length > 0 && typeof args[args.length - 1] === "object") { + params = args.pop() as Partial<{ skipCR: boolean; style: ";" | ";;" }>; + } + values = args as string[]; + const { skipCR = false, style = ";;" } = params; + return { + kind: "comment", + values, + skipCR, + style, + }; +} export const constant = (ty: FuncType, init: FuncAstExpr): FuncAstConstant => ({ kind: "constant", From c8ce46a970461ccb256beed27fcc90fb66ffe257 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 18 Jul 2024 02:10:50 +0000 Subject: [PATCH 038/162] chore(syntax): %s/varDef/vardef/g for consistency --- src/codegen/module.ts | 12 ++++++------ src/codegen/statement.ts | 8 ++++---- src/func/syntaxConstructors.ts | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index e554f5044..1b825fcf2 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -25,7 +25,7 @@ import { ret, tensor, Type, - varDef, + vardef, mod, condition, id, @@ -194,7 +194,7 @@ export class ModuleGen { // op = in_msg.preload_uint(32); // } condBody.push(comment("Parse op")); - condBody.push(varDef(Type.int(), "op", number(0))); + condBody.push(vardef(Type.int(), "op", number(0))); condBody.push( condition( binop( @@ -234,7 +234,7 @@ export class ModuleGen { ), ), [ - varDef( + vardef( undefined, "msg", call( @@ -284,7 +284,7 @@ export class ModuleGen { // op = in_msg.preload_uint(32); // } functionBody.push(comment("Parse incoming message")); - functionBody.push(varDef(Type.int(), "op", number(0))); + functionBody.push(vardef(Type.int(), "op", number(0))); functionBody.push( condition( binop(call(id("slice_bits"), [id("in_msg")]), ">=", number(32)), @@ -317,7 +317,7 @@ export class ModuleGen { condition( binop(id("op"), "==", number(allocation.header)), [ - varDef( + vardef( undefined, "msg", call(`in_msg~${ops.reader(selector.type)}`, []), @@ -393,7 +393,7 @@ export class ModuleGen { ) { // var text_op = slice_hash(in_msg); condBody.push( - varDef( + vardef( undefined, "text_op", call("slice_hash", [id("in_msg")]), diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index 4f7547d4c..74fca81a6 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -25,7 +25,7 @@ import { tensor, assign, condition, - varDef, + vardef, Type, } from "../func/syntaxConstructors"; @@ -125,7 +125,7 @@ export class StatementGen { this.tactStmt.expression, t, ); - return varDef(Type.tuple(), name, init); + return vardef(Type.tuple(), name, init); } else { const name = resolveFuncTypeUnpack( this.ctx.ctx, @@ -136,7 +136,7 @@ export class StatementGen { this.tactStmt.expression, t, ); - return varDef(undefined, name, init); + return vardef(undefined, name, init); } } } @@ -144,7 +144,7 @@ export class StatementGen { const ty = resolveFuncType(this.ctx.ctx, t); const name = funcIdOf(this.tactStmt.name); const init = this.makeCastedExpr(this.tactStmt.expression, t); - return varDef(ty, name, init); + return vardef(ty, name, init); } case "statement_assign": { diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 51be1ddb5..92fdc6d82 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -225,7 +225,7 @@ export const primitiveType = (ty: FuncType): FuncAstPrimitiveTypeExpr => ({ // Statements // -export const varDef = ( +export const vardef = ( ty: FuncType | undefined, name: string, init?: FuncAstExpr, From e9a01665fbb2628a0cc4464c01d6ff001eb518c5 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 18 Jul 2024 02:23:47 +0000 Subject: [PATCH 039/162] feat(syntax): Utilize `FuncAstIdExpr` for names instead of raw strings --- src/codegen/function.ts | 11 +++-------- src/codegen/generator.ts | 2 +- src/func/formatter.ts | 16 +++++++++------- src/func/syntax.ts | 12 ++++++------ src/func/syntaxConstructors.ts | 32 ++++++++++++++++++-------------- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 6566219a2..8724842e2 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -9,7 +9,7 @@ import { FuncAstExpr, FuncType, } from "../func/syntax"; -import { id, call, ret, fun } from "../func/syntaxConstructors"; +import { id, call, ret, fun, vardef } from "../func/syntaxConstructors"; import { StatementGen, ExpressionGen, CodegenContext } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; @@ -143,12 +143,7 @@ export class FunctionGen { funcIdOf("self"), ); const init: FuncAstExpr = id(funcIdOf("self")); - body.push({ - kind: "var_def_stmt", - name: varName, - init, - ty: undefined, - }); + body.push(vardef(undefined, varName, init)); } for (const a of tactFun.ast.params) { if ( @@ -160,7 +155,7 @@ export class FunctionGen { funcIdOf(a.name), ); const init: FuncAstExpr = id(funcIdOf(a.name)); - body.push({ kind: "var_def_stmt", name, init, ty: undefined }); + body.push(vardef(undefined, name, init)); } } diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index f8690cf07..afc5e3264 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -209,7 +209,7 @@ export class FuncGenerator { ); functions.forEach((f) => { // if (f.code.kind === "generic") { - m.entries.push(comment(f.name, { skipCR: true })); + m.entries.push(comment(f.name.value, { skipCR: true })); if ( f.attrs.find((attr) => attr !== "impure" && attr !== "inline") ) { diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 95b2d7b7b..76087daaa 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -173,15 +173,15 @@ export class FuncFormatter { } private formatFunctionSignature( - name: string, + name: FuncAstIdExpr, attrs: FuncAstFunctionAttribute[], params: FuncAstFormalFunctionParam[], returnTy: FuncType, ): string { const attrsStr = attrs.join(" "); - const nameStr = name; + const nameStr = this.dump(name); const paramsStr = params - .map((param) => `${this.dump(param.ty)} ${param.name}`) + .map((param) => `${this.dump(param.ty)} ${this.dump(param.name)}`) .join(", "); const returnTypeStr = this.dump(returnTy); return `${returnTypeStr} ${nameStr}(${paramsStr}) ${attrsStr}`; @@ -213,9 +213,10 @@ export class FuncFormatter { } private formatVarDefStmt(node: FuncAstVarDefStmt): string { - const type = node.ty ? `: ${this.dump(node.ty)} ` : ""; + const name = this.dump(node.name); + const type = node.ty ? `: ${this.dump(node.ty)} ` : "var "; const init = node.init ? ` = ${this.dump(node.init)}` : ""; - return `var ${node.name}${type}${init};`; + return `${type} ${name}${init};`; } private formatReturnStmt(node: FuncAstReturnStmt): string { @@ -287,7 +288,7 @@ export class FuncFormatter { const catchBlock = this.formatIndentedBlock( node.catchBlock.map((stmt) => this.dump(stmt)).join("\n"), ); - const catchVar = node.catchVar ? ` (${node.catchVar})` : ""; + const catchVar = node.catchVar ? ` (${this.dump(node.catchVar)})` : ""; return `try {\n${tryBlock}\n} catch${catchVar} {\n${catchBlock}\n}`; } @@ -298,8 +299,9 @@ export class FuncFormatter { } private formatGlobalVariable(node: FuncAstGlobalVariable): string { + const name = this.dump(node.name); const type = this.dump(node.ty); - return `global ${type} ${node.name};`; + return `global ${type} ${name};`; } private formatCallExpr(node: FuncAstCallExpr): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index fea4d2f77..22e13a500 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -256,7 +256,7 @@ export type FuncAstStmt = // var x = 2; // ty is undefined export type FuncAstVarDefStmt = { kind: "var_def_stmt"; - name: string; + name: FuncAstIdExpr; ty: FuncType | undefined; init: FuncAstExpr | undefined; }; @@ -306,7 +306,7 @@ export type FuncAstTryCatchStmt = { kind: "try_catch_stmt"; tryBlock: FuncAstStmt[]; catchBlock: FuncAstStmt[]; - catchVar: string | null; + catchVar: FuncAstIdExpr | undefined; }; // @@ -327,13 +327,13 @@ export type FuncAstFunctionAttribute = export type FuncAstFormalFunctionParam = { kind: "function_param"; - name: string; + name: FuncAstIdExpr; ty: FuncType; }; export type FuncAstFunctionDeclaration = { kind: "function_declaration"; - name: string; + name: FuncAstIdExpr; attrs: FuncAstFunctionAttribute[]; params: FuncAstFormalFunctionParam[]; returnTy: FuncType; @@ -341,7 +341,7 @@ export type FuncAstFunctionDeclaration = { export type FuncAstFunctionDefinition = { kind: "function_definition"; - name: string; + name: FuncAstIdExpr; attrs: FuncAstFunctionAttribute[]; params: FuncAstFormalFunctionParam[]; returnTy: FuncType; @@ -367,7 +367,7 @@ export type FuncAstPragma = { export type FuncAstGlobalVariable = { kind: "global_variable"; - name: string; + name: FuncAstIdExpr; ty: FuncType; }; diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 92fdc6d82..94d3e2949 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -46,6 +46,10 @@ import { FuncAstModule, } from "./syntax"; +function wrapToId(v: T | string): T { + return typeof v === "string" ? (id(v) as T) : v; +} + // // Types // @@ -129,7 +133,7 @@ export const call = ( args: FuncAstExpr[], ): FuncAstCallExpr => ({ kind: "call_expr", - fun: typeof fun === "string" ? id(fun) : fun, + fun: wrapToId(fun), args, }); @@ -227,11 +231,11 @@ export const primitiveType = (ty: FuncType): FuncAstPrimitiveTypeExpr => ({ export const vardef = ( ty: FuncType | undefined, - name: string, + name: string | FuncAstIdExpr, init?: FuncAstExpr, ): FuncAstVarDefStmt => ({ kind: "var_def_stmt", - name, + name: wrapToId(name), ty, init, }); @@ -294,12 +298,12 @@ export const expr = (expr: FuncAstExpr): FuncAstExprStmt => ({ export const tryCatch = ( tryBlock: FuncAstStmt[], catchBlock: FuncAstStmt[], - catchVar: string | null, + catchVar?: string | FuncAstIdExpr, ): FuncAstTryCatchStmt => ({ kind: "try_catch_stmt", tryBlock, catchBlock, - catchVar, + catchVar: catchVar === undefined ? undefined : wrapToId(catchVar), }); // Other top-level elements @@ -330,22 +334,22 @@ export const constant = (ty: FuncType, init: FuncAstExpr): FuncAstConstant => ({ }); export const functionParam = ( - name: string, + name: string | FuncAstIdExpr, ty: FuncType, ): FuncAstFormalFunctionParam => ({ kind: "function_param", - name, + name: wrapToId(name), ty, }); export const functionDeclaration = ( - name: string, + name: string | FuncAstIdExpr, attrs: FuncAstFunctionAttribute[], params: FuncAstFormalFunctionParam[], returnTy: FuncType, ): FuncAstFunctionDeclaration => ({ kind: "function_declaration", - name, + name: wrapToId(name), attrs, params, returnTy, @@ -353,7 +357,7 @@ export const functionDeclaration = ( export const fun = ( attrs: FuncAstFunctionAttribute[], - name: string, + name: string | FuncAstIdExpr, paramValues: [string, FuncType][], returnTy: FuncType, body: FuncAstStmt[], @@ -362,13 +366,13 @@ export const fun = ( ([name, ty]) => ({ kind: "function_param", - name, + name: wrapToId(name), ty, }) as FuncAstFormalFunctionParam, ); return { kind: "function_definition", - name, + name: wrapToId(name), attrs, params, returnTy, @@ -399,11 +403,11 @@ export const pragma = (value: string): FuncAstPragma => ({ }); export const globalVariable = ( - name: string, + name: string | FuncAstIdExpr, ty: FuncType, ): FuncAstGlobalVariable => ({ kind: "global_variable", - name, + name: wrapToId(name), ty, }); From 571b126d2547745c2e9fdd8720e90a77f281c007 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 18 Jul 2024 05:13:21 +0000 Subject: [PATCH 040/162] feat(tests): Differential tests based on jest' diff utility --- .gitignore | 1 + src/codegen/codegen.spec.ts | 178 ++++++++++++++++++++++++++++++ src/codegen/contracts/Simple.tact | 5 + src/pipeline/compile.ts | 11 +- 4 files changed, 190 insertions(+), 5 deletions(-) create mode 100644 src/codegen/codegen.spec.ts create mode 100644 src/codegen/contracts/Simple.tact diff --git a/.gitignore b/.gitignore index 7ffdeb777..505434aed 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ output/ src/grammar/grammar.ohm-bundle.js src/grammar/grammar.ohm-bundle.d.ts src/func/funcfiftlib.wasm.js +src/codegen/contracts/*.config.json diff --git a/src/codegen/codegen.spec.ts b/src/codegen/codegen.spec.ts new file mode 100644 index 000000000..d16d395d9 --- /dev/null +++ b/src/codegen/codegen.spec.ts @@ -0,0 +1,178 @@ +import * as fs from "fs"; +import * as path from "path"; + +import { __DANGER_resetNodeId } from "../grammar/ast"; +import { compile } from "../pipeline/compile"; +import { precompile } from "../pipeline/precompile"; +import { getContracts } from "../types/resolveDescriptors"; +import { CompilationOutput, CompilationResults } from "../pipeline/compile"; +import { createNodeFileSystem } from "../vfs/createNodeFileSystem"; +import { CompilerContext } from "../context"; + +const CONTRACTS_DIR = path.join(__dirname, "./contracts/"); + +function capitalize(str: string): string { + if (str.length === 0) return str; + return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); +} + +/** + * Generates a Tact configuration file for the given contract (imported from Misti). + */ +export function generateConfig(contractName: string): string { + const config = { + projects: [ + { + name: `${contractName}`, + path: `./${contractName}.tact`, + output: `./output`, + options: {}, + }, + ], + }; + const configPath = path.join(CONTRACTS_DIR, `${contractName}.config.json`); + fs.writeFileSync(configPath, JSON.stringify(config), { + encoding: "utf8", + flag: "w", + }); + return configPath; +} + +/** + * Compiles the contract on the given filepath to CompilationResults replicating the Tact compiler pipeline. + */ +async function compileContract( + backend: "new" | "old", + contractName: string, +): Promise { + const _ = generateConfig(contractName); + + // see: pipeline/build.ts + const project = createNodeFileSystem(CONTRACTS_DIR, false); + const stdlib = createNodeFileSystem( + path.resolve(__dirname, "..", "..", "stdlib"), + false, + ); + let ctx: CompilerContext = new CompilerContext({ shared: {} }); + ctx = precompile(ctx, project, stdlib, contractName); + + return await Promise.all( + getContracts(ctx).map(async (contract) => { + const res = await compile( + ctx, + contract, + `${contractName}_${contract}`, + backend, + ); + return res; + }), + ); +} + +function compareCompilationOutputs( + newOut: CompilationOutput, + oldOut: CompilationOutput, +): void { + const errors: string[] = []; + + if (newOut === undefined || oldOut === undefined) { + errors.push("One of the outputs is undefined."); + } else { + try { + expect(newOut.entrypoint).toBe(oldOut.entrypoint); + } catch (error) { + if (error instanceof Error) { + errors.push(`Entrypoint mismatch: ${error.message}`); + } else { + errors.push(`Entrypoint mismatch: ${String(error)}`); + } + } + + try { + expect(newOut.abi).toBe(oldOut.abi); + } catch (error) { + if (error instanceof Error) { + errors.push(`ABI mismatch: ${error.message}`); + } else { + errors.push(`ABI mismatch: ${String(error)}`); + } + } + + const unmatchedFiles = new Set(oldOut.files.map((file) => file.name)); + + for (const newFile of newOut.files) { + const oldFile = oldOut.files.find( + (file) => file.name === newFile.name, + ); + if (oldFile) { + unmatchedFiles.delete(oldFile.name); + try { + expect(newFile.code).toBe(oldFile.code); + } catch (error) { + if (error instanceof Error) { + errors.push( + `Code mismatch in file ${newFile.name}: ${error.message}`, + ); + } else { + errors.push( + `Code mismatch in file ${newFile.name}: ${String(error)}`, + ); + } + } + } else { + errors.push( + `File ${newFile.name} is missing in the old output.`, + ); + } + } + + for (const missingFile of unmatchedFiles) { + errors.push(`File ${missingFile} is missing in the new output.`); + } + } + + if (errors.length > 0) { + throw new Error(errors.join("\n")); + } +} + +describe("codegen", () => { + beforeEach(async () => { + __DANGER_resetNodeId(); + }); + + fs.readdirSync(CONTRACTS_DIR).forEach((file) => { + if (!file.endsWith(".tact")) { + return; + } + const contractName = capitalize(file); + // Differential tests with the old backend + it(`Should compile the ${file} contract`, async () => { + Promise.all([ + compileContract("new", contractName), + compileContract("old", contractName), + ]) + .then(([resultsNew, resultsOld]) => { + if (resultsNew.length !== resultsOld.length) { + throw new Error("Not all contracts have been compiled"); + } + const zipped = resultsNew.map((value, idx) => [ + value, + resultsOld[idx], + ]); + zipped.forEach(([newRes, oldRes]) => { + compareCompilationOutputs( + newRes!.output, + oldRes!.output, + ); + }); + }) + .catch((error) => { + console.error( + "An error occurred during compilation:", + error, + ); + }); + }); + }); +}); diff --git a/src/codegen/contracts/Simple.tact b/src/codegen/contracts/Simple.tact new file mode 100644 index 000000000..4e06edb30 --- /dev/null +++ b/src/codegen/contracts/Simple.tact @@ -0,0 +1,5 @@ +contract A { + get fun foo(): Int { + return 1; + } +} diff --git a/src/pipeline/compile.ts b/src/pipeline/compile.ts index 0b98e854a..04c6668a3 100644 --- a/src/pipeline/compile.ts +++ b/src/pipeline/compile.ts @@ -24,10 +24,11 @@ export async function compile( ctx: CompilerContext, contractName: string, abiName: string, + backend: "new" | "old" = "old", ): Promise { const abi = createABI(ctx, contractName); let output: CompilationOutput; - if (process.env.NEW_CODEGEN === "1") { + if (backend === "new" || process.env.NEW_CODEGEN === "1") { output = await FuncGenerator.fromTactProject( ctx, abi, @@ -36,9 +37,9 @@ export async function compile( } else { output = await writeProgram(ctx, abi, abiName); } - console.log(`${contractName} output:`); - output.files.forEach((o) => - console.log(`---------------\nname=${o.name}; code:\n${o.code}\n`), - ); + // console.log(`${contractName} output:`); + // output.files.forEach((o) => + // console.log(`---------------\nname=${o.name}; code:\n${o.code}\n`), + // ); return { output, ctx }; } From f557114f1e7bf9d1ef3c82e8e187dfb13ba9a8d0 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 18 Jul 2024 05:22:10 +0000 Subject: [PATCH 041/162] fix(fmt): Minor fixes --- src/func/formatter.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 76087daaa..d5034f268 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -214,7 +214,7 @@ export class FuncFormatter { private formatVarDefStmt(node: FuncAstVarDefStmt): string { const name = this.dump(node.name); - const type = node.ty ? `: ${this.dump(node.ty)} ` : "var "; + const type = node.ty ? this.dump(node.ty) : "var"; const init = node.init ? ` = ${this.dump(node.init)}` : ""; return `${type} ${name}${init};`; } @@ -250,7 +250,9 @@ export class FuncFormatter { } private formatConditionStmt(node: FuncAstConditionStmt): string { - const condition = node.condition ? this.dump(node.condition) : ""; + const condition = node.condition + ? `(${this.dump(node.condition)})` + : ""; const ifnot = node.ifnot ? "ifnot" : "if"; const bodyBlock = this.formatIndentedBlock( node.body.map((stmt) => this.dump(stmt)).join("\n"), From 29701e6c38221812328c04ccf6d048ad4c498e71 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 18 Jul 2024 05:24:23 +0000 Subject: [PATCH 042/162] fix(fmt): Trailing whitespaces in comments --- src/func/formatter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index d5034f268..8e3eef24a 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -408,7 +408,9 @@ export class FuncFormatter { } private formatComment(node: FuncAstComment): string { - return node.values.map((v) => `${node.style} ${v}`).join("\n"); + return node.values + .map((v) => `${node.style}${v.length > 0 ? " " + v : ""}`) + .join("\n"); } private formatType(node: FuncType): string { From 93932d446c2712eb834889e720f0c2ba99474b66 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 18 Jul 2024 05:25:52 +0000 Subject: [PATCH 043/162] fix(codegen): Typo --- src/codegen/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 1b825fcf2..cc1f5a924 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -292,7 +292,7 @@ export class ModuleGen { expr( assign( id("op"), - call("in_msg.preload_unit", [number(32)]), + call("in_msg.preload_uint", [number(32)]), ), ), ], From 59c5202497051348c4832b05fdcd27c812f08b15 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 00:37:53 +0000 Subject: [PATCH 044/162] feat(formatter): line length limit + multiline tensor expressions --- src/func/formatter.ts | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 8e3eef24a..31fa65057 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -46,10 +46,21 @@ import JSONbig from "json-bigint"; * Provides utilities to print the generated Func AST. */ export class FuncFormatter { + /** + * Limit for the length of a single line. + * @default 100 + */ + private lineLengthLimit: number; + /** + * Number of spaces used for identation. + * @default 4 + */ private indent: number; private currentIndent: number; - constructor(indent: number = 4) { + constructor( params: Partial<{ indent: number, lineLengthLimit: number }> = {},) { + const { indent= 4, lineLengthLimit= 100 } = params; + this.lineLengthLimit = lineLengthLimit; this.indent = indent; this.currentIndent = 0; } @@ -377,8 +388,17 @@ export class FuncFormatter { } private formatTensorExpr(node: FuncAstTensorExpr): string { - const values = node.values.map((value) => this.dump(value)).join(", "); - return `(${values})`; + const values = node.values.map((value) => this.dump(value)); + const singleLine = `(${values.join(", ")})`; + + if (singleLine.length <= this.lineLengthLimit) { + return singleLine; + } else { + const indentedValues = values + .map((value) => this.indentLine(value)) + .join(",\n"); + return `(\n${indentedValues}\n${" ".repeat(this.currentIndent)})`; + } } private formatUnitExpr(_: FuncAstUnitExpr): string { @@ -434,6 +454,10 @@ export class FuncFormatter { } } + private indentLine(line: string): string { + return " ".repeat(this.currentIndent + this.indent) + line; + } + private formatIndentedBlock(content: string): string { this.currentIndent += this.indent; const indentedContent = content From 559b4061dc0310f064a2cf0ab308d137b21ba302 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 00:53:49 +0000 Subject: [PATCH 045/162] feat(syntax+formatter): Support function receivers --- src/func/formatter.ts | 10 +++++++--- src/func/syntax.ts | 5 ++++- src/func/syntaxConstructors.ts | 17 +++++++++++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 31fa65057..173d49164 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -58,8 +58,10 @@ export class FuncFormatter { private indent: number; private currentIndent: number; - constructor( params: Partial<{ indent: number, lineLengthLimit: number }> = {},) { - const { indent= 4, lineLengthLimit= 100 } = params; + constructor( + params: Partial<{ indent: number; lineLengthLimit: number }> = {}, + ) { + const { indent = 4, lineLengthLimit = 100 } = params; this.lineLengthLimit = lineLengthLimit; this.indent = indent; this.currentIndent = 0; @@ -318,9 +320,11 @@ export class FuncFormatter { } private formatCallExpr(node: FuncAstCallExpr): string { + const receiver = + node.receiver === undefined ? "" : `${this.dump(node.receiver)}.`; const fun = this.dump(node.fun); const args = node.args.map((arg) => this.dump(arg)).join(", "); - return `${fun}(${args})`; + return `${receiver}${fun}(${args})`; } private formatAssignExpr(node: FuncAstAssignExpr): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 22e13a500..150a8deb7 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -132,7 +132,10 @@ export type FuncAstIdExpr = { export type FuncAstCallExpr = { kind: "call_expr"; - fun: FuncAstExpr; // function name or an expression returning a function + // Returns the function object, e.g. get_value().load_int() + // ^^^^^^^^^^^ + receiver: FuncAstExpr | undefined; + fun: FuncAstExpr; // function name args: FuncAstExpr[]; }; diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 94d3e2949..ca7568def 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -128,14 +128,19 @@ export const id = (value: string): FuncAstIdExpr => ({ value, }); -export const call = ( +export function call( fun: FuncAstExpr | string, args: FuncAstExpr[], -): FuncAstCallExpr => ({ - kind: "call_expr", - fun: wrapToId(fun), - args, -}); + params: Partial<{ receiver: FuncAstExpr }> = {}, +): FuncAstCallExpr { + const { receiver = undefined } = params; + return { + kind: "call_expr", + receiver, + fun: wrapToId(fun), + args, + }; +} export const assign = ( lhs: FuncAstExpr, From 8db5675784d1420db6f5b51c669d3d812f194898 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 00:54:06 +0000 Subject: [PATCH 046/162] fix(codegen): Correct function receivers --- src/codegen/expression.ts | 30 ++++++++++-------------------- src/codegen/module.ts | 16 +++++++++------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index deee4f96d..98f628623 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -552,7 +552,7 @@ export class ExpressionGen { const args = this.tactExpr.args.map((argAst, i) => this.makeCastedExpr(argAst, sf.params[i]!.type), ); - return { kind: "call_expr", fun, args }; + return call(fun, args); } // @@ -659,13 +659,10 @@ export class ExpressionGen { methodFun.params[0]!.type.kind === "ref" && !methodFun.params[0]!.type.optional ) { - const fun = id(ops.typeTensorCast(tt.name)); argExprs = [ - { - kind: "call_expr", - fun, - args: [argExprs[0]!], - }, + call(ops.typeTensorCast(tt.name), [ + argExprs[0]!, + ]), ]; } } @@ -684,22 +681,15 @@ export class ExpressionGen { `Impossible self kind: ${selfExpr.kind}`, ); } - const fun = id(`${selfExpr}~${name}`); - return { kind: "call_expr", fun, args: argExprs }; + return call(`${selfExpr}~${name}`, argExprs); } else { - const fun = id(ops.nonModifying(name)); - return { - kind: "call_expr", - fun, - args: [selfExpr, ...argExprs], - }; + return call(ops.nonModifying(name), [ + selfExpr, + ...argExprs, + ]); } } else { - return { - kind: "call_expr", - fun: id(name), - args: [selfExpr, ...argExprs], - }; + return call(name, [selfExpr, ...argExprs]); } } diff --git a/src/codegen/module.ts b/src/codegen/module.ts index cc1f5a924..e45148b36 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -542,13 +542,15 @@ export class ModuleGen { // return get_data().begin_parse().load_int(1); // } m.entries.push( - fun( - ["method_id"], - "lazy_deployment_completed", - [], - { kind: "hole" }, - [ret(call(call(call("load_init", [number(1)]), []), []))], - ), + fun(["method_id"], "lazy_deployment_completed", [], Type.hole(), [ + ret( + call("load_int", [number(1)], { + receiver: call("begin_parse", [], { + receiver: call("get_data", []), + }), + }), + ), + ]), ); m.entries.push( From a2ee2b8c5b22db45ee0aa629ba43cbb2c0fa1817 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 00:58:58 +0000 Subject: [PATCH 047/162] chore(compile): Optional debug prints for codegen output --- src/pipeline/compile.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pipeline/compile.ts b/src/pipeline/compile.ts index 04c6668a3..f30c25b8c 100644 --- a/src/pipeline/compile.ts +++ b/src/pipeline/compile.ts @@ -17,6 +17,14 @@ export type CompilationResults = { ctx: CompilerContext; }; +function printOutput(contractName: string, output: CompilationOutput) { + const sep = "---------------\n"; + console.log(`Contract ${contractName} output:\n`); + output.files.forEach((o) => + console.log(`${sep}\nFile ${o.name}:\n${o.code}\n`), + ); +} + /** * Compiles the given contract to Func. */ @@ -37,9 +45,8 @@ export async function compile( } else { output = await writeProgram(ctx, abi, abiName); } - // console.log(`${contractName} output:`); - // output.files.forEach((o) => - // console.log(`---------------\nname=${o.name}; code:\n${o.code}\n`), - // ); + if (process.env.PRINT_FUNC === "1") { + printOutput(contractName, output); + } return { output, ctx }; } From fad1dc6ca4c8460cde51b1b7207f3195a7186a68 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 01:12:09 +0000 Subject: [PATCH 048/162] fix(codegen): Get rid of extra function attributes --- src/codegen/generator.ts | 8 +++++--- src/func/syntaxUtils.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/func/syntaxUtils.ts diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index afc5e3264..3b981e541 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -5,6 +5,7 @@ import { topologicalSort } from "../utils/utils"; import { ContractABI } from "@ton/core"; import { FuncFormatter } from "../func/formatter"; import { FuncAstModule, FuncAstFunctionDefinition } from "../func/syntax"; +import { deepCopy } from "../func/syntaxUtils"; import { comment, mod, @@ -210,12 +211,13 @@ export class FuncGenerator { functions.forEach((f) => { // if (f.code.kind === "generic") { m.entries.push(comment(f.name.value, { skipCR: true })); + const f_ = deepCopy(f); if ( - f.attrs.find((attr) => attr !== "impure" && attr !== "inline") + f_.attrs.find((attr) => attr !== "impure" && attr !== "inline") ) { - f.attrs.push("inline_ref"); + f_.attrs.push("inline_ref"); } - m.entries.push(toDeclaration(f)); + m.entries.push(toDeclaration(f_)); // } }); generated.files.push({ diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts new file mode 100644 index 000000000..ff70410bd --- /dev/null +++ b/src/func/syntaxUtils.ts @@ -0,0 +1,18 @@ +/** + * Provides deep copy that works for AST nodes. + */ +export function deepCopy(obj: T): T { + if (obj === null || typeof obj !== "object") { + return obj; + } + if (Array.isArray(obj)) { + return obj.map((item) => deepCopy(item)) as unknown as T; + } + const copy = {} as T; + for (const key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + (copy as any)[key] = deepCopy((obj as any)[key]); + } + } + return copy; +} From 97216d1637e9fd7b15aca264403f904dfc76aedc Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 01:23:00 +0000 Subject: [PATCH 049/162] chore(codegen): Replace the rest of ad-hoc initializers w/ constructors --- src/codegen/expression.ts | 36 ++++++++---------------------------- src/codegen/function.ts | 6 +++--- src/codegen/module.ts | 4 ++-- src/codegen/statement.ts | 4 ++-- 4 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 98f628623..b7ffeb6ff 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -27,20 +27,15 @@ import { FuncAstExpr, FuncAstUnaryOp, FuncAstIdExpr, - FuncAstTernaryExpr, } from "../func/syntax"; -import { id, call, binop, ternary } from "../func/syntaxConstructors"; +import { id, call, binop, ternary, unop, number,nil, bool } from "../func/syntaxConstructors"; function isNull(f: AstExpression): boolean { return f.kind === "null"; } function addUnary(op: FuncAstUnaryOp, expr: FuncAstExpr): FuncAstExpr { - return { - kind: "unary_expr", - op, - value: expr, - }; + return unop(op, expr); } function negate(expr: FuncAstExpr): FuncAstExpr { @@ -81,7 +76,7 @@ export class ExpressionGen { */ static writeValue(ctx: CodegenContext, val: Value): FuncAstExpr { if (typeof val === "bigint") { - return { kind: "number_expr", value: val }; + return number(val); } // if (typeof val === "string") { // const id = writeString(val, wCtx); @@ -89,7 +84,7 @@ export class ExpressionGen { // return `${id}()`; // } if (typeof val === "boolean") { - return { kind: "bool_expr", value: val }; + return bool(val); } // if (Address.isAddress(val)) { // const res = writeAddress(val, wCtx); @@ -102,7 +97,7 @@ export class ExpressionGen { // return `${res}()`; // } if (val === null) { - return { kind: "nil_expr" }; + return nil(); } // if (val instanceof CommentValue) { // const id = writeComment(val.comment, wCtx); @@ -191,10 +186,7 @@ export class ExpressionGen { // Special case for non-integer types and nullable if (this.tactExpr.op === "==" || this.tactExpr.op === "!=") { if (isNull(this.tactExpr.left) && isNull(this.tactExpr.right)) { - return { - kind: "bool_expr", - value: this.tactExpr.op === "==", - }; + return bool(this.tactExpr.op === "=="); } else if ( isNull(this.tactExpr.left) && !isNull(this.tactExpr.right) @@ -386,26 +378,14 @@ export class ExpressionGen { if (this.tactExpr.op === "&&") { const cond = this.makeExpr(this.tactExpr.left); const trueExpr = this.makeExpr(this.tactExpr.right); - const falseExpr = { kind: "bool_expr", value: false }; - return { - kind: "ternary_expr", - cond, - trueExpr, - falseExpr, - } as FuncAstTernaryExpr; + return ternary(cond, trueExpr, bool(false)); } // Case for "||" operator if (this.tactExpr.op === "||") { const cond = this.makeExpr(this.tactExpr.left); - const trueExpr = { kind: "bool_expr", value: true }; const falseExpr = this.makeExpr(this.tactExpr.right); - return { - kind: "ternary_expr", - cond, - trueExpr, - falseExpr, - } as FuncAstTernaryExpr; + return ternary(cond, bool(true), falseExpr); } // Other ops diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 8724842e2..62668a73d 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -9,7 +9,7 @@ import { FuncAstExpr, FuncType, } from "../func/syntax"; -import { id, call, ret, fun, vardef } from "../func/syntaxConstructors"; +import { id, call, ret, fun, vardef, Type, tensor } from "../func/syntaxConstructors"; import { StatementGen, ExpressionGen, CodegenContext } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; @@ -99,7 +99,7 @@ export class FunctionGen { if (self !== undefined && tactFun.isMutating) { // Add `self` to the method signature as it is mutating in the body. const selfTy = resolveFuncType(this.ctx.ctx, self); - returnTy = { kind: "tensor", value: [selfTy, returnTy] }; + returnTy = Type.tensor(selfTy, returnTy); // returnsStr = resolveFuncTypeUnpack(ctx, self, funcIdOf("self")); } @@ -226,7 +226,7 @@ export class FunctionGen { const body = values.length === 0 && returnTy.kind === "tuple" ? [ret(call("empty_tuple", []))] - : [ret({ kind: "tensor_expr", values })]; + : [ret(tensor(...values))]; return fun(attrs, name, params, returnTy, body); } } diff --git a/src/codegen/module.ts b/src/codegen/module.ts index e45148b36..c0ba03966 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -108,7 +108,7 @@ export class ModuleGen { ["method_id"], "supported_interfaces", [], - { kind: "hole" }, + Type.hole(), [ret(tensor(...shiftExprs))], ); } @@ -532,7 +532,7 @@ export class ModuleGen { // return "${abiLink}"; // } m.entries.push( - fun(["method_id"], "get_abi_ipfs", [], { kind: "hole" }, [ + fun(["method_id"], "get_abi_ipfs", [], Type.hole(), [ ret(string(this.abiLink)), ]), ); diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index 74fca81a6..bfe5a6b93 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -24,6 +24,7 @@ import { ret, tensor, assign, + unit, condition, vardef, Type, @@ -100,8 +101,7 @@ export class StatementGen { ); return ret(getValue(castedReturns)); } else { - const unit = { kind: "unit_expr" } as FuncAstUnitExpr; - return ret(getValue(unit)); + return ret(getValue(unit())); } } case "statement_let": { From f666ac01e1b43359659886ab823ebb3f330db044 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 02:36:40 +0000 Subject: [PATCH 050/162] feat(syntax): Extra check for implicit `Object`->`string` conversion --- src/func/syntaxConstructors.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index ca7568def..a34f479d7 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -47,6 +47,9 @@ import { } from "./syntax"; function wrapToId(v: T | string): T { + if (typeof v === "string" && v.includes("[object")) { + throw new Error("Incorrect input"); + } return typeof v === "string" ? (id(v) as T) : v; } From e23bbd52230ad906b466a97fd24b125edf1956dc Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 02:39:41 +0000 Subject: [PATCH 051/162] feat(syntax): `asm` functions --- src/func/formatter.ts | 17 +++++++++++++- src/func/syntax.ts | 13 +++++++++- src/func/syntaxConstructors.ts | 43 +++++++++++++++++++++++++++------- 3 files changed, 62 insertions(+), 11 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 173d49164..cfd5b4fb0 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -9,8 +9,9 @@ import { FuncAstComment, FuncAstInclude, FuncAstModule, - FuncAstFunctionDefinition, FuncAstFunctionDeclaration, + FuncAstFunctionDefinition, + FuncAstAsmFunction, FuncAstVarDefStmt, FuncAstReturnStmt, FuncAstBlockStmt, @@ -97,6 +98,10 @@ export class FuncFormatter { return this.formatFunctionDefinition( node as FuncAstFunctionDefinition, ); + case "asm_function_definition": + return this.formatAsmFunction( + node as FuncAstAsmFunction, + ); case "var_def_stmt": return this.formatVarDefStmt(node as FuncAstVarDefStmt); case "return_stmt": @@ -225,6 +230,16 @@ export class FuncFormatter { return `${signature} {\n${body}\n}`; } + private formatAsmFunction(node: FuncAstAsmFunction): string { + const signature = this.formatFunctionSignature( + node.name, + node.attrs, + node.params, + node.returnTy, + ); + return `${signature} asm ${this.dump(node.rawAsm)};`; + } + private formatVarDefStmt(node: FuncAstVarDefStmt): string { const name = this.dump(node.name); const type = node.ty ? this.dump(node.ty) : "var"; diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 150a8deb7..a394a2302 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -351,6 +351,16 @@ export type FuncAstFunctionDefinition = { body: FuncAstStmt[]; }; +// e.g.: int preload_uint(slice s, int len) asm "PLDUX"; +export type FuncAstAsmFunction = { + kind: "asm_function_definition"; + name: FuncAstIdExpr; + attrs: FuncAstFunctionAttribute[]; + params: FuncAstFormalFunctionParam[]; + returnTy: FuncType; + rawAsm: FuncAstStringExpr; // Raw TVM assembly +} + export type FuncAstComment = { kind: "comment"; values: string[]; // Represents multiline comments @@ -377,8 +387,9 @@ export type FuncAstGlobalVariable = { export type FuncAstModuleEntry = | FuncAstInclude | FuncAstPragma - | FuncAstFunctionDefinition | FuncAstFunctionDeclaration + | FuncAstFunctionDefinition + | FuncAstAsmFunction | FuncAstComment | FuncAstConstant | FuncAstGlobalVariable; diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index a34f479d7..f5d724cbb 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -38,6 +38,7 @@ import { FuncAstFunctionAttribute, FuncAstFunctionDeclaration, FuncAstFunctionDefinition, + FuncAstAsmFunction, FuncAstComment, FuncAstInclude, FuncAstPragma, @@ -363,14 +364,12 @@ export const functionDeclaration = ( returnTy, }); -export const fun = ( - attrs: FuncAstFunctionAttribute[], - name: string | FuncAstIdExpr, - paramValues: [string, FuncType][], - returnTy: FuncType, - body: FuncAstStmt[], -): FuncAstFunctionDefinition => { - const params = paramValues.map( +type FunParamValues = [string, FuncType][]; + +function transformFunctionParams( + paramValues: FunParamValues, +): FuncAstFormalFunctionParam[] { + return paramValues.map( ([name, ty]) => ({ kind: "function_param", @@ -378,16 +377,42 @@ export const fun = ( ty, }) as FuncAstFormalFunctionParam, ); +} + +export const fun = ( + attrs: FuncAstFunctionAttribute[], + name: string | FuncAstIdExpr, + paramValues: FunParamValues, + returnTy: FuncType, + body: FuncAstStmt[], +): FuncAstFunctionDefinition => { return { kind: "function_definition", name: wrapToId(name), attrs, - params, + params: transformFunctionParams(paramValues), returnTy, body, }; }; +export const asmfun = ( + attrs: FuncAstFunctionAttribute[], + name: string | FuncAstIdExpr, + paramValues: FunParamValues, + returnTy: FuncType, + asm: string, +): FuncAstAsmFunction => { + return { + kind: "asm_function_definition", + name: wrapToId(name), + attrs, + params: transformFunctionParams(paramValues), + returnTy, + rawAsm: string(asm), + }; +}; + export function toDeclaration( def: FuncAstFunctionDefinition, ): FuncAstFunctionDeclaration { From fc696615ee5798d02588c34545d2d159dcb9701a Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 07:15:27 +0000 Subject: [PATCH 052/162] feat(codegen): Separate `Literal` generator; string literals support --- src/codegen/context.ts | 36 ++++++++--- src/codegen/expression.ts | 86 +++++-------------------- src/codegen/function.ts | 14 ++++- src/codegen/index.ts | 1 + src/codegen/literal.ts | 128 ++++++++++++++++++++++++++++++++++++++ src/codegen/statement.ts | 1 - 6 files changed, 185 insertions(+), 81 deletions(-) create mode 100644 src/codegen/literal.ts diff --git a/src/codegen/context.ts b/src/codegen/context.ts index e3d87298b..f2d667d7d 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -1,8 +1,8 @@ import { CompilerContext } from "../context"; -import { FuncAstFunctionDefinition } from "../func/syntax"; +import { FuncAstFunctionDefinition, FuncAstAsmFunction } from "../func/syntax"; type ContextValues = { - constructor: FuncAstFunctionDefinition; + function: FuncAstFunctionDefinition | FuncAstAsmFunction; }; export type ContextValueKind = keyof ContextValues; @@ -14,8 +14,11 @@ export type ContextValueKind = keyof ContextValues; export class CodegenContext { public ctx: CompilerContext; - /** Generated struct constructors. */ - private constructors: FuncAstFunctionDefinition[] = []; + /** Generated functions. */ + private functions: Map< + string, + FuncAstFunctionDefinition | FuncAstAsmFunction + > = new Map(); constructor(ctx: CompilerContext) { this.ctx = ctx; @@ -26,16 +29,33 @@ export class CodegenContext { value: ContextValues[K], ): void { switch (kind) { - case "constructor": - this.constructors.push(value as FuncAstFunctionDefinition); + case "function": + const fun = value as + | FuncAstFunctionDefinition + | FuncAstAsmFunction; + this.functions.set(fun.name.value, fun); break; + default: + throw new Error(`Unknown kind: ${kind}`); + } + } + + public has(kind: K, name: string) { + switch (kind) { + case "function": + return this.functions.has(name); + default: + throw new Error(`Unknown kind: ${kind}`); } } /** - * Returns all the generated functions. + * Returns all the generated functions that has non-asm body. */ public getFunctions(): FuncAstFunctionDefinition[] { - return this.constructors; + return Array.from(this.functions.values()).filter( + (f): f is FuncAstFunctionDefinition => + f.kind === "function_definition", + ); } } diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index b7ffeb6ff..72dba60df 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -7,7 +7,7 @@ import { evalConstantExpression } from "../constEval"; import { resolveFuncTypeUnpack } from "./type"; import { MapFunctions, StructFunctions, GlobalFunctions } from "./abi"; import { getExpType } from "../types/resolveExpression"; -import { FunctionGen, CodegenContext } from "."; +import { FunctionGen, CodegenContext, LiteralGen } from "."; import { cast, funcIdOf, ops } from "./util"; import { printTypeRef, TypeRef, Value, FieldDescription } from "../types/types"; import { @@ -23,12 +23,15 @@ import { eqNames, tryExtractPath, } from "../grammar/ast"; +import { FuncAstExpr, FuncAstUnaryOp, FuncAstIdExpr } from "../func/syntax"; import { - FuncAstExpr, - FuncAstUnaryOp, - FuncAstIdExpr, -} from "../func/syntax"; -import { id, call, binop, ternary, unop, number,nil, bool } from "../func/syntaxConstructors"; + id, + call, + binop, + ternary, + unop, + bool, +} from "../func/syntaxConstructors"; function isNull(f: AstExpression): boolean { return f.kind === "null"; @@ -71,70 +74,11 @@ export class ExpressionGen { return new ExpressionGen(ctx, tactExpr); } - /** - * Generates FunC literals from Tact ones. - */ - static writeValue(ctx: CodegenContext, val: Value): FuncAstExpr { - if (typeof val === "bigint") { - return number(val); - } - // if (typeof val === "string") { - // const id = writeString(val, wCtx); - // wCtx.used(id); - // return `${id}()`; - // } - if (typeof val === "boolean") { - return bool(val); - } - // if (Address.isAddress(val)) { - // const res = writeAddress(val, wCtx); - // wCtx.used(res); - // return res + "()"; - // } - // if (val instanceof Cell) { - // const res = writeCell(val, wCtx); - // wCtx.used(res); - // return `${res}()`; - // } - if (val === null) { - return nil(); - } - // if (val instanceof CommentValue) { - // const id = writeComment(val.comment, wCtx); - // wCtx.used(id); - // return `${id}()`; - // } - if (typeof val === "object" && "$tactStruct" in val) { - // this is a struct value - const structDescription = getType( - ctx.ctx, - val["$tactStruct"] as string, - ); - const fields = structDescription.fields.map((field) => field.name); - const constructor = FunctionGen.fromTact( - ctx, - ).writeStructConstructor(structDescription, fields); - ctx.add("constructor", constructor); - const fieldValues = structDescription.fields.map((field) => { - if (field.name in val) { - return ExpressionGen.writeValue(ctx, val[field.name]!); - } else { - throw Error( - `Struct value is missing a field: ${field.name}`, - val, - ); - } - }); - return call(constructor.name, fieldValues); - } - throw Error(`Invalid value: ${val}`); - } - public writeExpression(): FuncAstExpr { // literals and constant expressions are covered here try { const value = evalConstantExpression(this.tactExpr, this.ctx.ctx); - return ExpressionGen.writeValue(this.ctx, value); + return this.makeValue(value); } catch (error) { if (!(error instanceof TactConstEvalError) || error.fatal) throw error; @@ -175,7 +119,7 @@ export class ExpressionGen { // Handle constant if (hasStaticConstant(this.ctx.ctx, this.tactExpr.text)) { const c = getStaticConstant(this.ctx.ctx, this.tactExpr.text); - return ExpressionGen.writeValue(this.ctx, c.value!); + return this.makeValue(c.value!); } return id(funcIdOf(this.tactExpr.text)); @@ -497,7 +441,7 @@ export class ExpressionGen { this.makeExpr(this.tactExpr.aggregate), ]); } else { - return ExpressionGen.writeValue(this.ctx, cst!.value!); + return this.makeValue(cst!.value!); } } @@ -548,7 +492,7 @@ export class ExpressionGen { src, this.tactExpr.args.map((v) => v.field.text), ); - this.ctx.add("constructor", constructor); + this.ctx.add("function", constructor); // Write an expression const args = this.tactExpr.args.map((v) => @@ -734,6 +678,10 @@ export class ExpressionGen { throw Error(`Unknown expression: ${this.tactExpr.kind}`); } + private makeValue(val: Value): FuncAstExpr { + return LiteralGen.fromTact(this.ctx, val).writeValue(); + } + private makeExpr(src: AstExpression): FuncAstExpr { return ExpressionGen.fromTact(this.ctx, src).writeExpression(); } diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 62668a73d..c658d5da7 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -9,8 +9,16 @@ import { FuncAstExpr, FuncType, } from "../func/syntax"; -import { id, call, ret, fun, vardef, Type, tensor } from "../func/syntaxConstructors"; -import { StatementGen, ExpressionGen, CodegenContext } from "."; +import { + id, + call, + ret, + fun, + vardef, + Type, + tensor, +} from "../func/syntaxConstructors"; +import { StatementGen, LiteralGen, CodegenContext } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; /** @@ -216,7 +224,7 @@ export class FunctionGen { if (arg) { return id(avoidFunCKeywordNameClash(arg)); } else if (v.default !== undefined) { - return ExpressionGen.writeValue(this.ctx, v.default); + return LiteralGen.fromTact(this.ctx, v.default).writeValue(); } else { throw Error( `Missing argument for field "${v.name}" in struct "${type.name}"`, diff --git a/src/codegen/index.ts b/src/codegen/index.ts index ed3f15c9e..eaafe3d07 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -4,3 +4,4 @@ export { FunctionGen } from "./function"; export { StatementGen } from "./statement"; export { ExpressionGen, writePathExpression } from "./expression"; export { FuncGenerator } from "./generator"; +export { LiteralGen } from "./literal"; diff --git a/src/codegen/literal.ts b/src/codegen/literal.ts new file mode 100644 index 000000000..ece908377 --- /dev/null +++ b/src/codegen/literal.ts @@ -0,0 +1,128 @@ +import { CodegenContext, FunctionGen } from "."; +import { FuncAstExpr } from "../func/syntax"; +import { beginCell, Cell } from "@ton/core"; +import { Value } from "../types/types"; +import { + call, + Type, + number, + id, + asmfun, + nil, + bool, +} from "../func/syntaxConstructors"; +import { getType } from "../types/resolveDescriptors"; + +import JSONbig from "json-bigint"; + +/** + * Encapsulates generation of Func literal values from Tact values. + */ +export class LiteralGen { + /** + * @param tactExpr Expression to translate. + */ + private constructor( + private ctx: CodegenContext, + private tactValue: Value, + ) {} + + static fromTact(ctx: CodegenContext, tactValue: Value): LiteralGen { + return new LiteralGen(ctx, tactValue); + } + + /** + * Saves/retrieves a function from the context and returns its name. + */ + private writeRawSlice( + prefix: string, + comment: string, + cell: Cell, + ): FuncAstExpr { + const h = cell.hash().toString("hex"); + const t = cell.toBoc({ idx: false }).toString("hex"); + const funName = `__gen_slice_${prefix}_${h}`; + if (!this.ctx.has("function", funName)) { + // TODO: Add docstring: `comment` + const fun = asmfun( + [], + funName, + [], + Type.slice(), + `{${t}} B>boc field.name); + const constructor = FunctionGen.fromTact( + this.ctx, + ).writeStructConstructor(structDescription, fields); + this.ctx.add("function", constructor); + const fieldValues = structDescription.fields.map((field) => { + if (field.name in val) { + return this.makeValue(val[field.name]!); + } else { + throw Error( + `Struct value is missing a field: ${field.name}`, + val, + ); + } + }); + return call(constructor.name, fieldValues); + } + throw Error(`Invalid value: ${JSONbig.stringify(val, null, 2)}`); + } + + private makeValue(val: Value): FuncAstExpr { + return LiteralGen.fromTact(this.ctx, val).writeValue(); + } +} diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index bfe5a6b93..622d4e2c1 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -16,7 +16,6 @@ import { FuncAstStmt, FuncAstConditionStmt, FuncAstExpr, - FuncAstUnitExpr, } from "../func/syntax"; import { id, From 245e4c93e681535dd631a1526b1365110e719a3a Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 07:17:54 +0000 Subject: [PATCH 053/162] feat(codegen): Support `Address` --- src/codegen/literal.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/codegen/literal.ts b/src/codegen/literal.ts index ece908377..09a4064a2 100644 --- a/src/codegen/literal.ts +++ b/src/codegen/literal.ts @@ -1,6 +1,6 @@ import { CodegenContext, FunctionGen } from "."; import { FuncAstExpr } from "../func/syntax"; -import { beginCell, Cell } from "@ton/core"; +import { Address, beginCell, Cell } from "@ton/core"; import { Value } from "../types/types"; import { call, @@ -64,6 +64,17 @@ export class LiteralGen { return this.writeRawSlice("string", `String "${str}"`, cell); } + /** + * Returns a function name used to access the address value. + */ +private writeAddress(address: Address) { + return this.writeRawSlice( + "address", + address.toString(), + beginCell().storeAddress(address).endCell(), + ); +} + /** * Generates FunC literals from Tact ones. */ @@ -78,11 +89,9 @@ export class LiteralGen { if (typeof val === "boolean") { return bool(val); } - // if (Address.isAddress(val)) { - // const res = writeAddress(val, wCtx); - // wCtx.used(res); - // return res + "()"; - // } + if (Address.isAddress(val)) { + return call(this.writeAddress(val), []) + } // if (val instanceof Cell) { // const res = writeCell(val, wCtx); // wCtx.used(res); From 7204e741c2aa54e3e149193bcbd2e015af782afb Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 07:25:07 +0000 Subject: [PATCH 054/162] feat(codegen): Support `Cell` and `Comment` literals --- src/codegen/literal.ts | 80 +++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/src/codegen/literal.ts b/src/codegen/literal.ts index 09a4064a2..f11dcfe4e 100644 --- a/src/codegen/literal.ts +++ b/src/codegen/literal.ts @@ -1,7 +1,7 @@ import { CodegenContext, FunctionGen } from "."; import { FuncAstExpr } from "../func/syntax"; import { Address, beginCell, Cell } from "@ton/core"; -import { Value } from "../types/types"; +import { Value, CommentValue } from "../types/types"; import { call, Type, @@ -49,7 +49,7 @@ export class LiteralGen { funName, [], Type.slice(), - `{${t}} B>boc boc boc PUSHREF`, + ); + this.ctx.add("function", fun); + } + return id(funName); + } /** * Generates FunC literals from Tact ones. @@ -90,21 +134,17 @@ private writeAddress(address: Address) { return bool(val); } if (Address.isAddress(val)) { - return call(this.writeAddress(val), []) + return call(this.writeAddress(val), []); + } + if (val instanceof Cell) { + return call(this.writeCell(val), []); } - // if (val instanceof Cell) { - // const res = writeCell(val, wCtx); - // wCtx.used(res); - // return `${res}()`; - // } if (val === null) { return nil(); } - // if (val instanceof CommentValue) { - // const id = writeComment(val.comment, wCtx); - // wCtx.used(id); - // return `${id}()`; - // } + if (val instanceof CommentValue) { + return call(this.writeComment(val.comment), []); + } if (typeof val === "object" && "$tactStruct" in val) { // this is a struct value const structDescription = getType( From 7b564f15978869f396ea348fd656acb0410bf5c3 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 07:31:00 +0000 Subject: [PATCH 055/162] chore(syntax): More informative error message --- src/func/syntaxConstructors.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index f5d724cbb..ad6c2c527 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -47,9 +47,11 @@ import { FuncAstModule, } from "./syntax"; +import JSONbig from "json-bigint"; + function wrapToId(v: T | string): T { if (typeof v === "string" && v.includes("[object")) { - throw new Error("Incorrect input"); + throw new Error(`Incorrect input: ${JSONbig.stringify(v, null, 2)}`); } return typeof v === "string" ? (id(v) as T) : v; } From 2debb1e7a60d3d91f9ed4105e8026eac17fff84b Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 07:48:59 +0000 Subject: [PATCH 056/162] fix(codegen): `[object Object]` in output --- src/codegen/expression.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 72dba60df..9ab3e5afd 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -605,7 +605,7 @@ export class ExpressionGen { `Impossible self kind: ${selfExpr.kind}`, ); } - return call(`${selfExpr}~${name}`, argExprs); + return call(`${selfExpr.value}~${name}`, argExprs); } else { return call(ops.nonModifying(name), [ selfExpr, From 442dcada4b9469a5be418f8e02d68cbf61f469a3 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Fri, 19 Jul 2024 23:58:18 +0000 Subject: [PATCH 057/162] fix(codegen): Comment position --- src/codegen/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index c0ba03966..1364dbc7a 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -168,9 +168,9 @@ export class ModuleGen { // if (msg_bounced) { // ... // } + functionBody.push(comment("Handle bounced messages")); if (internal) { const body: FuncAstStmt[] = []; - body.push(comment("Handle bounced messages")); const bounceReceivers = type.receivers.filter((r) => { return r.selector.kind === "bounce-binary"; }); From 2b3f4f2d0f9b5b2bbe26a6581554cb316b4242b0 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 20 Jul 2024 00:05:22 +0000 Subject: [PATCH 058/162] feat(syntax): Support extra CR --- src/func/formatter.ts | 7 +++++++ src/func/syntax.ts | 8 +++++++- src/func/syntaxConstructors.ts | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index cfd5b4fb0..3b0bd982c 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -7,6 +7,7 @@ import { FuncAstAssignExpr, FuncAstPragma, FuncAstComment, + FuncAstCR, FuncAstInclude, FuncAstModule, FuncAstFunctionDeclaration, @@ -78,6 +79,8 @@ export class FuncFormatter { return this.formatPragma(node as FuncAstPragma); case "comment": return this.formatComment(node as FuncAstComment); + case "cr": + return this.formatCR(node as FuncAstCR); case "int": case "hole": case "cell": @@ -452,6 +455,10 @@ export class FuncFormatter { .join("\n"); } + private formatCR(node: FuncAstCR): string { + return '\n'.repeat(node.lines); + } + private formatType(node: FuncType): string { switch (node.kind) { case "hole": diff --git a/src/func/syntax.ts b/src/func/syntax.ts index a394a2302..46779ddb0 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -244,6 +244,7 @@ export type FuncAstPrimitiveTypeExpr = { export type FuncAstStmt = | FuncAstComment // A comment appearing among statements + | FuncAstCR // An extra newline separating block of statements | FuncAstBlockStmt | FuncAstVarDefStmt | FuncAstReturnStmt @@ -359,7 +360,7 @@ export type FuncAstAsmFunction = { params: FuncAstFormalFunctionParam[]; returnTy: FuncType; rawAsm: FuncAstStringExpr; // Raw TVM assembly -} +}; export type FuncAstComment = { kind: "comment"; @@ -368,6 +369,11 @@ export type FuncAstComment = { style: ";" | ";;"; }; +export type FuncAstCR = { + kind: "cr"; + lines: number; // Number of newline symbols +}; + export type FuncAstInclude = { kind: "include"; value: string; diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index ad6c2c527..8933e1b80 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -40,6 +40,7 @@ import { FuncAstFunctionDefinition, FuncAstAsmFunction, FuncAstComment, + FuncAstCR, FuncAstInclude, FuncAstPragma, FuncAstGlobalVariable, @@ -338,6 +339,11 @@ export function comment( }; } +export const cr = (lines: number = 1): FuncAstCR => ({ + kind: "cr", + lines, +}); + export const constant = (ty: FuncType, init: FuncAstExpr): FuncAstConstant => ({ kind: "constant", ty, From 5961ff2f33622294476d320e44de99cb4b30e9c5 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 20 Jul 2024 08:41:00 +0000 Subject: [PATCH 059/162] feat(codegen): Support receivers --- src/codegen/module.ts | 322 +++++++++++++++++++++++++++++++-- src/func/syntax.ts | 2 + src/func/syntaxConstructors.ts | 8 +- 3 files changed, 313 insertions(+), 19 deletions(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 1364dbc7a..bdf6afe6b 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,9 +1,11 @@ import { getAllTypes, getType } from "../types/resolveDescriptors"; -import { TypeDescription } from "../types/types"; +import { ReceiverDescription, TypeDescription } from "../types/types"; import { getSortedTypes } from "../storage/resolveAllocation"; +import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; import { getSupportedInterfaces } from "../types/getSupportedInterfaces"; -import { ops } from "./util"; +import { funcIdOf, ops } from "./util"; import { + UNIT_TYPE, FuncAstModule, FuncAstStmt, FuncAstFunctionAttribute, @@ -13,8 +15,10 @@ import { } from "../func/syntax"; import { comment, + FunParamValue, assign, expr, + unit, call, binop, bool, @@ -30,10 +34,20 @@ import { condition, id, } from "../func/syntaxConstructors"; -import { resolveFuncType } from "./type"; -import { FunctionGen, CodegenContext } from "."; +import { FunctionGen, StatementGen, CodegenContext } from "."; import { beginCell } from "@ton/core"; +import JSONbig from "json-bigint"; + +export function commentPseudoOpcode(comment: string): string { + return beginCell() + .storeUint(0, 32) + .storeBuffer(Buffer.from(comment, "utf8")) + .endCell() + .hash() + .toString("hex", 0, 64); +} + /** * Encapsulates generation of the main Func compilation module from the main Tact module. */ @@ -104,13 +118,9 @@ export class ModuleGen { const shiftExprs: FuncAstExpr[] = supported.map((item) => binop(string(item, "H"), ">>", number(128)), ); - return fun( - ["method_id"], - "supported_interfaces", - [], - Type.hole(), - [ret(tensor(...shiftExprs))], - ); + return fun(["method_id"], "supported_interfaces", [], Type.hole(), [ + ret(tensor(...shiftExprs)), + ]); } /** @@ -497,6 +507,288 @@ export class ModuleGen { return fun(attrs, name, paramValues, returnTy, functionBody); } + private writeReceiver( + self: TypeDescription, + f: ReceiverDescription, + ): FuncAstFunctionDefinition { + const selector = f.selector; + const selfRes = resolveFuncTypeUnpack( + this.ctx.ctx, + self, + funcIdOf("self"), + ); + const selfType = resolveFuncType(this.ctx.ctx, self); + const selfUnpack = vardef( + undefined, + resolveFuncTypeUnpack(this.ctx.ctx, self, funcIdOf("self")), + id(funcIdOf("self")), + ); + + // Binary receiver + if ( + selector.kind === "internal-binary" || + selector.kind === "external-binary" + ) { + const returnTy = Type.tensor(selfType, UNIT_TYPE); + const funName = ops.receiveType( + self.name, + selector.kind === "internal-binary" ? "internal" : "external", + selector.type, + ); + const paramValues: FunParamValue[] = [ + [funcIdOf("self"), selfType], + [ + funcIdOf(selector.name), + resolveFuncType(this.ctx.ctx, selector.type), + ], + ]; + const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const body: FuncAstStmt[] = [selfUnpack]; + body.push( + vardef( + undefined, + resolveFuncTypeUnpack( + this.ctx.ctx, + selector.type, + funcIdOf(selector.name), + ), + id(funcIdOf(selector.name)), + ), + ); + f.ast.statements.forEach((s) => + body.push( + StatementGen.fromTact( + this.ctx, + s, + selfRes, + ).writeStatement(), + ), + ); + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + body.push(ret(tensor(id(selfRes), unit()))); + } + return fun(attrs, funName, paramValues, returnTy, body); + } + + // Empty receiver + if ( + selector.kind === "internal-empty" || + selector.kind === "external-empty" + ) { + const returnTy = Type.tensor(selfType, UNIT_TYPE); + const funName = ops.receiveEmpty( + self.name, + selector.kind === "internal-empty" ? "internal" : "external", + ); + const paramValues: FunParamValue[] = [[funcIdOf("self"), selfType]]; + const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const body: FuncAstStmt[] = [selfUnpack]; + f.ast.statements.forEach((s) => + body.push( + StatementGen.fromTact( + this.ctx, + s, + selfRes, + ).writeStatement(), + ), + ); + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + body.push(ret(tensor(id(selfRes), unit()))); + } + return fun(attrs, funName, paramValues, returnTy, body); + } + + // Comment receiver + if ( + selector.kind === "internal-comment" || + selector.kind === "external-comment" + ) { + const hash = commentPseudoOpcode(selector.comment); + const returnTy = Type.tensor(selfType, UNIT_TYPE); + const funName = ops.receiveText( + self.name, + selector.kind === "internal-comment" ? "internal" : "external", + hash, + ); + const paramValues: FunParamValue[] = [[funcIdOf("self"), selfType]]; + const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const body: FuncAstStmt[] = [selfUnpack]; + f.ast.statements.forEach((s) => + body.push( + StatementGen.fromTact( + this.ctx, + s, + selfRes, + ).writeStatement(), + ), + ); + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + body.push(ret(tensor(id(selfRes), unit()))); + } + return fun(attrs, funName, paramValues, returnTy, body); + } + + // Fallback + if ( + selector.kind === "internal-comment-fallback" || + selector.kind === "external-comment-fallback" + ) { + const returnTy = Type.tensor(selfType, UNIT_TYPE); + const funName = ops.receiveAnyText( + self.name, + selector.kind === "internal-comment-fallback" + ? "internal" + : "external", + ); + const paramValues: FunParamValue[] = [ + [funcIdOf("self"), selfType], + [funcIdOf(selector.name), Type.slice()], + ]; + const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const body: FuncAstStmt[] = [selfUnpack]; + f.ast.statements.forEach((s) => + body.push( + StatementGen.fromTact( + this.ctx, + s, + selfRes, + ).writeStatement(), + ), + ); + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + body.push(ret(tensor(id(selfRes), unit()))); + } + return fun(attrs, funName, paramValues, returnTy, body); + } + + // Fallback + if (selector.kind === "internal-fallback") { + const returnTy = Type.tensor(selfType, UNIT_TYPE); + const funName = ops.receiveAny(self.name, "internal"); + const paramValues: FunParamValue[] = [ + [funcIdOf("self"), selfType], + [funcIdOf(selector.name), Type.slice()], + ]; + const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const body: FuncAstStmt[] = [selfUnpack]; + f.ast.statements.forEach((s) => + body.push( + StatementGen.fromTact( + this.ctx, + s, + selfRes, + ).writeStatement(), + ), + ); + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + body.push(ret(tensor(id(selfRes), unit()))); + } + return fun(attrs, funName, paramValues, returnTy, body); + } + + // Bounced + if (selector.kind === "bounce-fallback") { + const returnTy = Type.tensor(selfType, UNIT_TYPE); + const funName = ops.receiveBounceAny(self.name); + const paramValues: FunParamValue[] = [ + [funcIdOf("self"), selfType], + [funcIdOf(selector.name), Type.slice()], + ]; + const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const body: FuncAstStmt[] = [selfUnpack]; + f.ast.statements.forEach((s) => + body.push( + StatementGen.fromTact( + this.ctx, + s, + selfRes, + ).writeStatement(), + ), + ); + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + body.push(ret(tensor(id(selfRes), unit()))); + } + return fun(attrs, funName, paramValues, returnTy, body); + } + + if (selector.kind === "bounce-binary") { + const returnTy = Type.tensor(selfType, UNIT_TYPE); + const funName = ops.receiveTypeBounce(self.name, selector.type); + const paramValues: FunParamValue[] = [ + [funcIdOf("self"), selfType], + [ + funcIdOf(selector.name), + resolveFuncType( + this.ctx.ctx, + selector.type, + false, + selector.bounced, + ), + ], + ]; + const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const body: FuncAstStmt[] = [selfUnpack]; + body.push( + vardef( + undefined, + resolveFuncTypeUnpack( + this.ctx.ctx, + selector.type, + funcIdOf(selector.name), + false, + selector.bounced, + ), + id(funcIdOf(selector.name)), + ), + ); + f.ast.statements.forEach((s) => + body.push( + StatementGen.fromTact( + this.ctx, + s, + selfRes, + ).writeStatement(), + ), + ); + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + body.push(ret(tensor(id(selfRes), unit()))); + } + return fun(attrs, funName, paramValues, returnTy, body); + } + + throw new Error( + `Unknown selector ${selector.kind}:\n${JSONbig.stringify(selector, null, 2)}`, + ); + } + /** * Adds entries from the main Tact contract. */ @@ -508,10 +800,10 @@ export class ModuleGen { comment("", `Receivers of a Contract ${contractTy.name}`, ""), ); - // // Write receivers - // for (const r of Object.values(c.receivers)) { - // this.writeReceiver(type, r, ctx); - // } + // Write receivers + for (const r of Object.values(contractTy.receivers)) { + m.entries.push(this.writeReceiver(contractTy, r)); + } m.entries.push( comment("", `Get methods of a Contract ${contractTy.name}`, ""), diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 46779ddb0..a1669712e 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -9,6 +9,8 @@ export const FUNC_VERSION: string = "0.4.4"; * NOTE: Unit type `()` is a special case of the tensor type. */ export type FuncTensorType = FuncType[]; + +// TODO: move it to syntaxConstructors export const UNIT_TYPE: FuncType = { kind: "tensor", value: [] as FuncTensorType, diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 8933e1b80..e663636ca 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -372,10 +372,10 @@ export const functionDeclaration = ( returnTy, }); -type FunParamValues = [string, FuncType][]; +export type FunParamValue = [string, FuncType]; function transformFunctionParams( - paramValues: FunParamValues, + paramValues: FunParamValue[], ): FuncAstFormalFunctionParam[] { return paramValues.map( ([name, ty]) => @@ -390,7 +390,7 @@ function transformFunctionParams( export const fun = ( attrs: FuncAstFunctionAttribute[], name: string | FuncAstIdExpr, - paramValues: FunParamValues, + paramValues: FunParamValue[], returnTy: FuncType, body: FuncAstStmt[], ): FuncAstFunctionDefinition => { @@ -407,7 +407,7 @@ export const fun = ( export const asmfun = ( attrs: FuncAstFunctionAttribute[], name: string | FuncAstIdExpr, - paramValues: FunParamValues, + paramValues: FunParamValue[], returnTy: FuncType, asm: string, ): FuncAstAsmFunction => { From 9065452690a75c35d6c5c5769c1b919d6337e19a Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 20 Jul 2024 08:58:59 +0000 Subject: [PATCH 060/162] feat(syntax): Support value in `method_id` attributes --- src/func/formatter.ts | 21 ++++++++++++++++----- src/func/syntax.ts | 8 ++++---- src/func/syntaxConstructors.ts | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 3b0bd982c..812f420ed 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -102,9 +102,7 @@ export class FuncFormatter { node as FuncAstFunctionDefinition, ); case "asm_function_definition": - return this.formatAsmFunction( - node as FuncAstAsmFunction, - ); + return this.formatAsmFunction(node as FuncAstAsmFunction); case "var_def_stmt": return this.formatVarDefStmt(node as FuncAstVarDefStmt); case "return_stmt": @@ -193,13 +191,26 @@ export class FuncFormatter { .join(""); } + private formatFunctionAttribute(attr: FuncAstFunctionAttribute): string { + switch (attr.kind) { + case "method_id": + return attr.value === undefined + ? "method_id" + : `method_id(${attr.value})`; + case "impure": + case "inline": + case "inline_ref": + return attr.kind; + } + } + private formatFunctionSignature( name: FuncAstIdExpr, attrs: FuncAstFunctionAttribute[], params: FuncAstFormalFunctionParam[], returnTy: FuncType, ): string { - const attrsStr = attrs.join(" "); + const attrsStr = attrs.map(this.formatFunctionAttribute).join(" "); const nameStr = this.dump(name); const paramsStr = params .map((param) => `${this.dump(param.ty)} ${this.dump(param.name)}`) @@ -456,7 +467,7 @@ export class FuncFormatter { } private formatCR(node: FuncAstCR): string { - return '\n'.repeat(node.lines); + return "\n".repeat(node.lines); } private formatType(node: FuncType): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index a1669712e..33e1925c6 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -326,10 +326,10 @@ export type FuncAstConstant = { }; export type FuncAstFunctionAttribute = - | "impure" - | "inline" - | "inline_ref" - | "method_id"; + | { kind: "impure" } + | { kind: "inline" } + | { kind: "inline_ref" } + | { kind: "method_id"; value: number | undefined }; export type FuncAstFormalFunctionParam = { kind: "function_param"; diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index e663636ca..8e92d4536 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -98,6 +98,24 @@ export class Type { } } +export class FunAttr { + public static impure(): FuncAstFunctionAttribute { + return { kind: "impure" }; + } + + public static inline(): FuncAstFunctionAttribute { + return { kind: "inline" }; + } + + public static inline_ref(): FuncAstFunctionAttribute { + return { kind: "inline_ref" }; + } + + public static method_id(value?: number): FuncAstFunctionAttribute { + return { kind: "method_id", value }; + } +} + // // Expressions // From 9baeac523fda340d8ae6a2623595bef2dc8ddb76 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 20 Jul 2024 09:26:15 +0000 Subject: [PATCH 061/162] fix(codegen): Comment position --- src/codegen/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index bdf6afe6b..2eb6077f0 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -178,8 +178,8 @@ export class ModuleGen { // if (msg_bounced) { // ... // } - functionBody.push(comment("Handle bounced messages")); if (internal) { + functionBody.push(comment("Handle bounced messages")); const body: FuncAstStmt[] = []; const bounceReceivers = type.receivers.filter((r) => { return r.selector.kind === "bounce-binary"; From 49d246c2e6b82c9d647a243d4829254514d604f2 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 20 Jul 2024 09:26:32 +0000 Subject: [PATCH 062/162] feat(codegen): Support getters --- src/codegen/expression.ts | 10 +- src/codegen/function.ts | 7 +- src/codegen/generator.ts | 5 +- src/codegen/module.ts | 207 ++++++++++++++++++++++++++++----- src/codegen/type.ts | 52 +++++++++ src/func/syntaxConstructors.ts | 1 + 6 files changed, 241 insertions(+), 41 deletions(-) diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 9ab3e5afd..2d0af740e 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -526,7 +526,6 @@ export class ExpressionGen { // Check struct ABI if (methodTy.kind === "struct") { if (StructFunctions.has(idText(this.tactExpr.method))) { - console.log(`getting ${idText(this.tactExpr.method)}`); const abi = StructFunctions.get( idText(this.tactExpr.method), )!; @@ -551,15 +550,10 @@ export class ExpressionGen { idText(this.tactExpr.method), ); if ( - methodFun.ast.kind === "function_def" || - methodFun.ast.kind === "function_decl" + methodFun.ast.kind !== "function_def" && + methodFun.ast.kind !== "function_decl" ) { - // wCtx.used(name); - } else { name = idText(methodFun.ast.nativeName); - if (name.startsWith("__tact")) { - // wCtx.used(name); - } } // Translate arguments diff --git a/src/codegen/function.ts b/src/codegen/function.ts index c658d5da7..e043ee042 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -13,6 +13,7 @@ import { id, call, ret, + FunAttr, fun, vardef, Type, @@ -131,9 +132,9 @@ export class FunctionGen { : ops.global(tactFun.name); // Prepare function attributes - let attrs: FuncAstFunctionAttribute[] = ["impure"]; + let attrs: FuncAstFunctionAttribute[] = [FunAttr.impure()]; if (enabledInline(this.ctx.ctx) || tactFun.isInline) { - attrs.push("inline"); + attrs.push(FunAttr.inline()); } // TODO: handle stdlib // if (f.origin === "stdlib") { @@ -200,7 +201,7 @@ export class FunctionGen { type: TypeDescription, args: string[], ): FuncAstFunctionDefinition { - const attrs: FuncAstFunctionAttribute[] = ["inline"]; + const attrs: FuncAstFunctionAttribute[] = [FunAttr.inline()]; const name = ops.typeConstructor( type.name, args.map((a) => a), diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 3b981e541..102393307 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -12,6 +12,7 @@ import { pragma, include, toDeclaration, +FunAttr, } from "../func/syntaxConstructors"; import { calculateIPFSlink } from "../utils/calculateIPFSlink"; @@ -213,9 +214,9 @@ export class FuncGenerator { m.entries.push(comment(f.name.value, { skipCR: true })); const f_ = deepCopy(f); if ( - f_.attrs.find((attr) => attr !== "impure" && attr !== "inline") + f_.attrs.find((attr) => attr.kind !== "impure" && attr.kind !== "inline") ) { - f_.attrs.push("inline_ref"); + f_.attrs.push(FunAttr.inline_ref()); } m.entries.push(toDeclaration(f_)); // } diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 2eb6077f0..9066595b1 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,7 +1,19 @@ import { getAllTypes, getType } from "../types/resolveDescriptors"; -import { ReceiverDescription, TypeDescription } from "../types/types"; +import { + ReceiverDescription, + TypeDescription, + TypeRef, + FunctionDescription, +} from "../types/types"; +import { CompilerContext } from "../context"; import { getSortedTypes } from "../storage/resolveAllocation"; -import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; +import { getMethodId } from "../utils/utils"; +import { idTextErr } from "../errors"; +import { + resolveFuncTypeUnpack, + resolveFuncType, + resolveFuncTupleType, +} from "./type"; import { getSupportedInterfaces } from "../types/getSupportedInterfaces"; import { funcIdOf, ops } from "./util"; import { @@ -10,6 +22,7 @@ import { FuncAstStmt, FuncAstFunctionAttribute, FuncType, + FuncAstVarDefStmt, FuncAstFunctionDefinition, FuncAstExpr, } from "../func/syntax"; @@ -29,6 +42,8 @@ import { ret, tensor, Type, + ternary, + FunAttr, vardef, mod, condition, @@ -48,6 +63,48 @@ export function commentPseudoOpcode(comment: string): string { .toString("hex", 0, 64); } +export function unwrapExternal( + ctx: CompilerContext, + targetName: string, + sourceName: string, + type: TypeRef, +): FuncAstVarDefStmt { + if (type.kind === "ref") { + const t = getType(ctx, type.name); + if (t.kind === "struct") { + if (type.optional) { + return vardef( + resolveFuncType(ctx, type), + targetName, + call(ops.typeFromOptTuple(t.name), [id(sourceName)]), + ); + } else { + return vardef( + resolveFuncType(ctx, type), + targetName, + call(ops.typeFromTuple(t.name), [id(sourceName)]), + ); + } + } else if (t.kind === "primitive_type_decl" && t.name === "Address") { + if (type.optional) { + const init = ternary( + call("null?", [id(sourceName)]), + call("null", []), + call("__tact_verify_address", [id(sourceName)]), + ); + return vardef(resolveFuncType(ctx, type), targetName, init); + } else { + return vardef( + resolveFuncType(ctx, type), + targetName, + call("__tact_verify_address", [id(sourceName)]), + ); + } + } + } + return vardef(resolveFuncType(ctx, type), targetName, id(sourceName)); +} + /** * Encapsulates generation of the main Func compilation module from the main Tact module. */ @@ -118,9 +175,13 @@ export class ModuleGen { const shiftExprs: FuncAstExpr[] = supported.map((item) => binop(string(item, "H"), ">>", number(128)), ); - return fun(["method_id"], "supported_interfaces", [], Type.hole(), [ - ret(tensor(...shiftExprs)), - ]); + return fun( + [FunAttr.method_id()], + "supported_interfaces", + [], + Type.hole(), + [ret(tensor(...shiftExprs))], + ); } /** @@ -156,7 +217,10 @@ export class ModuleGen { kind: "internal" | "external", ): FuncAstFunctionDefinition { const internal = kind === "internal"; - const attrs: FuncAstFunctionAttribute[] = ["impure", "inline_ref"]; + const attrs: FuncAstFunctionAttribute[] = [ + FunAttr.impure(), + FunAttr.inline_ref(), + ]; const name = ops.contractRouter(type.name, kind); const returnTy = Type.tensor( resolveFuncType(this.ctx.ctx, type), @@ -542,7 +606,10 @@ export class ModuleGen { resolveFuncType(this.ctx.ctx, selector.type), ], ]; - const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const attrs: FuncAstFunctionAttribute[] = [ + FunAttr.impure(), + FunAttr.inline(), + ]; const body: FuncAstStmt[] = [selfUnpack]; body.push( vardef( @@ -585,7 +652,10 @@ export class ModuleGen { selector.kind === "internal-empty" ? "internal" : "external", ); const paramValues: FunParamValue[] = [[funcIdOf("self"), selfType]]; - const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const attrs: FuncAstFunctionAttribute[] = [ + FunAttr.impure(), + FunAttr.inline(), + ]; const body: FuncAstStmt[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( @@ -619,7 +689,10 @@ export class ModuleGen { hash, ); const paramValues: FunParamValue[] = [[funcIdOf("self"), selfType]]; - const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const attrs: FuncAstFunctionAttribute[] = [ + FunAttr.impure(), + FunAttr.inline(), + ]; const body: FuncAstStmt[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( @@ -656,7 +729,10 @@ export class ModuleGen { [funcIdOf("self"), selfType], [funcIdOf(selector.name), Type.slice()], ]; - const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const attrs: FuncAstFunctionAttribute[] = [ + FunAttr.impure(), + FunAttr.inline(), + ]; const body: FuncAstStmt[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( @@ -685,7 +761,10 @@ export class ModuleGen { [funcIdOf("self"), selfType], [funcIdOf(selector.name), Type.slice()], ]; - const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const attrs: FuncAstFunctionAttribute[] = [ + FunAttr.impure(), + FunAttr.inline(), + ]; const body: FuncAstStmt[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( @@ -714,7 +793,10 @@ export class ModuleGen { [funcIdOf("self"), selfType], [funcIdOf(selector.name), Type.slice()], ]; - const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const attrs: FuncAstFunctionAttribute[] = [ + FunAttr.impure(), + FunAttr.inline(), + ]; const body: FuncAstStmt[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( @@ -750,7 +832,10 @@ export class ModuleGen { ), ], ]; - const attrs: FuncAstFunctionAttribute[] = ["impure", "inline"]; + const attrs: FuncAstFunctionAttribute[] = [ + FunAttr.impure(), + FunAttr.inline(), + ]; const body: FuncAstStmt[] = [selfUnpack]; body.push( vardef( @@ -789,6 +874,66 @@ export class ModuleGen { ); } + private writeGetter(f: FunctionDescription): FuncAstFunctionDefinition { + // Render tensors + const self = f.self !== null ? getType(this.ctx.ctx, f.self) : null; + if (!self) { + throw new Error(`No self type for getter ${idTextErr(f.name)}`); // Impossible + } + const returnTy = Type.hole(); + const funName = `%${f.name}`; + const paramValues: FunParamValue[] = f.params.map((v) => [ + funcIdOf(v.name), + resolveFuncTupleType(this.ctx.ctx, v.type), + ]); + const attrs = [FunAttr.method_id(getMethodId(f.name))]; + + const body: FuncAstStmt[] = []; + // Unpack parameters + for (const param of f.params) { + unwrapExternal( + this.ctx.ctx, + funcIdOf(param.name), + funcIdOf(param.name), + param.type, + ); + } + // Load contract state + body.push( + vardef(undefined, "self", call(ops.contractLoad(self.name), [])), + ); + // Execute get method + body.push( + vardef( + undefined, + "res", + call( + `self~${ops.extension(self.name, f.name)}`, + f.params.map((v) => id(funcIdOf(v.name))), + ), + ), + ); + // Pack if needed + if (f.returns.kind === "ref") { + const t = getType(this.ctx.ctx, f.returns.name); + if (t.kind === "struct") { + if (f.returns.optional) { + body.push( + ret(call(ops.typeToOptExternal(t.name), [id("res")])), + ); + } else { + body.push( + ret(call(ops.typeToExternal(t.name), [id("res")])), + ); + } + return fun(attrs, funName, paramValues, returnTy, body); + } + } + // Return result + body.push(ret(id("res"))); + return fun(attrs, funName, paramValues, returnTy, body); + } + /** * Adds entries from the main Tact contract. */ @@ -809,12 +954,12 @@ export class ModuleGen { comment("", `Get methods of a Contract ${contractTy.name}`, ""), ); - // // Getters - // for (const f of type.functions.values()) { - // if (f.isGetter) { - // writeGetter(f, ctx); - // } - // } + // Getters + for (const f of contractTy.functions.values()) { + if (f.isGetter) { + m.entries.push(this.writeGetter(f)); + } + } // Interfaces m.entries.push(this.writeInterfaces(contractTy)); @@ -824,7 +969,7 @@ export class ModuleGen { // return "${abiLink}"; // } m.entries.push( - fun(["method_id"], "get_abi_ipfs", [], Type.hole(), [ + fun([FunAttr.method_id()], "get_abi_ipfs", [], Type.hole(), [ ret(string(this.abiLink)), ]), ); @@ -834,15 +979,21 @@ export class ModuleGen { // return get_data().begin_parse().load_int(1); // } m.entries.push( - fun(["method_id"], "lazy_deployment_completed", [], Type.hole(), [ - ret( - call("load_int", [number(1)], { - receiver: call("begin_parse", [], { - receiver: call("get_data", []), + fun( + [FunAttr.method_id()], + "lazy_deployment_completed", + [], + Type.hole(), + [ + ret( + call("load_int", [number(1)], { + receiver: call("begin_parse", [], { + receiver: call("get_data", []), + }), }), - }), - ), - ]), + ), + ], + ), ); m.entries.push( diff --git a/src/codegen/type.ts b/src/codegen/type.ts index 67639e2bd..5a02ae6a8 100644 --- a/src/codegen/type.ts +++ b/src/codegen/type.ts @@ -191,3 +191,55 @@ export function resolveFuncType( // Unreachable throw Error(`Unknown type: ${descriptor.kind}`); } + +export function resolveFuncTupleType( + ctx: CompilerContext, + descriptor: TypeRef | TypeDescription | string, +): FuncType { + // String + if (typeof descriptor === "string") { + return resolveFuncTupleType(ctx, getType(ctx, descriptor)); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncTupleType(ctx, getType(ctx, descriptor.name)); + } + if (descriptor.kind === "map") { + return Type.cell(); + } + if (descriptor.kind === "ref_bounced") { + throw Error("Unimplemented"); + } + if (descriptor.kind === "void") { + return Type.tensor(); + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + if (descriptor.name === "Int") { + return Type.int(); + } else if (descriptor.name === "Bool") { + return Type.int(); + } else if (descriptor.name === "Slice") { + return Type.slice(); + } else if (descriptor.name === "Cell") { + return Type.cell(); + } else if (descriptor.name === "Builder") { + return Type.builder(); + } else if (descriptor.name === "Address") { + return Type.slice(); + } else if (descriptor.name === "String") { + return Type.slice(); + } else if (descriptor.name === "StringBuilder") { + return Type.tuple(); + } else { + throw Error(`Unknown primitive type: ${descriptor.name}`); + } + } else if (descriptor.kind === "struct") { + return Type.tuple(); + } + + // Unreachable + throw Error(`Unknown type: ${descriptor.kind}`); +} diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 8e92d4536..fad6a5421 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -260,6 +260,7 @@ export const primitiveType = (ty: FuncType): FuncAstPrimitiveTypeExpr => ({ // export const vardef = ( + // TODO: replace w/ `FuncType | '_'` ty: FuncType | undefined, name: string | FuncAstIdExpr, init?: FuncAstExpr, From aff835ecfbf099b9f515988223c96c86b8797c4e Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sat, 20 Jul 2024 09:38:03 +0000 Subject: [PATCH 063/162] feat(codegen): CRs in routers code to look as the old backend --- src/codegen/module.ts | 5 +++++ src/func/formatter.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 9066595b1..017b64677 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -27,6 +27,7 @@ import { FuncAstExpr, } from "../func/syntax"; import { + cr, comment, FunParamValue, assign, @@ -350,6 +351,7 @@ export class ModuleGen { } const cond = condition(id("msg_bounced"), body); functionBody.push(cond); + functionBody.push(cr()); } // ;; Parse incoming message @@ -372,6 +374,7 @@ export class ModuleGen { ], ), ); + functionBody.push(cr()); // Non-empty receivers for (const f of type.receivers) { @@ -439,6 +442,7 @@ export class ModuleGen { ], ), ); + functionBody.push(cr()); } } @@ -542,6 +546,7 @@ export class ModuleGen { ); } functionBody.push(condition(cond, condBody)); + functionBody.push(cr()); } // Fallback diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 812f420ed..1325daf9e 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -467,7 +467,7 @@ export class FuncFormatter { } private formatCR(node: FuncAstCR): string { - return "\n".repeat(node.lines); + return node.lines === 1 ? "" : "\n".repeat(node.lines - 1); } private formatType(node: FuncType): string { From 6cf09e51e5121b55c0e80fe51adf8fee052066c1 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Sun, 21 Jul 2024 01:54:56 +0000 Subject: [PATCH 064/162] feat(codegen): Context management to replicate some `Writer` logic --- src/codegen/context.ts | 146 +++++++++++++++++++++------ src/codegen/expression.ts | 1 - src/codegen/function.ts | 8 +- src/codegen/generator.ts | 177 ++++++++++++++------------------- src/codegen/index.ts | 2 +- src/codegen/literal.ts | 11 +- src/func/syntaxConstructors.ts | 4 +- 7 files changed, 204 insertions(+), 145 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index f2d667d7d..22fb6d3b7 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -1,11 +1,48 @@ import { CompilerContext } from "../context"; +import { topologicalSort } from "../utils/utils"; import { FuncAstFunctionDefinition, FuncAstAsmFunction } from "../func/syntax"; -type ContextValues = { - function: FuncAstFunctionDefinition | FuncAstAsmFunction; -}; +/** + * An additional information on how to handle the function definition. + * TODO: Refactor: we need only the boolean `skip` field in WrittenFunction. + * XXX: Writer.ts: `Body.kind` + */ +export type BodyKind = "asm" | "skip" | "generic"; + +/** + * Replicates the `ctx.context` parameter of the old backends Writer context. + * Basically, it tells in which file the context value should be located in the + * generated Func code. + * + * TODO: Should be refactored; `type` seems to be redundant + */ +export type LocationContext = + | { kind: "stdlib" } + | { kind: "constants" } + | { kind: "type"; value: string }; + +export class Location { + public static stdlib(): LocationContext { + return { kind: "stdlib" }; + } + + public static constants(): LocationContext { + return { kind: "constants" }; + } + + public static type(value: string): LocationContext { + return { kind: "type", value }; + } +} -export type ContextValueKind = keyof ContextValues; +// TODO: Rename when refactoring +export type WrittenFunction = { + name: string; + definition: FuncAstFunctionDefinition | FuncAstAsmFunction; + kind: BodyKind; + context: LocationContext; + depends: Set; +}; /** * The context containing the objects generated from the bottom-up in the generation @@ -15,47 +52,90 @@ export class CodegenContext { public ctx: CompilerContext; /** Generated functions. */ - private functions: Map< - string, - FuncAstFunctionDefinition | FuncAstAsmFunction - > = new Map(); + private functions: Map = new Map(); constructor(ctx: CompilerContext) { this.ctx = ctx; } - public add( - kind: K, - value: ContextValues[K], + public addFunction( + value: FuncAstFunctionDefinition | FuncAstAsmFunction, + bodyKind: BodyKind, + context: LocationContext, ): void { - switch (kind) { - case "function": - const fun = value as - | FuncAstFunctionDefinition - | FuncAstAsmFunction; - this.functions.set(fun.name.value, fun); - break; - default: - throw new Error(`Unknown kind: ${kind}`); - } + const definition = value as + | FuncAstFunctionDefinition + | FuncAstAsmFunction; + const depends: Set = new Set(); + this.functions.set(definition.name.value, { + name: definition.name.value, + definition, + kind: bodyKind, + context, + depends, + }); } - public has(kind: K, name: string) { - switch (kind) { - case "function": - return this.functions.has(name); - default: - throw new Error(`Unknown kind: ${kind}`); - } + public hasFunction(name: string) { + return this.functions.has(name); + } + + public allFunctions(): WrittenFunction[] { + return Array.from(this.functions.values()); } /** - * Returns all the generated functions that has non-asm body. + * XXX: Replicates WriteContext.extract */ - public getFunctions(): FuncAstFunctionDefinition[] { - return Array.from(this.functions.values()).filter( - (f): f is FuncAstFunctionDefinition => - f.kind === "function_definition", + public extract(debug: boolean = false): WrittenFunction[] { + // Check dependencies + const missing: Map = new Map(); + for (const f of this.functions.values()) { + for (const d of f.depends) { + if (!this.functions.has(d)) { + if (!missing.has(d)) { + missing.set(d, [f.name]); + } else { + missing.set(d, [...missing.get(d)!, f.name]); + } + } + } + } + if (missing.size > 0) { + throw new Error( + `Functions ${Array.from(missing.keys()) + .map((v) => `"${v}"`) + .join(", ")} wasn't added to the context`, + ); + } + + // All functions + let all = this.allFunctions(); + + // TODO: Remove unused + // if (!debug) { + // const used: Set = new Set(); + // const visit = (name: string) => { + // used.add(name); + // const f = this.functions.get(name); + // if (f === undefined) { + // throw new Error( + // `Cannot find functon ${name} within the CodegenContext`, + // ); + // } + // for (const d of f.depends) { + // visit(d); + // } + // }; + // visit("$main"); + // all = all.filter((v) => used.has(v.name)); + // } + + // Sort functions + const sorted = topologicalSort(all, (f) => + Array.from(f.depends).map((v) => this.functions.get(v)!), ); + + return sorted; } } diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 2d0af740e..bb39daaeb 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -492,7 +492,6 @@ export class ExpressionGen { src, this.tactExpr.args.map((v) => v.field.text), ); - this.ctx.add("function", constructor); // Write an expression const args = this.tactExpr.args.map((v) => diff --git a/src/codegen/function.ts b/src/codegen/function.ts index e043ee042..a13d7a75d 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -19,7 +19,7 @@ import { Type, tensor, } from "../func/syntaxConstructors"; -import { StatementGen, LiteralGen, CodegenContext } from "."; +import { StatementGen, LiteralGen, CodegenContext, Location } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; /** @@ -194,6 +194,8 @@ export class FunctionGen { * } * ``` * + * The generated constructor will be saved in the context. + * * @param type Type description of the struct for which the constructor is generated * @param args Names of the arguments */ @@ -236,6 +238,8 @@ export class FunctionGen { values.length === 0 && returnTy.kind === "tuple" ? [ret(call("empty_tuple", []))] : [ret(tensor(...values))]; - return fun(attrs, name, params, returnTy, body); + const constructor = fun(attrs, name, params, returnTy, body); + this.ctx.addFunction(constructor, "generic", Location.type(type.name)); + return constructor; } } diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 102393307..8d6938c62 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -1,18 +1,23 @@ import { CompilationOutput } from "../pipeline/compile"; import { CompilerContext } from "../context"; -import { CodegenContext, ModuleGen } from "."; -import { topologicalSort } from "../utils/utils"; +import { CodegenContext, ModuleGen, WrittenFunction } from "."; import { ContractABI } from "@ton/core"; import { FuncFormatter } from "../func/formatter"; -import { FuncAstModule, FuncAstFunctionDefinition } from "../func/syntax"; +import { + FuncAstModule, + FuncAstFunctionDefinition, + FuncAstAsmFunction, +} from "../func/syntax"; import { deepCopy } from "../func/syntaxUtils"; import { comment, mod, pragma, + Type, include, + global, toDeclaration, -FunAttr, + FunAttr, } from "../func/syntaxConstructors"; import { calculateIPFSlink } from "../utils/calculateIPFSlink"; @@ -69,7 +74,7 @@ export class FuncGenerator { this.abiSrc.name!, abiLink, ); - const functions = this.extractFunctions(mainContract); + const functions = this.funcCtx.extract(); this.generateHeaders(generated, functions); this.generateStdlib(generated, functions); this.generateNative(generated); @@ -129,75 +134,12 @@ export class FuncGenerator { return m; } - /** - * Extract information about the generated functions from the contract module. - */ - private extractFunctions( - mainContract: FuncAstModule, - ): FuncAstFunctionDefinition[] { - const contractFunctions = mainContract.entries.reduce((acc, e) => { - if ( - e.kind === - "function_definition" /* TODO: || e.kind === "function_declaration" */ - ) { - acc.push(e); - } - return acc; - }, [] as FuncAstFunctionDefinition[]); - const generatedFunctions = this.funcCtx.getFunctions(); - return [...contractFunctions, ...generatedFunctions]; - - // // Check dependencies - // const missing: Map = new Map(); - // for (const f of contract.entries.values()) { - // for (const d of f.depends) { - // if (!this.#functions.has(d)) { - // if (!missing.has(d)) { - // missing.set(d, [f.name]); - // } else { - // missing.set(d, [...missing.get(d)!, f.name]); - // } - // } - // } - // } - // if (missing.size > 0) { - // throw new Error( - // `Functions ${Array.from(missing.keys()) - // .map((v) => `"${v}"`) - // .join(", ")} wasn't rendered`, - // ); - // } - - // // All functions - // let all = Array.from(this.#functions.values()); - - // // Remove unused - // if (!debug) { - // const used: Set = new Set(); - // const visit = (name: string) => { - // used.add(name); - // const f = this.#functions.get(name)!; - // for (const d of f.depends) { - // visit(d); - // } - // }; - // visit("$main"); - // all = all.filter((v) => used.has(v.name)); - // } - - // Sort functions - // const sorted = topologicalSort(all, (f) => - // Array.from(f.depends).map((v) => this.#functions.get(v)!), - // ); - // return sorted; - } - /** * Generates a file that contains declarations of all the generated Func functions. */ private generateHeaders( generated: GeneratedFilesInfo, - functions: FuncAstFunctionDefinition[], + functions: WrittenFunction[], ): void { // FIXME: We should add only contract methods and special methods here => add attribute and register them in the context const m = mod(); @@ -210,16 +152,24 @@ export class FuncGenerator { ), ); functions.forEach((f) => { - // if (f.code.kind === "generic") { - m.entries.push(comment(f.name.value, { skipCR: true })); - const f_ = deepCopy(f); if ( - f_.attrs.find((attr) => attr.kind !== "impure" && attr.kind !== "inline") + f.kind === "generic" && + f.definition.kind === "function_definition" ) { - f_.attrs.push(FunAttr.inline_ref()); + m.entries.push( + comment(f.definition.name.value, { skipCR: true }), + ); + const copiedDefinition = deepCopy(f.definition); + if ( + copiedDefinition.attrs.find( + (attr) => + attr.kind !== "impure" && attr.kind !== "inline", + ) + ) { + copiedDefinition.attrs.push(FunAttr.inline_ref()); + } + m.entries.push(toDeclaration(copiedDefinition)); } - m.entries.push(toDeclaration(f_)); - // } }); generated.files.push({ name: `${this.basename}.headers.fc`, @@ -229,29 +179,28 @@ export class FuncGenerator { private generateStdlib( generated: GeneratedFilesInfo, - functions: FuncAstFunctionDefinition[], + functions: WrittenFunction[], ): void { - // const stdlibHeader = trimIndent(` - // global (int, slice, int, slice) __tact_context; - // global slice __tact_context_sender; - // global cell __tact_context_sys; - // global int __tact_randomized; - // `); - // - // const stdlibFunctions = tryExtractModule(functions, "stdlib", []); - // if (stdlibFunctions) { - // generated.imported.push("stdlib"); - // } - // - // const stdlib = emit({ - // header: stdlibHeader, - // functions: stdlibFunctions, - // }); - // - // generated.files.push({ - // name: this.basename + ".stdlib.fc", - // code: stdlib, - // }); + const m = mod(); + m.entries.push( + global( + Type.tensor(Type.int(), Type.slice(), Type.int(), Type.slice()), + "__tact_context", + ), + ); + m.entries.push(global(Type.slice(), "__tact_context_sender")); + m.entries.push(global(Type.cell(), "__tact_context_sys")); + m.entries.push(global(Type.int(), "__tact_randomized")); + + const stdlibFunctions = this.tryExtractModule(functions, "stdlib", []); + if (stdlibFunctions) { + generated.imported.push("stdlib"); + } + stdlibFunctions.forEach((f) => m.entries.push(f.definition)); + generated.files.push({ + name: `${this.basename}.stdlib.fc`, + code: new FuncFormatter().dump(m), + }); } private generateNative(generated: GeneratedFilesInfo): void { @@ -269,7 +218,7 @@ export class FuncGenerator { private generateConstants( generated: GeneratedFilesInfo, - functions: FuncAstFunctionDefinition[], + functions: WrittenFunction[], ): void { // const constantsFunctions = tryExtractModule( // functions, @@ -287,7 +236,7 @@ export class FuncGenerator { private generateStorage( generated: GeneratedFilesInfo, - functions: FuncAstFunctionDefinition[], + functions: WrittenFunction[], ): void { // const emittedTypes: string[] = []; // const types = getSortedTypes(ctx); @@ -346,4 +295,32 @@ export class FuncGenerator { // }); // } } + + private tryExtractModule( + functions: WrittenFunction[], + context: string | null, + imported: string[], + ): WrittenFunction[] { + // Put to map + const maps: Map = new Map(); + for (const f of functions) { + maps.set(f.name, f); + } + + // Extract functions of a context + const ctxFunctions: WrittenFunction[] = functions + .filter((v) => v.kind !== "skip") + .filter((v) => { + if (context) { + return v.kind === context; + } else { + return v.kind === null || !imported.includes(v.kind); + } + }); + if (ctxFunctions.length === 0) { + return []; + } + + return ctxFunctions; + } } diff --git a/src/codegen/index.ts b/src/codegen/index.ts index eaafe3d07..85cb2a430 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -1,4 +1,4 @@ -export { CodegenContext } from "./context"; +export { CodegenContext, WrittenFunction, Location } from "./context"; export { ModuleGen } from "./module"; export { FunctionGen } from "./function"; export { StatementGen } from "./statement"; diff --git a/src/codegen/literal.ts b/src/codegen/literal.ts index f11dcfe4e..99c7dd049 100644 --- a/src/codegen/literal.ts +++ b/src/codegen/literal.ts @@ -1,4 +1,4 @@ -import { CodegenContext, FunctionGen } from "."; +import { CodegenContext, FunctionGen, Location } from "."; import { FuncAstExpr } from "../func/syntax"; import { Address, beginCell, Cell } from "@ton/core"; import { Value, CommentValue } from "../types/types"; @@ -42,7 +42,7 @@ export class LiteralGen { const h = cell.hash().toString("hex"); const t = cell.toBoc({ idx: false }).toString("hex"); const funName = `__gen_slice_${prefix}_${h}`; - if (!this.ctx.has("function", funName)) { + if (!this.ctx.hasFunction(funName)) { // TODO: Add docstring: `comment` const fun = asmfun( [], @@ -51,7 +51,7 @@ export class LiteralGen { Type.slice(), `B{${t}} B>boc boc PUSHREF`, ); - this.ctx.add("function", fun); + this.ctx.addFunction(fun, "asm", Location.constants()); } return id(funName); } @@ -155,7 +155,6 @@ export class LiteralGen { const constructor = FunctionGen.fromTact( this.ctx, ).writeStructConstructor(structDescription, fields); - this.ctx.add("function", constructor); const fieldValues = structDescription.fields.map((field) => { if (field.name in val) { return this.makeValue(val[field.name]!); diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index fad6a5421..67165637c 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -462,9 +462,9 @@ export const pragma = (value: string): FuncAstPragma => ({ value, }); -export const globalVariable = ( - name: string | FuncAstIdExpr, +export const global = ( ty: FuncType, + name: string | FuncAstIdExpr, ): FuncAstGlobalVariable => ({ kind: "global_variable", name: wrapToId(name), From 39d3127476ce4d62e39bc7f850b4002510ea05be Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Mon, 22 Jul 2024 15:02:48 +0000 Subject: [PATCH 065/162] feat(codegen): Support internal receivers --- src/codegen/module.ts | 151 +++++++++++++++++++++++++++++------------- 1 file changed, 104 insertions(+), 47 deletions(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 017b64677..125266251 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -9,6 +9,7 @@ import { CompilerContext } from "../context"; import { getSortedTypes } from "../storage/resolveAllocation"; import { getMethodId } from "../utils/utils"; import { idTextErr } from "../errors"; +import { contractErrors } from "../abi/errors"; import { resolveFuncTypeUnpack, resolveFuncType, @@ -28,6 +29,7 @@ import { } from "../func/syntax"; import { cr, + unop, comment, FunParamValue, assign, @@ -442,7 +444,7 @@ export class ModuleGen { ], ), ); - functionBody.push(cr()); + functionBody.push(cr()); } } @@ -939,6 +941,104 @@ export class ModuleGen { return fun(attrs, funName, paramValues, returnTy, body); } + private makeInternalReceiver( + type: TypeDescription, + ): FuncAstFunctionDefinition { + // () recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { + const returnTy = UNIT_TYPE; + const funName = "recv_internal"; + const paramValues: FunParamValue[] = [ + ["msg_value", Type.int()], + ["in_msg_cell", Type.cell()], + ["in_msg", Type.slice()], + ]; + const attrs = [FunAttr.impure()]; + const body: FuncAstStmt[] = []; + + // Load context + body.push(comment("Context")); + body.push( + vardef( + undefined, + "cs", + call("begin_parse", [], { receiver: id("in_msg_cell") }), + ), + ); + body.push( + vardef(undefined, "msg_flags", call("cs~load_uint", [number(4)])), + ); // int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + body.push( + vardef( + undefined, + "msg_bounced", + unop("-", binop(id("msg_flags"), "&", number(1))), + ), + ); + body.push( + vardef( + Type.slice(), + id("msg_sender"), + call("__tact_verify_address", [call("cs~load_msg_addr", [])]), + ), + ); + body.push( + expr( + assign( + id("__tact_context"), + tensor( + id("msg_bounced"), + id("msg_sender_addr"), + id("msg_value"), + id("cs"), + ), + ), + ), + ); + body.push( + expr(assign(id("__tact_context_sender"), id("msg_sender_addr"))), + ); + body.push(cr()); + + // Load self + body.push(comment("Load contract data")); + body.push( + vardef(undefined, "self", call(ops.contractLoad(type.name), [])), + ); + body.push(cr()); + + // Process operation + body.push(comment("Handle operation")); + body.push( + vardef( + Type.int(), + id("handled"), + call(`self~${ops.contractRouter(type.name, "internal")}`, [ + id("msg_bounced"), + id("in_msg"), + ]), + ), + ); + body.push(cr()); + + // Throw if not handled + body.push(comment("Throw if not handled")); + body.push( + expr( + call("throw_unless", [ + number(contractErrors.invalidMessage.id), + id("handled"), + ]), + ), + ); + body.push(cr()); + + // Persist state + body.push(comment("Persist state")); + body.push(expr(call(ops.contractStore(type.name, ctx), [id("self")]))); + + return fun(attrs, funName, paramValues, returnTy, body); + } + /** * Adds entries from the main Tact contract. */ @@ -1012,52 +1112,9 @@ export class ModuleGen { m.entries.push(this.writeRouter(contractTy, "external")); } - // // Render internal receiver - // ctx.append( - // `() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure {`, - // ); - // ctx.inIndent(() => { - // // Load context - // ctx.append(); - // ctx.append(`;; Context`); - // ctx.append(`var cs = in_msg_cell.begin_parse();`); - // ctx.append(`var msg_flags = cs~load_uint(4);`); // int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool - // ctx.append(`var msg_bounced = -(msg_flags & 1);`); - // ctx.append( - // `slice msg_sender_addr = ${ctx.used("__tact_verify_address")}(cs~load_msg_addr());`, - // ); - // ctx.append( - // `__tact_context = (msg_bounced, msg_sender_addr, msg_value, cs);`, - // ); - // ctx.append(`__tact_context_sender = msg_sender_addr;`); - // ctx.append(); - // - // // Load self - // ctx.append(`;; Load contract data`); - // ctx.append(`var self = ${ops.contractLoad(type.name, ctx)}();`); - // ctx.append(); - // - // // Process operation - // ctx.append(`;; Handle operation`); - // ctx.append( - // `int handled = self~${ops.contractRouter(type.name, "internal")}(msg_bounced, in_msg);`, - // ); - // ctx.append(); - // - // // Throw if not handled - // ctx.append(`;; Throw if not handled`); - // ctx.append( - // `throw_unless(${contractErrors.invalidMessage.id}, handled);`, - // ); - // ctx.append(); - // - // // Persist state - // ctx.append(`;; Persist state`); - // ctx.append(`${ops.contractStore(type.name, ctx)}(self);`); - // }); - // ctx.append("}"); - // ctx.append(); - // + // Render internal receiver + m.entries.push(this.makeInternalReceiver(contractTy)); + // // Render external receiver // if (hasExternal) { // ctx.append(`() recv_external(slice in_msg) impure {`); From 1a655d8ec045d41a894b6cf47f4a95105ba8382a Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Mon, 22 Jul 2024 15:17:18 +0000 Subject: [PATCH 066/162] fix(codgen): Bug in the old backend --- src/codegen/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 125266251..a7b0b953a 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1025,8 +1025,8 @@ export class ModuleGen { body.push( expr( call("throw_unless", [ - number(contractErrors.invalidMessage.id), id("handled"), + number(contractErrors.invalidMessage.id), ]), ), ); From 9cddfa1999d6f2bad3bad06394f65096caf7687a Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Mon, 22 Jul 2024 15:19:12 +0000 Subject: [PATCH 067/162] feat(codegen): Support external receivers --- src/codegen/module.ts | 93 +++++++++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 34 deletions(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index a7b0b953a..aaf1b98ab 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -944,7 +944,7 @@ export class ModuleGen { private makeInternalReceiver( type: TypeDescription, ): FuncAstFunctionDefinition { - // () recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { + // () recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure const returnTy = UNIT_TYPE; const funName = "recv_internal"; const paramValues: FunParamValue[] = [ @@ -1034,7 +1034,60 @@ export class ModuleGen { // Persist state body.push(comment("Persist state")); - body.push(expr(call(ops.contractStore(type.name, ctx), [id("self")]))); + body.push(expr(call(ops.contractStore(type.name), [id("self")]))); + + return fun(attrs, funName, paramValues, returnTy, body); + } + + private makeExternalReceiver( + type: TypeDescription, + ): FuncAstFunctionDefinition { + // () recv_external(slice in_msg) impure + const returnTy = UNIT_TYPE; + const funName = "recv_internal"; + const paramValues: FunParamValue[] = [ + ["msg_value", Type.int()], + ["in_msg_cell", Type.cell()], + ["in_msg", Type.slice()], + ]; + const attrs = [FunAttr.impure()]; + const body: FuncAstStmt[] = []; + + // Load self + body.push(comment("Load contract data")); + body.push( + vardef(undefined, "self", call(ops.contractLoad(type.name), [])), + ); + body.push(cr()); + + // Process operation + body.push(comment("Handle operation")); + body.push( + vardef( + Type.int(), + id("handled"), + call(`self~${ops.contractRouter(type.name, "external")}`, [ + id("in_msg"), + ]), + ), + ); + body.push(cr()); + + // Throw if not handled + body.push(comment("Throw if not handled")); + body.push( + expr( + call("throw_unless", [ + id("handled"), + number(contractErrors.invalidMessage.id), + ]), + ), + ); + body.push(cr()); + + // Persist state + body.push(comment("Persist state")); + body.push(expr(call(ops.contractStore(type.name), [id("self")]))); return fun(attrs, funName, paramValues, returnTy, body); } @@ -1114,38 +1167,10 @@ export class ModuleGen { // Render internal receiver m.entries.push(this.makeInternalReceiver(contractTy)); - - // // Render external receiver - // if (hasExternal) { - // ctx.append(`() recv_external(slice in_msg) impure {`); - // ctx.inIndent(() => { - // // Load self - // ctx.append(`;; Load contract data`); - // ctx.append(`var self = ${ops.contractLoad(type.name, ctx)}();`); - // ctx.append(); - // - // // Process operation - // ctx.append(`;; Handle operation`); - // ctx.append( - // `int handled = self~${ops.contractRouter(type.name, "external")}(in_msg);`, - // ); - // ctx.append(); - // - // // Throw if not handled - // ctx.append(`;; Throw if not handled`); - // ctx.append( - // `throw_unless(handled, ${contractErrors.invalidMessage.id});`, - // ); - // ctx.append(); - // - // // Persist state - // ctx.append(`;; Persist state`); - // ctx.append(`${ops.contractStore(type.name, ctx)}(self);`); - // }); - // ctx.append("}"); - // ctx.append(); - // } - // }); + if (hasExternal) { + // Render external receiver + m.entries.push(this.makeExternalReceiver(contractTy)); + } } public writeAll(): FuncAstModule { From cc8848802dfae74383a8ea7d25f99ef7374bdb2f Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Tue, 23 Jul 2024 00:48:20 +0000 Subject: [PATCH 068/162] fix(codegen): Arguments of `throw_unless` See: https://github.com/tact-lang/tact/pull/604 --- src/codegen/module.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index aaf1b98ab..32855a497 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1025,8 +1025,8 @@ export class ModuleGen { body.push( expr( call("throw_unless", [ - id("handled"), number(contractErrors.invalidMessage.id), + id("handled"), ]), ), ); @@ -1078,8 +1078,8 @@ export class ModuleGen { body.push( expr( call("throw_unless", [ - id("handled"), number(contractErrors.invalidMessage.id), + id("handled"), ]), ), ); From 51defe8cb62cd940ad6342f305974bd06f765c07 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Tue, 23 Jul 2024 00:52:36 +0000 Subject: [PATCH 069/162] feat(formatter): Set parens around non-trivial unary expressions --- src/func/formatter.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 1325daf9e..886300f3f 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -385,7 +385,21 @@ export class FuncFormatter { private formatUnaryExpr(node: FuncAstUnaryExpr): string { const value = this.dump(node.value); - return `${node.op}${value}`; + const isNonTrivial = + node.value.kind !== "number_expr" && + node.value.kind !== "hex_number_expr" && + node.value.kind !== "unit_expr" && + node.value.kind !== "hole_expr" && + node.value.kind !== "tuple_expr" && + node.value.kind !== "tensor_expr" && + node.value.kind !== "primitive_type_expr" && + node.value.kind !== "bool_expr" && + node.value.kind !== "string_expr" && + node.value.kind !== "nil_expr" && + node.value.kind !== "id_expr"; + return node.op + ? `${node.op}${isNonTrivial ? `(${value})` : value}` + : value; } private formatNumberExpr(node: FuncAstNumberExpr): string { From 265cf944d481b545ba0e35c4af8c10d0bfe3f5eb Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Tue, 23 Jul 2024 02:01:22 +0000 Subject: [PATCH 070/162] feat(codegen): More convinient context API for adding function --- src/codegen/context.ts | 8 ++++---- src/codegen/function.ts | 4 +++- src/codegen/literal.ts | 10 ++++++++-- src/codegen/module.ts | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index 22fb6d3b7..9edc38c69 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -40,7 +40,7 @@ export type WrittenFunction = { name: string; definition: FuncAstFunctionDefinition | FuncAstAsmFunction; kind: BodyKind; - context: LocationContext; + context: LocationContext | undefined; depends: Set; }; @@ -60,9 +60,9 @@ export class CodegenContext { public addFunction( value: FuncAstFunctionDefinition | FuncAstAsmFunction, - bodyKind: BodyKind, - context: LocationContext, + params: Partial<{ kind: BodyKind; context: LocationContext }> = {}, ): void { + const { kind = "generic", context = undefined } = params; const definition = value as | FuncAstFunctionDefinition | FuncAstAsmFunction; @@ -70,7 +70,7 @@ export class CodegenContext { this.functions.set(definition.name.value, { name: definition.name.value, definition, - kind: bodyKind, + kind, context, depends, }); diff --git a/src/codegen/function.ts b/src/codegen/function.ts index a13d7a75d..40878fd7e 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -239,7 +239,9 @@ export class FunctionGen { ? [ret(call("empty_tuple", []))] : [ret(tensor(...values))]; const constructor = fun(attrs, name, params, returnTy, body); - this.ctx.addFunction(constructor, "generic", Location.type(type.name)); + this.ctx.addFunction(constructor, { + context: Location.type(type.name), + }); return constructor; } } diff --git a/src/codegen/literal.ts b/src/codegen/literal.ts index 99c7dd049..5cf4da800 100644 --- a/src/codegen/literal.ts +++ b/src/codegen/literal.ts @@ -51,7 +51,10 @@ export class LiteralGen { Type.slice(), `B{${t}} B>boc boc PUSHREF`, ); - this.ctx.addFunction(fun, "asm", Location.constants()); + this.ctx.addFunction(fun, { + kind: "asm", + context: Location.constants(), + }); } return id(funName); } diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 32855a497..354f3abea 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -977,7 +977,7 @@ export class ModuleGen { body.push( vardef( Type.slice(), - id("msg_sender"), + id("msg_sender_addr"), call("__tact_verify_address", [call("cs~load_msg_addr", [])]), ), ); From 2a058ecfcb38bc42ae46c4ae6fb36e519a76e06c Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Tue, 23 Jul 2024 02:01:46 +0000 Subject: [PATCH 071/162] feat(codegen): Support init and initChild functions --- src/codegen/module.ts | 257 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 256 insertions(+), 1 deletion(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 354f3abea..66513b215 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,7 +1,10 @@ import { getAllTypes, getType } from "../types/resolveDescriptors"; +import { enabledInline, enabledMasterchain } from "../config/features"; +import { LiteralGen, Location } from "."; import { ReceiverDescription, TypeDescription, + InitDescription, TypeRef, FunctionDescription, } from "../types/types"; @@ -15,8 +18,9 @@ import { resolveFuncType, resolveFuncTupleType, } from "./type"; +import { resolveFuncPrimitive } from "./primitive"; import { getSupportedInterfaces } from "../types/getSupportedInterfaces"; -import { funcIdOf, ops } from "./util"; +import { funcIdOf, funcInitIdOf, ops } from "./util"; import { UNIT_TYPE, FuncAstModule, @@ -187,6 +191,252 @@ export class ModuleGen { ); } + /** + * Adds the init function and the init utility function to the context. + * + * TODO: Create two separate functions when refactoring + */ + private writeInit(t: TypeDescription, init: InitDescription) { + { + const returnTy = resolveFuncType(this.ctx.ctx, t); + const funName = ops.contractInit(t.name); + const paramValues: FunParamValue[] = init.params.map((v) => [ + funcIdOf(v.name), + resolveFuncType(this.ctx.ctx, v.type), + ]); + const attrs = [FunAttr.impure()]; + const body: FuncAstStmt[] = []; + + // Unpack parameters + for (const a of init.params) { + if (!resolveFuncPrimitive(this.ctx.ctx, a.type)) { + body.push( + vardef( + undefined, + resolveFuncTypeUnpack( + this.ctx.ctx, + a.type, + funcIdOf(a.name), + ), + id(funcIdOf(a.name)), + ), + ); + } + } + + // Generate self initial tensor + const initValues: FuncAstExpr[] = t.fields.map((tField) => + tField.default === undefined + ? call("null", []) + : LiteralGen.fromTact( + this.ctx, + tField.default!, + ).writeValue(), + ); + if (initValues.length > 0) { + // Special case for empty contracts + body.push( + vardef( + undefined, + resolveFuncTypeUnpack( + this.ctx.ctx, + t, + funcIdOf("self"), + ), + tensor(...initValues), + ), + ); + } else { + body.push( + vardef(Type.tuple(), funcIdOf("self"), call("null", [])), + ); + } + + // Generate statements + const returns = resolveFuncTypeUnpack( + this.ctx.ctx, + t, + funcIdOf("self"), + ); + for (const s of init.ast.statements) { + body.push( + StatementGen.fromTact( + this.ctx, + s, + returns, + ).writeStatement(), + ); + } + + // Return result + if ( + init.ast.statements.length === 0 || + init.ast.statements[init.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + body.push(ret(id(returns))); + } + + const initFun = fun(attrs, funName, paramValues, returnTy, body); + this.ctx.addFunction(initFun); + } + + { + const returnTy = Type.tensor(Type.cell(), Type.cell()); + const funName = ops.contractInitChild(t.name); + const paramValues: FunParamValue[] = [ + ["sys", Type.cell()], + ...init.params.map( + (v) => + [ + funcIdOf(v.name), + resolveFuncType(this.ctx.ctx, v.type), + ] as FunParamValue, + ), + ]; + const attrs = [ + ...(enabledInline(this.ctx.ctx) ? [FunAttr.inline()] : []), + ]; + const body: FuncAstStmt[] = []; + + // slice sc' = sys'.begin_parse(); + // cell source = sc'~load_dict(); + // cell contracts = new_dict(); + // + // ;; Contract Code: ${t.name} + // cell mine = __tact_dict_get_code(source, ${t.uid}); + // contracts = __tact_dict_set_code(contracts, ${t.uid}, mine); + body.push( + vardef( + Type.slice(), + "sc'", + call("begin_parse", [], { receiver: id("sys'") }), + ), + ); + body.push(vardef(Type.cell(), "source", call("sc'~load_dict", []))); + body.push(vardef(Type.cell(), "contracts", call("new_dict", []))); + body.push(cr()); + body.push(comment(`Contract Code: ${t.name}`)); + body.push( + vardef( + Type.cell(), + "mine", + call("__tact_dict_get_code", [id("source"), number(t.uid)]), + ), + ); + body.push( + expr( + assign( + id("contracts"), + call("__tact_dict_set_code", [ + id("contracts"), + number(t.uid), + id("mine"), + ]), + ), + ), + ); + + // Copy contracts code + for (const c of t.dependsOn) { + // ;; Contract Code: ${c.name} + // cell code_${c.uid} = __tact_dict_get_code(source, ${c.uid}); + // contracts = __tact_dict_set_code(contracts, ${c.uid}, code_${c.uid}); + body.push(cr()); + body.push(comment(`Contract Code: ${c.name}`)); + body.push( + vardef( + Type.cell(), + `code_${c.uid}`, + call("__tact_dict_get_code", [ + id("source"), + number(c.uid), + ]), + ), + ); + body.push( + expr( + assign( + id("contracts"), + call("__tact_dict_set_code", [ + id("contracts"), + number(c.uid), + id(`code_${c.uid}`), + ]), + ), + ), + ); + } + + // Build cell + body.push(cr()); + body.push(comment("Build cell")); + body.push(vardef(Type.builder(), "b", call("begin_cell", []))); + // b = b.store_ref(begin_cell().store_dict(contracts).end_cell()); + body.push( + expr( + assign( + id("b"), + call( + "store_ref", + [ + call("end_cell", [], { + receiver: call( + "store_dict", + [id("contracts")], + { receiver: call("begin_cell", []) }, + ), + }), + ], + { receiver: id("b") }, + ), + ), + ), + ); + // b = b.store_int(false, 1); + body.push( + expr( + assign( + id("b"), + call("store_int", [bool(false), number(1)], { + receiver: id("b"), + }), + ), + ), + ); + const args = + t.init!.params.length > 0 + ? [ + call( + "b", + t.init!.params.map((a) => id(funcIdOf(a.name))), + ), + ] + : [id("b"), call("null", [])]; + body.push( + expr( + assign( + id("b"), + call(`${ops.writer(funcInitIdOf(t.name))}`, args), + ), + ), + ); + body.push( + ret( + tensor( + id("mine"), + call("end_cell", [], { receiver: id("b") }), + ), + ), + ); + + this.ctx.addFunction( + fun(attrs, funName, paramValues, returnTy, body), + { context: Location.type("type:" + t.name + "$init") }, + ); + } + } + /** * Adds functions defined within the Tact contract to the generated Func module. * TODO: Why do we need function from *all* the contracts? @@ -194,10 +444,15 @@ export class ModuleGen { private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { m.entries.push(comment("", `Contract ${c.name} functions`, "")); + if (c.init) { + this.writeInit(c, c.init); + } + for (const tactFun of c.functions.values()) { const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( tactFun, ); + // TODO: Should we really put them here? m.entries.push(funcFun); } } From d9a9e59b39c5ad704e5418d5a53db4d39f0a90b1 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Tue, 23 Jul 2024 02:01:59 +0000 Subject: [PATCH 072/162] feat(codegen): Add primitives --- src/codegen/primitive.ts | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/codegen/primitive.ts diff --git a/src/codegen/primitive.ts b/src/codegen/primitive.ts new file mode 100644 index 000000000..4e7c1181d --- /dev/null +++ b/src/codegen/primitive.ts @@ -0,0 +1,57 @@ +import { CompilerContext } from "../context"; +import { getType } from "../types/resolveDescriptors"; +import { TypeDescription, TypeRef } from "../types/types"; + +export function resolveFuncPrimitive( + ctx: CompilerContext, + descriptor: TypeRef | TypeDescription | string, +): boolean { + // String + if (typeof descriptor === "string") { + return resolveFuncPrimitive(ctx, getType(ctx, descriptor)); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncPrimitive(ctx, getType(ctx, descriptor.name)); + } + if (descriptor.kind === "map") { + return true; + } + if (descriptor.kind === "ref_bounced") { + throw Error("Unimplemented"); + } + if (descriptor.kind === "void") { + return true; + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + if (descriptor.name === "Int") { + return true; + } else if (descriptor.name === "Bool") { + return true; + } else if (descriptor.name === "Slice") { + return true; + } else if (descriptor.name === "Cell") { + return true; + } else if (descriptor.name === "Builder") { + return true; + } else if (descriptor.name === "Address") { + return true; + } else if (descriptor.name === "String") { + return true; + } else if (descriptor.name === "StringBuilder") { + return true; + } else { + throw Error(`Unknown primitive type: ${descriptor.name}`); + } + } else if (descriptor.kind === "struct") { + return false; + } else if (descriptor.kind === "contract") { + return false; + } + + // Unreachable + throw Error(`Unknown type: ${descriptor.kind}`); +} From d27e246b3f21ad3b1dd9e2a12c0ada7d88f03bad Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Tue, 23 Jul 2024 04:36:39 +0000 Subject: [PATCH 073/162] chore(codegen): Revisit the structure of `writeProgram` --- src/codegen/generator.ts | 52 +++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 8d6938c62..5a8cc5ab1 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -69,18 +69,48 @@ export class FuncGenerator { const abi = JSON.stringify(this.abiSrc); const abiLink = await calculateIPFSlink(Buffer.from(abi)); - const generated: GeneratedFilesInfo = { files: [], imported: [] }; const mainContract = this.generateMainContract( this.abiSrc.name!, abiLink, ); + // TODO: writeAll const functions = this.funcCtx.extract(); + + // + // Emit files + // + const generated: GeneratedFilesInfo = { files: [], imported: [] }; + + // + // Headers + // this.generateHeaders(generated, functions); + + // + // stdlib + // this.generateStdlib(generated, functions); + + // + // native + // this.generateNative(generated); + + // + // constants + // this.generateConstants(generated, functions); + + // + // storage + // this.generateStorage(generated, functions); + // + // Remaining + // + // TODO + // Finalize and dump the main contract, as we have just obtained the structure of the project mainContract.entries.unshift( ...generated.files.map((f) => include(f.name)), @@ -204,16 +234,16 @@ export class FuncGenerator { } private generateNative(generated: GeneratedFilesInfo): void { - // const nativeSources = getRawAST(ctx).funcSources; - // if (nativeSources.length > 0) { - // generated.imported.push("native"); - // generated.files.push({ - // name: this.basename + ".native.fc", - // code: emit({ - // header: [...nativeSources.map((v) => v.code)].join("\n\n"), - // }), - // }); - // } + const nativeSources = getRawAST(ctx).funcSources; + if (nativeSources.length > 0) { + generated.imported.push("native"); + generated.files.push({ + name: this.basename + ".native.fc", + code: emit({ + header: [...nativeSources.map((v) => v.code)].join("\n\n"), + }), + }); + } } private generateConstants( From 6929720160332846d66ce2dc608b901e019db457 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Tue, 23 Jul 2024 04:39:45 +0000 Subject: [PATCH 074/162] feat(codegen): Support native Func code --- src/codegen/generator.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 5a8cc5ab1..dfd8d97b4 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -1,6 +1,7 @@ import { CompilationOutput } from "../pipeline/compile"; import { CompilerContext } from "../context"; import { CodegenContext, ModuleGen, WrittenFunction } from "."; +import { getRawAST } from "../grammar/store"; import { ContractABI } from "@ton/core"; import { FuncFormatter } from "../func/formatter"; import { @@ -234,14 +235,13 @@ export class FuncGenerator { } private generateNative(generated: GeneratedFilesInfo): void { - const nativeSources = getRawAST(ctx).funcSources; + const nativeSources = getRawAST(this.funcCtx.ctx).funcSources; if (nativeSources.length > 0) { generated.imported.push("native"); generated.files.push({ - name: this.basename + ".native.fc", - code: emit({ - header: [...nativeSources.map((v) => v.code)].join("\n\n"), - }), + name: `${this.basename}.native.fc`, + code: + [...nativeSources.map((v) => v.code)].join("\n\n"), }); } } From 0ecdaba2c0802834c95645ec5060b0315c1f7c2e Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Tue, 23 Jul 2024 04:45:33 +0000 Subject: [PATCH 075/162] feat(codegen): Generate the constants file --- src/codegen/generator.ts | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index dfd8d97b4..15ae1979f 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -239,9 +239,8 @@ export class FuncGenerator { if (nativeSources.length > 0) { generated.imported.push("native"); generated.files.push({ - name: `${this.basename}.native.fc`, - code: - [...nativeSources.map((v) => v.code)].join("\n\n"), + name: `${this.basename}.native.fc`, + code: [...nativeSources.map((v) => v.code)].join("\n\n"), }); } } @@ -250,18 +249,20 @@ export class FuncGenerator { generated: GeneratedFilesInfo, functions: WrittenFunction[], ): void { - // const constantsFunctions = tryExtractModule( - // functions, - // "constants", - // imported, - // ); - // if (constantsFunctions) { - // generated.imported.push("constants"); - // generated.files.push({ - // name: this.basename + ".constants.fc", - // code: emit({ functions: constantsFunctions }), - // }); - // } + const constantsFunctions = this.tryExtractModule( + functions, + "constants", + generated.imported, + ); + if (constantsFunctions) { + generated.imported.push("constants"); + generated.files.push({ + name: `${this.basename}.constants.fc`, + code: new FuncFormatter().dump( + mod(...constantsFunctions.map((v) => v.definition)), + ), + }); + } } private generateStorage( From 34df3be0483a81c2d9a29357a4660175f0ba41a3 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Wed, 24 Jul 2024 01:00:27 +0000 Subject: [PATCH 076/162] feat(codegen): Support storage --- src/codegen/context.ts | 17 +++++ src/codegen/generator.ts | 138 ++++++++++++++++++++------------------- src/codegen/index.ts | 10 ++- 3 files changed, 97 insertions(+), 68 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index 9edc38c69..3013a6266 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -21,6 +21,23 @@ export type LocationContext = | { kind: "constants" } | { kind: "type"; value: string }; +export function locEquals(lhs: LocationContext, rhs: LocationContext): boolean { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === "type" && rhs.kind === "type") { + return lhs.value === rhs.value; + } + return true; +} + +/** + * Returns string value of the location context "as in the old backend". + */ +export function locValue(loc: LocationContext): string { + return loc.kind === "type" ? `type:${loc.value}` : loc.kind; +} + export class Location { public static stdlib(): LocationContext { return { kind: "stdlib" }; diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 15ae1979f..611c8ed0c 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -1,14 +1,13 @@ import { CompilationOutput } from "../pipeline/compile"; +import { getSortedTypes } from "../storage/resolveAllocation"; import { CompilerContext } from "../context"; +import { idToHex } from "../utils/idToHex"; +import { LocationContext, Location, locEquals, locValue } from "."; import { CodegenContext, ModuleGen, WrittenFunction } from "."; import { getRawAST } from "../grammar/store"; import { ContractABI } from "@ton/core"; import { FuncFormatter } from "../func/formatter"; -import { - FuncAstModule, - FuncAstFunctionDefinition, - FuncAstAsmFunction, -} from "../func/syntax"; +import { FuncAstModule, FuncAstComment } from "../func/syntax"; import { deepCopy } from "../func/syntaxUtils"; import { comment, @@ -223,7 +222,11 @@ export class FuncGenerator { m.entries.push(global(Type.cell(), "__tact_context_sys")); m.entries.push(global(Type.int(), "__tact_randomized")); - const stdlibFunctions = this.tryExtractModule(functions, "stdlib", []); + const stdlibFunctions = this.tryExtractModule( + functions, + Location.stdlib(), + [], + ); if (stdlibFunctions) { generated.imported.push("stdlib"); } @@ -251,7 +254,7 @@ export class FuncGenerator { ): void { const constantsFunctions = this.tryExtractModule( functions, - "constants", + Location.constants(), generated.imported, ); if (constantsFunctions) { @@ -269,67 +272,65 @@ export class FuncGenerator { generated: GeneratedFilesInfo, functions: WrittenFunction[], ): void { - // const emittedTypes: string[] = []; - // const types = getSortedTypes(ctx); - // for (const t of types) { - // const ffs: WrittenFunction[] = []; - // if ( - // t.kind === "struct" || - // t.kind === "contract" || - // t.kind == "trait" - // ) { - // const typeFunctions = tryExtractModule( - // functions, - // "type:" + t.name, - // generated.imported, - // ); - // if (typeFunctions) { - // generated.imported.push("type:" + t.name); - // ffs.push(...typeFunctions); - // } - // } - // if (t.kind === "contract") { - // const typeFunctions = tryExtractModule( - // functions, - // "type:" + t.name + "$init", - // generated.imported, - // ); - // if (typeFunctions) { - // generated.imported.push("type:" + t.name + "$init"); - // ffs.push(...typeFunctions); - // } - // } - // if (ffs.length > 0) { - // const header: string[] = []; - // header.push(";;"); - // header.push(`;; Type: ${t.name}`); - // if (t.header !== null) { - // header.push(`;; Header: 0x${idToHex(t.header)}`); - // } - // if (t.tlb) { - // header.push(`;; TLB: ${t.tlb}`); - // } - // header.push(";;"); - // - // emittedTypes.push( - // emit({ - // functions: ffs, - // header: header.join("\n"), - // }), - // ); - // } - // } - // if (emittedTypes.length > 0) { - // generated.files.push({ - // name: this.basename + ".storage.fc", - // code: [...emittedTypes].join("\n\n"), - // }); - // } + const generatedModules: FuncAstModule[] = []; + const types = getSortedTypes(this.funcCtx.ctx); + for (const t of types) { + const ffs: WrittenFunction[] = []; + if ( + t.kind === "struct" || + t.kind === "contract" || + t.kind == "trait" + ) { + const typeFunctions = this.tryExtractModule( + functions, + Location.type(t.name), + generated.imported, + ); + if (typeFunctions) { + generated.imported.push(`type:${t.name}`); + ffs.push(...typeFunctions); + } + } + if (t.kind === "contract") { + const typeFunctions = this.tryExtractModule( + functions, + Location.type(`${t.name}$init`), + generated.imported, + ); + if (typeFunctions) { + generated.imported.push("type:" + t.name + "$init"); + ffs.push(...typeFunctions); + } + } + const comments: string[] = []; + if (ffs.length > 0) { + comments.push(""); + comments.push(`Type: ${t.name}`); + if (t.header !== null) { + comments.push(`Header: 0x${idToHex(t.header)}`); + } + if (t.tlb) { + comments.push(`TLB: ${t.tlb}`); + } + comments.push(""); + } + generatedModules.push( + mod(...[comment(...comments), ...ffs.map((f) => f.definition)]), + ); + } + if (generatedModules.length > 0) { + generated.files.push({ + name: `${this.basename}.storage.fc`, + code: generatedModules + .map((m) => new FuncFormatter().dump(m)) + .join("\n\n"), + }); + } } private tryExtractModule( functions: WrittenFunction[], - context: string | null, + location: LocationContext, imported: string[], ): WrittenFunction[] { // Put to map @@ -342,10 +343,13 @@ export class FuncGenerator { const ctxFunctions: WrittenFunction[] = functions .filter((v) => v.kind !== "skip") .filter((v) => { - if (context) { - return v.kind === context; + if (location !== undefined && v.context !== undefined) { + return locEquals(v.context, location); } else { - return v.kind === null || !imported.includes(v.kind); + return ( + v.context === undefined || + !imported.includes(locValue(v.context)) + ); } }); if (ctxFunctions.length === 0) { diff --git a/src/codegen/index.ts b/src/codegen/index.ts index 85cb2a430..872ecb16a 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -1,4 +1,12 @@ -export { CodegenContext, WrittenFunction, Location } from "./context"; +export { + CodegenContext, + WrittenFunction, + Location, + LocationContext, + BodyKind, + locEquals, + locValue, +} from "./context"; export { ModuleGen } from "./module"; export { FunctionGen } from "./function"; export { StatementGen } from "./statement"; From 089e87c3210479d7f1ba51a089c1d3a8d7c70789 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Wed, 24 Jul 2024 01:22:12 +0000 Subject: [PATCH 077/162] fix(formatter): Extra space in fun declarations w/o attrs --- src/func/formatter.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index 886300f3f..bda7c7116 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -210,13 +210,16 @@ export class FuncFormatter { params: FuncAstFormalFunctionParam[], returnTy: FuncType, ): string { - const attrsStr = attrs.map(this.formatFunctionAttribute).join(" "); + const attrsStr = + attrs.length === 0 + ? "" + : ` ${attrs.map(this.formatFunctionAttribute).join(" ")}`; const nameStr = this.dump(name); const paramsStr = params .map((param) => `${this.dump(param.ty)} ${this.dump(param.name)}`) .join(", "); const returnTypeStr = this.dump(returnTy); - return `${returnTypeStr} ${nameStr}(${paramsStr}) ${attrsStr}`; + return `${returnTypeStr} ${nameStr}(${paramsStr})${attrsStr}`; } private formatFunctionDeclaration( From 8e97c7eb5623beeb3fc82d0c1a3fa8c98f5ddd71 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Wed, 24 Jul 2024 10:11:10 +0000 Subject: [PATCH 078/162] feat(syntax): Func syntax iterator --- src/func/iterators.ts | 151 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 src/func/iterators.ts diff --git a/src/func/iterators.ts b/src/func/iterators.ts new file mode 100644 index 000000000..27775c3c8 --- /dev/null +++ b/src/func/iterators.ts @@ -0,0 +1,151 @@ +import { FuncAstNode, FuncAstExpr } from "./syntax"; + +import JSONbig from "json-bigint"; + +/** + * Recursively executes `callback` on each nested expression. + * + * NOTE: It doesn't traverse raw assembly (present as string literals) and + * identifier expressions that represent names. + */ +export function forEachExpression( + node: FuncAstNode, + callback: (expr: FuncAstExpr) => void, +): void { + if ("kind" in node) { + switch (node.kind) { + // Expressions + case "id_expr": + case "number_expr": + case "hex_number_expr": + case "bool_expr": + case "string_expr": + case "nil_expr": + case "unit_expr": + case "primitive_type_expr": + callback(node); + break; + case "call_expr": + if (node.receiver) forEachExpression(node.receiver, callback); + forEachExpression(node.fun, callback); + node.args.forEach((arg) => forEachExpression(arg, callback)); + callback(node); + break; + case "assign_expr": + case "augmented_assign_expr": + forEachExpression(node.lhs, callback); + forEachExpression(node.rhs, callback); + callback(node); + break; + case "ternary_expr": + forEachExpression(node.cond, callback); + forEachExpression(node.trueExpr, callback); + forEachExpression(node.falseExpr, callback); + callback(node); + break; + case "binary_expr": + forEachExpression(node.lhs, callback); + forEachExpression(node.rhs, callback); + callback(node); + break; + case "unary_expr": + forEachExpression(node.value, callback); + callback(node); + break; + case "apply_expr": + forEachExpression(node.lhs, callback); + forEachExpression(node.rhs, callback); + callback(node); + break; + case "tuple_expr": + case "tensor_expr": + node.values.forEach((value) => + forEachExpression(value, callback), + ); + callback(node); + break; + case "hole_expr": + forEachExpression(node.init, callback); + callback(node); + break; + + // Statements + case "var_def_stmt": + if (node.init) forEachExpression(node.init, callback); + break; + case "return_stmt": + if (node.value) forEachExpression(node.value, callback); + break; + case "block_stmt": + node.body.forEach((stmt) => forEachExpression(stmt, callback)); + break; + case "repeat_stmt": + forEachExpression(node.condition, callback); + node.body.forEach((stmt) => forEachExpression(stmt, callback)); + break; + case "condition_stmt": + if (node.condition) forEachExpression(node.condition, callback); + node.body.forEach((stmt) => forEachExpression(stmt, callback)); + if (node.else) forEachExpression(node.else, callback); + break; + case "do_until_stmt": + node.body.forEach((stmt) => forEachExpression(stmt, callback)); + forEachExpression(node.condition, callback); + break; + case "while_stmt": + forEachExpression(node.condition, callback); + node.body.forEach((stmt) => forEachExpression(stmt, callback)); + break; + case "expr_stmt": + forEachExpression(node.expr, callback); + break; + case "try_catch_stmt": + node.tryBlock.forEach((stmt) => + forEachExpression(stmt, callback), + ); + node.catchBlock.forEach((stmt) => + forEachExpression(stmt, callback), + ); + break; + + // Other and top-level elements + case "constant": + forEachExpression(node.init, callback); + break; + case "function_definition": + node.body.forEach((stmt) => forEachExpression(stmt, callback)); + break; + case "asm_function_definition": + // Do nothing; we don't iterate raw asm + break; + case "comment": + case "cr": + case "include": + case "pragma": + case "global_variable": + case "function_declaration": + // These nodes don't contain expressions, so we don't need to do anything + break; + case "module": + node.entries.forEach((entry) => + forEachExpression(entry, callback), + ); + break; + + // FuncType cases + case "int": + case "cell": + case "slice": + case "builder": + case "cont": + case "tuple": + case "tensor": + case "hole": + case "type": + break; + + default: + throw new Error(`Unsupported node: ${JSONbig.stringify(node)}`); + } + } +} From a938e04c90d9fcff78c95ec4f33c41357fee073a Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Wed, 24 Jul 2024 10:40:18 +0000 Subject: [PATCH 079/162] feat(codegen): Automatic depdendency detection Extended the logic of the context to automatically detect dependencies between functions based on the given AST. It replicates the previous `WriterContext` logic, but makes things less "imperative", removing state variables. --- src/codegen/context.ts | 147 +++++++++++++++++++++++++++++--------- src/codegen/expression.ts | 6 +- src/codegen/function.ts | 12 ++-- src/codegen/generator.ts | 8 +-- src/codegen/index.ts | 2 +- src/codegen/literal.ts | 14 ++-- src/codegen/module.ts | 63 +++++++++------- src/codegen/statement.ts | 6 +- 8 files changed, 175 insertions(+), 83 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index 3013a6266..fda9e0b24 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -1,6 +1,15 @@ import { CompilerContext } from "../context"; import { topologicalSort } from "../utils/utils"; -import { FuncAstFunctionDefinition, FuncAstAsmFunction } from "../func/syntax"; +import { + FuncAstFunctionDefinition, + FuncAstAsmFunction, + FuncAstFunctionAttribute, + FuncAstIdExpr, + FuncType, + FuncAstStmt, +} from "../func/syntax"; +import { asmfun, fun, FunParamValue } from "../func/syntaxConstructors"; +import { forEachExpression } from "../func/iterators"; /** * An additional information on how to handle the function definition. @@ -9,6 +18,12 @@ import { FuncAstFunctionDefinition, FuncAstAsmFunction } from "../func/syntax"; */ export type BodyKind = "asm" | "skip" | "generic"; +export type FunctionInfo = { + kind: BodyKind; + context: LocationContext; + inMainContract: boolean; +}; + /** * Replicates the `ctx.context` parameter of the old backends Writer context. * Basically, it tells in which file the context value should be located in the @@ -52,21 +67,24 @@ export class Location { } } -// TODO: Rename when refactoring export type WrittenFunction = { name: string; definition: FuncAstFunctionDefinition | FuncAstAsmFunction; kind: BodyKind; context: LocationContext | undefined; depends: Set; + inMainContract: boolean; // true iff it should be placed in $main in the old backend }; /** - * The context containing the objects generated from the bottom-up in the generation - * process and other intermediate information. + * The context containing objects generated by the codegen and stores the + * required intermediate information. + * + * It implements the original WriterContext, but keeps AST elements instead and + * doesn't pretend to implement any formatting/code emitting logic. */ -export class CodegenContext { - public ctx: CompilerContext; +export class WriterContext { + public readonly ctx: CompilerContext; /** Generated functions. */ private functions: Map = new Map(); @@ -75,35 +93,98 @@ export class CodegenContext { this.ctx = ctx; } - public addFunction( + /** + * Analyses the AST of the function saving names of the functions it calls under the hood. + */ + private addDependencies( + fun: FuncAstFunctionDefinition, + depends: Set, + ): void { + forEachExpression(fun, (expr) => { + // TODO: It doesn't save receivers. But should it? + if (expr.kind === "call_expr" && expr.fun.kind === "id_expr") { + depends.add(expr.fun.value); + } + }); + } + + /** + * Saves an information about the function in the context automatically extracting + * info about the dependencies: functions that it calls. + */ + public save( value: FuncAstFunctionDefinition | FuncAstAsmFunction, - params: Partial<{ kind: BodyKind; context: LocationContext }> = {}, + params: Partial = {}, ): void { - const { kind = "generic", context = undefined } = params; + const { + kind = "generic", + context = undefined, + inMainContract = false, + } = params; const definition = value as | FuncAstFunctionDefinition | FuncAstAsmFunction; - const depends: Set = new Set(); + const depends = new Set(); + if (value.kind === "function_definition") { + this.addDependencies(value, depends); + } this.functions.set(definition.name.value, { name: definition.name.value, definition, kind, context, depends, + inMainContract, }); } - public hasFunction(name: string) { + /** + * Wraps the function definition constructor saving it to the context. + * XXX: Replicates old WriterContext.fun + */ + public fun( + attrs: FuncAstFunctionAttribute[], + name: string | FuncAstIdExpr, + paramValues: FunParamValue[], + returnTy: FuncType, + body: FuncAstStmt[], + params: Partial = {}, + ): FuncAstFunctionDefinition { + const f = fun(attrs, name, paramValues, returnTy, body); + this.save(f, params); + return f; + } + + /** + * Wraps the asm function definition constructor saving it to the context. + * XXX: Replicates old WriterContext.asm + */ + public asm( + attrs: FuncAstFunctionAttribute[], + name: string | FuncAstIdExpr, + paramValues: FunParamValue[], + returnTy: FuncType, + rawAsm: string, + params: Partial = {}, + ): FuncAstAsmFunction { + const f = asmfun(attrs, name, paramValues, returnTy, rawAsm); + this.save(f, params); + return f; + } + + public hasFunction(name: string): boolean { return this.functions.has(name); } - public allFunctions(): WrittenFunction[] { + private allFunctions(): WrittenFunction[] { return Array.from(this.functions.values()); } - /** - * XXX: Replicates WriteContext.extract - */ + // Functions that are defined in the $main "section" of the old backend. + private mainFunctions(): WrittenFunction[] { + return this.allFunctions().filter((f) => f.inMainContract); + } + public extract(debug: boolean = false): WrittenFunction[] { // Check dependencies const missing: Map = new Map(); @@ -129,24 +210,24 @@ export class CodegenContext { // All functions let all = this.allFunctions(); - // TODO: Remove unused - // if (!debug) { - // const used: Set = new Set(); - // const visit = (name: string) => { - // used.add(name); - // const f = this.functions.get(name); - // if (f === undefined) { - // throw new Error( - // `Cannot find functon ${name} within the CodegenContext`, - // ); - // } - // for (const d of f.depends) { - // visit(d); - // } - // }; - // visit("$main"); - // all = all.filter((v) => used.has(v.name)); - // } + // Remove unused + if (!debug) { + const used: Set = new Set(); + const visit = (name: string) => { + used.add(name); + const f = this.functions.get(name); + if (f === undefined) { + throw new Error( + `Cannot find function ${name} within the CodegenContext`, + ); + } + for (const d of f.depends) { + visit(d); + } + }; + this.mainFunctions().forEach((f) => visit(f.name)); + all = all.filter((v) => used.has(v.name)); + } // Sort functions const sorted = topologicalSort(all, (f) => diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index bb39daaeb..04a6458e8 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -7,7 +7,7 @@ import { evalConstantExpression } from "../constEval"; import { resolveFuncTypeUnpack } from "./type"; import { MapFunctions, StructFunctions, GlobalFunctions } from "./abi"; import { getExpType } from "../types/resolveExpression"; -import { FunctionGen, CodegenContext, LiteralGen } from "."; +import { FunctionGen, WriterContext, LiteralGen } from "."; import { cast, funcIdOf, ops } from "./util"; import { printTypeRef, TypeRef, Value, FieldDescription } from "../types/types"; import { @@ -63,12 +63,12 @@ export class ExpressionGen { * @param tactExpr Expression to translate. */ private constructor( - private ctx: CodegenContext, + private ctx: WriterContext, private tactExpr: AstExpression, ) {} static fromTact( - ctx: CodegenContext, + ctx: WriterContext, tactExpr: AstExpression, ): ExpressionGen { return new ExpressionGen(ctx, tactExpr); diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 40878fd7e..2a610896d 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -19,7 +19,7 @@ import { Type, tensor, } from "../func/syntaxConstructors"; -import { StatementGen, LiteralGen, CodegenContext, Location } from "."; +import { StatementGen, LiteralGen, WriterContext, Location } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; /** @@ -29,9 +29,9 @@ export class FunctionGen { /** * @param tactFun Type description of the Tact function. */ - private constructor(private ctx: CodegenContext) {} + private constructor(private ctx: WriterContext) {} - static fromTact(ctx: CodegenContext): FunctionGen { + static fromTact(ctx: WriterContext): FunctionGen { return new FunctionGen(ctx); } @@ -183,7 +183,7 @@ export class FunctionGen { body.push(funcStmt); }); - return fun(attrs, name, params, returnTy, body); + return this.ctx.fun(attrs, name, params, returnTy, body); } /** @@ -238,8 +238,8 @@ export class FunctionGen { values.length === 0 && returnTy.kind === "tuple" ? [ret(call("empty_tuple", []))] : [ret(tensor(...values))]; - const constructor = fun(attrs, name, params, returnTy, body); - this.ctx.addFunction(constructor, { + const constructor = this.ctx.fun(attrs, name, params, returnTy, body); + this.ctx.save(constructor, { context: Location.type(type.name), }); return constructor; diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 611c8ed0c..60b08fd6e 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -3,7 +3,7 @@ import { getSortedTypes } from "../storage/resolveAllocation"; import { CompilerContext } from "../context"; import { idToHex } from "../utils/idToHex"; import { LocationContext, Location, locEquals, locValue } from "."; -import { CodegenContext, ModuleGen, WrittenFunction } from "."; +import { WriterContext, ModuleGen, WrittenFunction } from "."; import { getRawAST } from "../grammar/store"; import { ContractABI } from "@ton/core"; import { FuncFormatter } from "../func/formatter"; @@ -40,7 +40,7 @@ export class FuncGenerator { private abiSrc: ContractABI; /** Basename used e.g. to name the generated Func files. */ private basename: string; - private funcCtx: CodegenContext; + private funcCtx: WriterContext; private constructor( tactCtx: CompilerContext, @@ -50,7 +50,7 @@ export class FuncGenerator { this.tactCtx = tactCtx; this.abiSrc = abiSrc; this.basename = basename; - this.funcCtx = new CodegenContext(tactCtx); + this.funcCtx = new WriterContext(tactCtx); } static fromTactProject( @@ -150,7 +150,7 @@ export class FuncGenerator { /** * Runs the generation of the main contract. - * This generates some entries from the bottom-up saving them in CodegenContext. + * This generates some entries from the bottom-up saving them in WriterContext. */ private generateMainContract( mainContractName: string, diff --git a/src/codegen/index.ts b/src/codegen/index.ts index 872ecb16a..ec32a3785 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -1,5 +1,5 @@ export { - CodegenContext, + WriterContext, WrittenFunction, Location, LocationContext, diff --git a/src/codegen/literal.ts b/src/codegen/literal.ts index 5cf4da800..6d258b1f8 100644 --- a/src/codegen/literal.ts +++ b/src/codegen/literal.ts @@ -1,4 +1,4 @@ -import { CodegenContext, FunctionGen, Location } from "."; +import { WriterContext, FunctionGen, Location } from "."; import { FuncAstExpr } from "../func/syntax"; import { Address, beginCell, Cell } from "@ton/core"; import { Value, CommentValue } from "../types/types"; @@ -23,11 +23,11 @@ export class LiteralGen { * @param tactExpr Expression to translate. */ private constructor( - private ctx: CodegenContext, + private ctx: WriterContext, private tactValue: Value, ) {} - static fromTact(ctx: CodegenContext, tactValue: Value): LiteralGen { + static fromTact(ctx: WriterContext, tactValue: Value): LiteralGen { return new LiteralGen(ctx, tactValue); } @@ -44,14 +44,14 @@ export class LiteralGen { const funName = `__gen_slice_${prefix}_${h}`; if (!this.ctx.hasFunction(funName)) { // TODO: Add docstring: `comment` - const fun = asmfun( + const fun = this.ctx.asm( [], funName, [], Type.slice(), `B{${t}} B>boc boc PUSHREF`, ); - this.ctx.addFunction(fun, { + this.ctx.save(fun, { kind: "asm", context: Location.constants(), }); diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 66513b215..98968f6af 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -56,7 +56,7 @@ import { condition, id, } from "../func/syntaxConstructors"; -import { FunctionGen, StatementGen, CodegenContext } from "."; +import { FunctionGen, StatementGen, WriterContext } from "."; import { beginCell } from "@ton/core"; import JSONbig from "json-bigint"; @@ -117,13 +117,13 @@ export function unwrapExternal( */ export class ModuleGen { private constructor( - private ctx: CodegenContext, + private ctx: WriterContext, private contractName: string, private abiLink: string, ) {} static fromTact( - ctx: CodegenContext, + ctx: WriterContext, contractName: string, abiLink: string, ): ModuleGen { @@ -182,7 +182,7 @@ export class ModuleGen { const shiftExprs: FuncAstExpr[] = supported.map((item) => binop(string(item, "H"), ">>", number(128)), ); - return fun( + return this.ctx.fun( [FunAttr.method_id()], "supported_interfaces", [], @@ -277,8 +277,7 @@ export class ModuleGen { body.push(ret(id(returns))); } - const initFun = fun(attrs, funName, paramValues, returnTy, body); - this.ctx.addFunction(initFun); + this.ctx.fun(attrs, funName, paramValues, returnTy, body); } { @@ -430,10 +429,9 @@ export class ModuleGen { ), ); - this.ctx.addFunction( - fun(attrs, funName, paramValues, returnTy, body), - { context: Location.type("type:" + t.name + "$init") }, - ); + this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.type("type:" + t.name + "$init"), + }); } } @@ -900,7 +898,7 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } // Empty receiver @@ -935,7 +933,7 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } // Comment receiver @@ -972,7 +970,7 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } // Fallback @@ -1012,7 +1010,7 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } // Fallback @@ -1044,7 +1042,7 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } // Bounced @@ -1076,7 +1074,7 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } if (selector.kind === "bounce-binary") { @@ -1128,7 +1126,7 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } throw new Error( @@ -1188,12 +1186,18 @@ export class ModuleGen { ret(call(ops.typeToExternal(t.name), [id("res")])), ); } - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun( + attrs, + funName, + paramValues, + returnTy, + body, + ); } } // Return result body.push(ret(id("res"))); - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } private makeInternalReceiver( @@ -1291,7 +1295,7 @@ export class ModuleGen { body.push(comment("Persist state")); body.push(expr(call(ops.contractStore(type.name), [id("self")]))); - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } private makeExternalReceiver( @@ -1344,11 +1348,14 @@ export class ModuleGen { body.push(comment("Persist state")); body.push(expr(call(ops.contractStore(type.name), [id("self")]))); - return fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body); } /** - * Adds entries from the main Tact contract. + * Adds entries from the main Tact contract creating a program containing the entrypoint. + * + * XXX: In the old backend, they simply push multiply functions here, creating an entry + * for a non-existent `$main` function. */ private writeMainContract( m: FuncAstModule, @@ -1382,9 +1389,13 @@ export class ModuleGen { // return "${abiLink}"; // } m.entries.push( - fun([FunAttr.method_id()], "get_abi_ipfs", [], Type.hole(), [ - ret(string(this.abiLink)), - ]), + this.ctx.fun( + [FunAttr.method_id()], + "get_abi_ipfs", + [], + Type.hole(), + [ret(string(this.abiLink))], + ), ); // Deployed @@ -1392,7 +1403,7 @@ export class ModuleGen { // return get_data().begin_parse().load_int(1); // } m.entries.push( - fun( + this.ctx.fun( [FunAttr.method_id()], "lazy_deployment_completed", [], diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index 622d4e2c1..7a843882d 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -10,7 +10,7 @@ import { isWildcard, tryExtractPath, } from "../grammar/ast"; -import { ExpressionGen, writePathExpression, CodegenContext } from "."; +import { ExpressionGen, writePathExpression, WriterContext } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; import { FuncAstStmt, @@ -39,14 +39,14 @@ export class StatementGen { * @param returns The return value of the return statement. */ private constructor( - private ctx: CodegenContext, + private ctx: WriterContext, private tactStmt: AstStatement, private selfName?: string, private returns?: TypeRef, ) {} static fromTact( - ctx: CodegenContext, + ctx: WriterContext, tactStmt: AstStatement, selfVarName?: string, returns?: TypeRef, From e98e2f190a0b4e29244392c57806b32e2cfd132b Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Wed, 24 Jul 2024 11:00:36 +0000 Subject: [PATCH 080/162] chore(codegen): Skip dependencies check We skip this, because we automatically add the standard Func functions as dependencies, which are not present in the context. --- src/codegen/context.ts | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index fda9e0b24..4618b22bb 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -186,27 +186,6 @@ export class WriterContext { } public extract(debug: boolean = false): WrittenFunction[] { - // Check dependencies - const missing: Map = new Map(); - for (const f of this.functions.values()) { - for (const d of f.depends) { - if (!this.functions.has(d)) { - if (!missing.has(d)) { - missing.set(d, [f.name]); - } else { - missing.set(d, [...missing.get(d)!, f.name]); - } - } - } - } - if (missing.size > 0) { - throw new Error( - `Functions ${Array.from(missing.keys()) - .map((v) => `"${v}"`) - .join(", ")} wasn't added to the context`, - ); - } - // All functions let all = this.allFunctions(); @@ -216,13 +195,10 @@ export class WriterContext { const visit = (name: string) => { used.add(name); const f = this.functions.get(name); - if (f === undefined) { - throw new Error( - `Cannot find function ${name} within the CodegenContext`, - ); - } - for (const d of f.depends) { - visit(d); + if (f !== undefined) { + for (const d of f.depends) { + visit(d); + } } }; this.mainFunctions().forEach((f) => visit(f.name)); From e5578ce79ba813fa6076ff41fa15910da11ac53f Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 25 Jul 2024 10:21:14 +0000 Subject: [PATCH 081/162] feat(codegen): Introduce hacks in dependency management to overcome missing functions --- src/codegen/context.ts | 35 ++++++++++++++++-------------- src/codegen/module.ts | 48 ++++++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index 4618b22bb..093908687 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -190,25 +190,28 @@ export class WriterContext { let all = this.allFunctions(); // Remove unused - if (!debug) { - const used: Set = new Set(); - const visit = (name: string) => { - used.add(name); - const f = this.functions.get(name); - if (f !== undefined) { - for (const d of f.depends) { - visit(d); - } + const used: Set = new Set(); + const visit = (name: string) => { + used.add(name); + const f = this.functions.get(name); + if (f !== undefined) { + for (const d of f.depends) { + visit(d); } - }; - this.mainFunctions().forEach((f) => visit(f.name)); - all = all.filter((v) => used.has(v.name)); - } + } + }; + this.mainFunctions().forEach((f) => visit(f.name)); + all = all.filter((v) => used.has(v.name)); // Sort functions - const sorted = topologicalSort(all, (f) => - Array.from(f.depends).map((v) => this.functions.get(v)!), - ); + const sorted = topologicalSort(all, (f) => { + if (f !== undefined) { + return Array.from(f.depends).map((v) => this.functions.get(v)!); + } else { + // TODO: This will be resolved when all the required functions are added to the new backend. + return []; + } + }).filter(f => f !== undefined); return sorted; } diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 98968f6af..c0445ebd0 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -188,6 +188,7 @@ export class ModuleGen { [], Type.hole(), [ret(tensor(...shiftExprs))], + { inMainContract: true }, ); } @@ -828,7 +829,9 @@ export class ModuleGen { functionBody.push(ret(tensor(id("self"), bool(false)))); } - return fun(attrs, name, paramValues, returnTy, functionBody); + return this.ctx.fun(attrs, name, paramValues, returnTy, functionBody, { + inMainContract: true, + }); } private writeReceiver( @@ -898,7 +901,9 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } // Empty receiver @@ -933,7 +938,9 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } // Comment receiver @@ -970,7 +977,9 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } // Fallback @@ -1010,7 +1019,9 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } // Fallback @@ -1042,7 +1053,9 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } // Bounced @@ -1074,7 +1087,9 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } if (selector.kind === "bounce-binary") { @@ -1126,7 +1141,9 @@ export class ModuleGen { ) { body.push(ret(tensor(id(selfRes), unit()))); } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } throw new Error( @@ -1192,12 +1209,15 @@ export class ModuleGen { paramValues, returnTy, body, + { inMainContract: true }, ); } } // Return result body.push(ret(id("res"))); - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } private makeInternalReceiver( @@ -1295,7 +1315,9 @@ export class ModuleGen { body.push(comment("Persist state")); body.push(expr(call(ops.contractStore(type.name), [id("self")]))); - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } private makeExternalReceiver( @@ -1348,7 +1370,9 @@ export class ModuleGen { body.push(comment("Persist state")); body.push(expr(call(ops.contractStore(type.name), [id("self")]))); - return this.ctx.fun(attrs, funName, paramValues, returnTy, body); + return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { + inMainContract: true, + }); } /** @@ -1395,6 +1419,7 @@ export class ModuleGen { [], Type.hole(), [ret(string(this.abiLink))], + { inMainContract: true }, ), ); @@ -1417,6 +1442,7 @@ export class ModuleGen { }), ), ], + { inMainContract: true }, ), ); From 8d704c286eba4599379702c139455c8146633ec8 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 25 Jul 2024 10:28:15 +0000 Subject: [PATCH 082/162] chore(codegen): Restructure, to make `writeAll` more explicit --- src/codegen/generator.ts | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 60b08fd6e..5400a0d66 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -69,11 +69,11 @@ export class FuncGenerator { const abi = JSON.stringify(this.abiSrc); const abiLink = await calculateIPFSlink(Buffer.from(abi)); - const mainContract = this.generateMainContract( + const m = ModuleGen.fromTact( + this.funcCtx, this.abiSrc.name!, abiLink, - ); - // TODO: writeAll + ).writeAll(); const functions = this.funcCtx.extract(); // @@ -112,10 +112,10 @@ export class FuncGenerator { // TODO // Finalize and dump the main contract, as we have just obtained the structure of the project - mainContract.entries.unshift( + m.entries.unshift( ...generated.files.map((f) => include(f.name)), ); - mainContract.entries.unshift( + m.entries.unshift( ...[ `version =${CODEGEN_FUNC_VERSION}`, "allow-post-modification", @@ -124,7 +124,7 @@ export class FuncGenerator { ); generated.files.push({ name: `${this.basename}.code.fc`, - code: new FuncFormatter().dump(mainContract), + code: new FuncFormatter().dump(m), }); // header.push(""); @@ -148,22 +148,6 @@ export class FuncGenerator { }; } - /** - * Runs the generation of the main contract. - * This generates some entries from the bottom-up saving them in WriterContext. - */ - private generateMainContract( - mainContractName: string, - abiLink: string, - ): FuncAstModule { - const m = ModuleGen.fromTact( - this.funcCtx, - mainContractName, - abiLink, - ).writeAll(); - return m; - } - /** * Generates a file that contains declarations of all the generated Func functions. */ From 660bf84826ee4a88c098081b6050a04748cee33b Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 25 Jul 2024 11:33:52 +0000 Subject: [PATCH 083/162] feat(syntax): Support variables unpacking --- src/func/formatter.ts | 6 ++++-- src/func/syntax.ts | 3 ++- src/func/syntaxConstructors.ts | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/func/formatter.ts b/src/func/formatter.ts index bda7c7116..54c555a17 100644 --- a/src/func/formatter.ts +++ b/src/func/formatter.ts @@ -258,10 +258,12 @@ export class FuncFormatter { } private formatVarDefStmt(node: FuncAstVarDefStmt): string { - const name = this.dump(node.name); + const names = node.names.map(this.dump); + const namesStr = + names.length === 1 ? names[0] : `(${names.join(", ")})`; const type = node.ty ? this.dump(node.ty) : "var"; const init = node.init ? ` = ${this.dump(node.init)}` : ""; - return `${type} ${name}${init};`; + return `${type} ${namesStr}${init};`; } private formatReturnStmt(node: FuncAstReturnStmt): string { diff --git a/src/func/syntax.ts b/src/func/syntax.ts index 33e1925c6..b755265ff 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -260,9 +260,10 @@ export type FuncAstStmt = // Local variable definition: // int x = 2; // ty = int // var x = 2; // ty is undefined +// var (x, y) = 2; // ty is undefined; names = ["x", "y"] export type FuncAstVarDefStmt = { kind: "var_def_stmt"; - name: FuncAstIdExpr; + names: FuncAstIdExpr[]; ty: FuncType | undefined; init: FuncAstExpr | undefined; }; diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 67165637c..dfb88cfee 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -259,17 +259,21 @@ export const primitiveType = (ty: FuncType): FuncAstPrimitiveTypeExpr => ({ // Statements // -export const vardef = ( +export function vardef( // TODO: replace w/ `FuncType | '_'` ty: FuncType | undefined, - name: string | FuncAstIdExpr, + names: string | string[] | FuncAstIdExpr | FuncAstIdExpr[], init?: FuncAstExpr, -): FuncAstVarDefStmt => ({ - kind: "var_def_stmt", - name: wrapToId(name), - ty, - init, -}); +): FuncAstVarDefStmt { + return { + kind: "var_def_stmt", + names: Array.isArray(names) + ? names.map((v) => wrapToId(v)) + : [wrapToId(names)], + ty, + init, + }; +} export const ret = (value?: FuncAstExpr): FuncAstReturnStmt => ({ kind: "return_stmt", From 1a16faf2bf3707942f258b473d9ceeaf174b2804 Mon Sep 17 00:00:00 2001 From: Byakuren Hijiri Date: Thu, 25 Jul 2024 12:11:23 +0000 Subject: [PATCH 084/162] feat(codgen): WIP stdlib translation to showcase how it looks like --- src/codegen/context.ts | 38 +- src/codegen/module.ts | 7 +- src/codegen/stdlib.ts | 2172 ++++++++++++++++++++++++++++++++ src/func/syntaxConstructors.ts | 5 + 4 files changed, 2212 insertions(+), 10 deletions(-) create mode 100644 src/codegen/stdlib.ts diff --git a/src/codegen/context.ts b/src/codegen/context.ts index 093908687..461fe2db7 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -14,6 +14,7 @@ import { forEachExpression } from "../func/iterators"; /** * An additional information on how to handle the function definition. * TODO: Refactor: we need only the boolean `skip` field in WrittenFunction. + * TODO: We don't need even `skip`. These are merely names without signature saved within the context. * XXX: Writer.ts: `Body.kind` */ export type BodyKind = "asm" | "skip" | "generic"; @@ -69,7 +70,7 @@ export class Location { export type WrittenFunction = { name: string; - definition: FuncAstFunctionDefinition | FuncAstAsmFunction; + definition: FuncAstFunctionDefinition | FuncAstAsmFunction | undefined; kind: BodyKind; context: LocationContext | undefined; depends: Set; @@ -113,7 +114,10 @@ export class WriterContext { * info about the dependencies: functions that it calls. */ public save( - value: FuncAstFunctionDefinition | FuncAstAsmFunction, + value: + | FuncAstFunctionDefinition + | FuncAstAsmFunction + | { name: string; kind: "name_only" }, params: Partial = {}, ): void { const { @@ -121,15 +125,27 @@ export class WriterContext { context = undefined, inMainContract = false, } = params; - const definition = value as + let name: string; + let definition: | FuncAstFunctionDefinition - | FuncAstAsmFunction; + | FuncAstAsmFunction + | undefined; + if (value.kind === "name_only") { + name = value.name; + definition = undefined; + } else { + const defValue = value as + | FuncAstFunctionDefinition + | FuncAstAsmFunction; + name = defValue.name.value; + definition = defValue; + } const depends = new Set(); if (value.kind === "function_definition") { this.addDependencies(value, depends); } - this.functions.set(definition.name.value, { - name: definition.name.value, + this.functions.set(name, { + name, definition, kind, context, @@ -155,6 +171,14 @@ export class WriterContext { return f; } + /** + * Saves the function name in the context. + * XXX: Replicates old WriterContext.skip + */ + public skip(name: string, params: Partial = {}): void { + this.save({ name, kind: "name_only" }, params); + } + /** * Wraps the asm function definition constructor saving it to the context. * XXX: Replicates old WriterContext.asm @@ -211,7 +235,7 @@ export class WriterContext { // TODO: This will be resolved when all the required functions are added to the new backend. return []; } - }).filter(f => f !== undefined); + }).filter((f) => f !== undefined); return sorted; } diff --git a/src/codegen/module.ts b/src/codegen/module.ts index c0445ebd0..3eeeece69 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -13,6 +13,7 @@ import { getSortedTypes } from "../storage/resolveAllocation"; import { getMethodId } from "../utils/utils"; import { idTextErr } from "../errors"; import { contractErrors } from "../abi/errors"; +import { writeStdlib } from "./stdlib"; import { resolveFuncTypeUnpack, resolveFuncType, @@ -133,8 +134,8 @@ export class ModuleGen { /** * Adds stdlib definitions to the generated module. */ - private addStdlib(_m: FuncAstModule): void { - // TODO + private writeStdlib(m: FuncAstModule): void { + writeStdlib(this.ctx); } private addSerializers(_m: FuncAstModule): void { @@ -1475,7 +1476,7 @@ export class ModuleGen { throw Error(`Contract "${this.contractName}" not found`); } - this.addStdlib(m); + this.writeStdlib(m); this.addSerializers(m); this.addAccessors(m); this.addInitSerializer(m); diff --git a/src/codegen/stdlib.ts b/src/codegen/stdlib.ts new file mode 100644 index 000000000..2ba6acf00 --- /dev/null +++ b/src/codegen/stdlib.ts @@ -0,0 +1,2172 @@ +import { contractErrors } from "../abi/errors"; +import { enabledMasterchain } from "../config/features"; +import { WriterContext, Location } from "./context"; +import { + UNIT_TYPE, + FuncAstModule, + FuncAstStmt, + FuncAstFunctionAttribute, + FuncType, + FuncAstVarDefStmt, + FuncAstFunctionDefinition, + FuncAstExpr, +} from "../func/syntax"; +import { + cr, + unop, + comment, + FunParamValue, + nil, + assign, + while_, + expr, + unit, + call, + binop, + bool, + number, + hexnumber, + string, + fun, + ret, + tensor, + Type, + ternary, + FunAttr, + vardef, + mod, + condition, + id, +} from "../func/syntaxConstructors"; + +export function writeStdlib(ctx: WriterContext) { + // + // stdlib extension functions + // + + ctx.skip("__tact_set", { context: Location.stdlib() }); + ctx.skip("__tact_nop", { context: Location.stdlib() }); + ctx.skip("__tact_str_to_slice", { context: Location.stdlib() }); + ctx.skip("__tact_slice_to_str", { context: Location.stdlib() }); + ctx.skip("__tact_address_to_slice", { context: Location.stdlib() }); + + // + // Addresses + // + + // ctx.fun("__tact_verify_address", () => ); + + // ctx.fun("__tact_load_bool", () => ); + + // ctx.fun("__tact_load_address", () => ); + + // __tact_load_address + { + const returnTy = Type.tensor(Type.slice(), Type.slice()); + const funName = "__tact_load_address"; + const paramValues: FunParamValue[] = [["cs", Type.slice()]]; + const attrs = [FunAttr.inline()]; + const body: FuncAstStmt[] = []; + + body.push(vardef(Type.slice(), "raw", call("cs~load_msg_addr", []))); + body.push( + ret(tensor(id("cs"), call("__tact_verify_address", [id("raw")]))), + ); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // __tact_load_address_opt + { + const returnTy = Type.tensor(Type.slice(), Type.slice()); + const funName = "__tact_load_address_opt"; + const paramValues: FunParamValue[] = [["cs", Type.slice()]]; + const attrs = [FunAttr.inline()]; + const body: FuncAstStmt[] = []; + + // if (cs.preload_uint(2) != 0) + const cond = binop( + call(id("cs~preload_uint"), [number(2)]), + "!=", + number(0), + ); + + // if branch + const ifBody: FuncAstStmt[] = []; + ifBody.push(vardef(Type.slice(), "raw", call("cs~load_msg_addr", []))); + ifBody.push( + ret(tensor(id("cs"), call("__tact_verify_address", [id("raw")]))), + ); + + // else branch + const elseBody: FuncAstStmt[] = []; + elseBody.push(expr(call(id("cs~skip_bits"), [number(2)]))); + elseBody.push(ret(tensor(id("cs"), call("null", [])))); + + body.push( + condition(cond, ifBody, false, condition(undefined, elseBody)), + ); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // __tact_store_address + { + const returnTy = Type.builder(); + const funName = "__tact_store_address"; + const paramValues: FunParamValue[] = [ + ["b", Type.builder()], + ["address", Type.slice()], + ]; + const attrs = [FunAttr.inline()]; + const body: FuncAstStmt[] = []; + + body.push( + ret( + call(id("b~store_slice"), [ + call("__tact_verify_address", [id("address")]), + ]), + ), + ); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // __tact_store_address_opt + { + const returnTy = Type.builder(); + const funName = "__tact_store_address_opt"; + const paramValues: FunParamValue[] = [ + ["b", Type.builder()], + ["address", Type.slice()], + ]; + const attrs = [FunAttr.inline()]; + const body: FuncAstStmt[] = []; + + // if (null?(address)) + const cond = call("null?", [id("address")]); + + // if branch + const ifBody: FuncAstStmt[] = []; + ifBody.push( + expr( + assign( + id("b"), + call("store_uint", [number(0), number(2)], { + receiver: id("b"), + }), + ), + ), + ); + ifBody.push(ret(id("b"))); + + // else branch + const elseBody: FuncAstStmt[] = []; + elseBody.push( + ret(call("__tact_store_address", [id("b"), id("address")])), + ); + + body.push( + condition(cond, ifBody, false, condition(undefined, elseBody)), + ); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // __tact_create_address + { + const returnTy = Type.slice(); + const funName = "__tact_create_address"; + const paramValues: FunParamValue[] = [ + ["chain", Type.int()], + ["hash", Type.int()], + ]; + const attrs = [FunAttr.inline()]; + const body: FuncAstStmt[] = []; + + body.push(vardef(Type.builder(), "b", call("begin_cell", []))); + body.push( + expr( + assign( + id("b"), + call("store_uint", [number(2), number(2)], { + receiver: id("b"), + }), + ), + ), + ); + body.push( + expr( + assign( + id("b"), + call("store_uint", [number(0), number(1)], { + receiver: id("b"), + }), + ), + ), + ); + body.push( + expr( + assign( + id("b"), + call("store_int", [id("chain"), number(8)], { + receiver: id("b"), + }), + ), + ), + ); + body.push( + expr( + assign( + id("b"), + call("store_uint", [id("hash"), number(256)], { + receiver: id("b"), + }), + ), + ), + ); + body.push( + vardef( + Type.slice(), + "addr", + call("begin_parse", [], { + receiver: call("end_cell", [], { receiver: id("b") }), + }), + ), + ); + body.push(ret(call("__tact_verify_address", [id("addr")]))); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // __tact_compute_contract_address + { + const returnTy = Type.slice(); + const funName = "__tact_compute_contract_address"; + const paramValues: FunParamValue[] = [ + ["chain", Type.int()], + ["code", Type.cell()], + ["data", Type.cell()], + ]; + const attrs = [FunAttr.inline()]; + const body: FuncAstStmt[] = []; + + body.push(vardef(Type.builder(), "b", call("begin_cell", []))); + body.push( + expr( + assign( + id("b"), + call("store_uint", [number(0), number(2)], { + receiver: id("b"), + }), + ), + ), + ); + body.push( + expr( + assign( + id("b"), + call("store_uint", [number(3), number(2)], { + receiver: id("b"), + }), + ), + ), + ); + body.push( + expr( + assign( + id("b"), + call("store_uint", [number(0), number(1)], { + receiver: id("b"), + }), + ), + ), + ); + body.push( + expr( + assign( + id("b"), + call("store_ref", [id("code")], { receiver: id("b") }), + ), + ), + ); + body.push( + expr( + assign( + id("b"), + call("store_ref", [id("data")], { receiver: id("b") }), + ), + ), + ); + body.push( + vardef( + Type.slice(), + "hash", + call("cell_hash", [ + call("end_cell", [], { receiver: id("b") }), + ]), + ), + ); + body.push( + ret(call("__tact_create_address", [id("chain"), id("hash")])), + ); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // __tact_my_balance + { + const returnTy = Type.int(); + const funName = "__tact_my_balance"; + const paramValues: FunParamValue[] = []; + const attrs = [FunAttr.inline()]; + const body: FuncAstStmt[] = []; + + body.push(ret(call("pair_first", [call("get_balance", [])]))); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // TODO: we don't have forall yet + // ctx.fun("__tact_not_null", () => ); + + // ctx.fun("__tact_dict_delete", () => ); + + // ctx.fun("__tact_dict_delete_int", () => ); + + // ctx.fun("__tact_dict_delete_uint", () => ); + + // ctx.fun("__tact_dict_set_ref", () => ); + + // ctx.fun("__tact_dict_get", () => ); + + // ctx.fun("__tact_dict_get_ref", () => ); + + // ctx.fun("__tact_dict_min", () => ); + + // ctx.fun("__tact_dict_min_ref", () => ); + + // ctx.fun("__tact_dict_next", () => ); + + // __tact_dict_next_ref + { + const returnTy = Type.tensor(Type.slice(), Type.cell(), Type.int()); + const funName = "__tact_dict_next_ref"; + const paramValues: FunParamValue[] = [ + ["dict", Type.cell()], + ["key_len", Type.int()], + ["pivot", Type.slice()], + ]; + const attrs: FuncAstFunctionAttribute[] = []; + const body: FuncAstStmt[] = []; + + body.push( + vardef( + undefined, + ["key", "value", "flag"], + call("__tact_dict_next", [ + id("dict"), + id("key_len"), + id("pivot"), + ]), + ), + ); + + // if branch + const ifBody: FuncAstStmt[] = []; + ifBody.push( + ret(tensor(id("key"), call("value~load_ref", []), id("flag"))), + ); + + // else branch + const elseBody: FuncAstStmt[] = []; + elseBody.push( + ret(tensor(call("null", []), call("null", []), id("flag"))), + ); + + body.push( + condition( + id("flag"), + ifBody, + false, + condition(undefined, elseBody), + ), + ); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // ctx.fun("__tact_debug", () => ); + + // ctx.fun("__tact_debug_str", () => ); + + // __tact_debug_bool + { + const returnTy = UNIT_TYPE; + const funName = "__tact_debug_bool"; + const paramValues: FunParamValue[] = [ + ["value", Type.int()], + ["debug_print", Type.slice()], + ]; + const attrs = [FunAttr.impure()]; + const body: FuncAstStmt[] = []; + + // if branch + const ifBody: FuncAstStmt[] = []; + ifBody.push( + expr(call("__tact_debug_str", [string("true"), id("debug_print")])), + ); + + // else branch + const elseBody: FuncAstStmt[] = []; + elseBody.push( + expr( + call("__tact_debug_str", [string("false"), id("debug_print")]), + ), + ); + + body.push( + condition( + id("value"), + ifBody, + false, + condition(undefined, elseBody), + ), + ); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // ctx.fun("__tact_preload_offset", () => ); + + // __tact_crc16 + { + const returnTy = Type.slice(); + const funName = "__tact_crc16"; + const paramValues: FunParamValue[] = [["data", Type.slice()]]; + const attrs = [FunAttr.inline_ref()]; + const body: FuncAstStmt[] = []; + + body.push( + vardef( + Type.slice(), + "new_data", + call("begin_parse", [], { + receiver: call("end_cell", [], { + receiver: call("store_slice", [string("0000", "s")], { + receiver: call("store_slice", [id("data")], { + receiver: call("begin_cell", []), + }), + }), + }), + }), + ), + ); + + body.push(vardef(Type.int(), "reg", number(0))); + + const cond = unop( + "~", + call("slice_data_empty?", [], { receiver: id("new_data") }), + ); + + // while loop + const whileBody: FuncAstStmt[] = []; + whileBody.push( + vardef( + Type.int(), + "byte", + call("load_uint", [number(8)], { receiver: id("new_data") }), + ), + ); + whileBody.push(vardef(Type.int(), "mask", hexnumber("0x80"))); + + const innerCond = binop(id("mask"), ">", number(0)); + + // inner while loop + const innerWhileBody: FuncAstStmt[] = []; + innerWhileBody.push( + expr(assign(id("reg"), binop(id("reg"), "<<", number(1)))), + ); + innerWhileBody.push( + condition( + binop(id("byte"), "&", id("mask")), + [expr(assign(id("reg"), binop(id("reg"), "+", number(1))))], + false, + ), + ); + innerWhileBody.push( + expr(assign(id("mask"), binop(id("mask"), ">>", number(1)))), + ); + innerWhileBody.push( + condition( + binop(id("reg"), ">", number(0xffff)), + [ + expr( + assign( + id("reg"), + binop(id("reg"), "&", number(0xffff)), + ), + ), + expr( + assign( + id("reg"), + binop(id("reg"), "^", hexnumber("0x1021")), + ), + ), + ], + false, + ), + ); + + whileBody.push(while_(innerCond, innerWhileBody)); + body.push(while_(cond, whileBody)); + + body.push( + vardef( + undefined, + ["q", "r"], + call("divmod", [id("reg"), number(256)]), + ), + ); + + body.push( + ret( + call("begin_parse", [], { + receiver: call("end_cell", [], { + receiver: call("store_uint", [id("r"), number(8)], { + receiver: call("store_uint", [id("q"), number(8)], { + receiver: call("begin_cell", []), + }), + }), + }), + }), + ), + ); + + ctx.fun(attrs, funName, paramValues, returnTy, body, { + context: Location.stdlib(), + }); + } + + // ctx.fun("__tact_base64_encode", () => { + // ctx.signature(`(slice) __tact_base64_encode(slice data)`); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; + // builder res = begin_cell(); + // + // while (data.slice_bits() >= 24) { + // (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); + // + // int n = (bs1 << 16) | (bs2 << 8) | bs3; + // + // res = res + // .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 18) & 63) * 8, 8)) + // .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 12) & 63) * 8, 8)) + // .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 6) & 63) * 8, 8)) + // .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n ) & 63) * 8, 8)); + // } + // + // return res.end_cell().begin_parse(); + // `); + // }); + // }); + + // ctx.fun("__tact_address_to_user_friendly", () => { + // ctx.signature(`(slice) __tact_address_to_user_friendly(slice address)`); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // (int wc, int hash) = address.parse_std_addr(); + + // slice user_friendly_address = begin_cell() + // .store_slice("11"s) + // .store_uint((wc + 0x100) % 0x100, 8) + // .store_uint(hash, 256) + // .end_cell().begin_parse(); + // + // slice checksum = ${ctx.used("__tact_crc16")}(user_friendly_address); + // slice user_friendly_address_with_checksum = begin_cell() + // .store_slice(user_friendly_address) + // .store_slice(checksum) + // .end_cell().begin_parse(); + // + // return ${ctx.used("__tact_base64_encode")}(user_friendly_address_with_checksum); + // `); + // }); + // }); + + // ctx.fun("__tact_debug_address", () => { + // ctx.signature( + // `() __tact_debug_address(slice address, slice debug_print)`, + // ); + // ctx.flag("impure"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // ${ctx.used("__tact_debug_str")}(${ctx.used("__tact_address_to_user_friendly")}(address), debug_print); + // `); + // }); + // }); + + // ctx.fun("__tact_debug_stack", () => { + // ctx.signature(`() __tact_debug_stack(slice debug_print)`); + // ctx.flag("impure"); + // ctx.context("stdlib"); + // ctx.asm(`asm "STRDUMP" "DROP" "DUMPSTK"`); + // }); + + // ctx.fun("__tact_context_get", () => { + // ctx.signature(`(int, slice, int, slice) __tact_context_get()`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(`return __tact_context;`); + // }); + // }); + + // ctx.fun("__tact_context_get_sender", () => { + // ctx.signature(`slice __tact_context_get_sender()`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(`return __tact_context_sender;`); + // }); + // }); + + // ctx.fun("__tact_prepare_random", () => { + // ctx.signature(`() __tact_prepare_random()`); + // ctx.flag("impure"); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(__tact_randomized)) { + // randomize_lt(); + // __tact_randomized = true; + // } + // `); + // }); + // }); + + // ctx.fun("__tact_store_bool", () => { + // ctx.signature(`builder __tact_store_bool(builder b, int v)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return b.store_int(v, 1); + // `); + // }); + // }); + + // ctx.fun("__tact_to_tuple", () => { + // ctx.signature(`forall X -> tuple __tact_to_tuple(X x)`); + // ctx.context("stdlib"); + // ctx.asm(`asm "NOP"`); + // }); + + // ctx.fun("__tact_from_tuple", () => { + // ctx.signature(`forall X -> X __tact_from_tuple(tuple x)`); + // ctx.context("stdlib"); + // ctx.asm(`asm "NOP"`); + // }); + + // Dict Int -> Int + // + // + // ctx.fun("__tact_dict_set_int_int", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = idict_delete?(d, kl, k); + // return (r, ()); + // } else { + // return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_int_int", () => { + // ctx.signature( + // `int __tact_dict_get_int_int(cell d, int kl, int k, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = idict_get?(d, kl, k); + // if (ok) { + // return r~load_int(vl); + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_int_int", () => { + // ctx.signature( + // `(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = idict_get_min?(d, kl); + // if (flag) { + // return (key, value~load_int(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_int_int", () => { + // ctx.signature( + // `(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = idict_get_next?(d, kl, pivot); + // if (flag) { + // return (key, value~load_int(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Int -> Int + // + // + // ctx.fun("__tact_dict_set_int_uint", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_int_uint(cell d, int kl, int k, int v, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = idict_delete?(d, kl, k); + // return (r, ()); + // } else { + // return (idict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_int_uint", () => { + // ctx.signature( + // `int __tact_dict_get_int_uint(cell d, int kl, int k, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = idict_get?(d, kl, k); + // if (ok) { + // return r~load_uint(vl); + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_int_uint", () => { + // ctx.signature( + // `(int, int, int) __tact_dict_min_int_uint(cell d, int kl, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = idict_get_min?(d, kl); + // if (flag) { + // return (key, value~load_uint(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_int_uint", () => { + // ctx.signature( + // `(int, int, int) __tact_dict_next_int_uint(cell d, int kl, int pivot, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = idict_get_next?(d, kl, pivot); + // if (flag) { + // return (key, value~load_uint(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Uint -> Int + // + // + // ctx.fun("__tact_dict_set_uint_int", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = udict_delete?(d, kl, k); + // return (r, ()); + // } else { + // return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_uint_int", () => { + // ctx.signature( + // `int __tact_dict_get_uint_int(cell d, int kl, int k, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = udict_get?(d, kl, k); + // if (ok) { + // return r~load_int(vl); + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_uint_int", () => { + // ctx.signature( + // `(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = udict_get_min?(d, kl); + // if (flag) { + // return (key, value~load_int(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_uint_int", () => { + // ctx.signature( + // `(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = udict_get_next?(d, kl, pivot); + // if (flag) { + // return (key, value~load_int(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Uint -> Uint + // + // + // ctx.fun("__tact_dict_set_uint_uint", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = udict_delete?(d, kl, k); + // return (r, ()); + // } else { + // return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_uint_uint", () => { + // ctx.signature( + // `int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = udict_get?(d, kl, k); + // if (ok) { + // return r~load_uint(vl); + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_uint_uint", () => { + // ctx.signature( + // `(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = udict_get_min?(d, kl); + // if (flag) { + // return (key, value~load_uint(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_uint_uint", () => { + // ctx.signature( + // `(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = udict_get_next?(d, kl, pivot); + // if (flag) { + // return (key, value~load_uint(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Int -> Cell + // + // + // ctx.fun("__tact_dict_set_int_cell", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = idict_delete?(d, kl, k); + // return (r, ()); + // } else { + // return (idict_set_ref(d, kl, k, v), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_int_cell", () => { + // ctx.signature(`cell __tact_dict_get_int_cell(cell d, int kl, int k)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = idict_get_ref?(d, kl, k); + // if (ok) { + // return r; + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_int_cell", () => { + // ctx.signature( + // `(int, cell, int) __tact_dict_min_int_cell(cell d, int kl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = idict_get_min_ref?(d, kl); + // if (flag) { + // return (key, value, flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_int_cell", () => { + // ctx.signature( + // `(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = idict_get_next?(d, kl, pivot); + // if (flag) { + // return (key, value~load_ref(), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Uint -> Cell + // + // + // ctx.fun("__tact_dict_set_uint_cell", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = udict_delete?(d, kl, k); + // return (r, ()); + // } else { + // return (udict_set_ref(d, kl, k, v), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_uint_cell", () => { + // ctx.signature(`cell __tact_dict_get_uint_cell(cell d, int kl, int k)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = udict_get_ref?(d, kl, k); + // if (ok) { + // return r; + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_uint_cell", () => { + // ctx.signature( + // `(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = udict_get_min_ref?(d, kl); + // if (flag) { + // return (key, value, flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_uint_cell", () => { + // ctx.signature( + // `(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = udict_get_next?(d, kl, pivot); + // if (flag) { + // return (key, value~load_ref(), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Int -> Slice + // + // + // ctx.fun("__tact_dict_set_int_slice", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = idict_delete?(d, kl, k); + // return (r, ()); + // } else { + // return (idict_set(d, kl, k, v), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_int_slice", () => { + // ctx.signature(`slice __tact_dict_get_int_slice(cell d, int kl, int k)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = idict_get?(d, kl, k); + // if (ok) { + // return r; + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_int_slice", () => { + // ctx.signature( + // `(int, slice, int) __tact_dict_min_int_slice(cell d, int kl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = idict_get_min?(d, kl); + // if (flag) { + // return (key, value, flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_int_slice", () => { + // ctx.signature( + // `(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = idict_get_next?(d, kl, pivot); + // if (flag) { + // return (key, value, flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Uint -> Slice + // + // + // ctx.fun("__tact_dict_set_uint_slice", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = udict_delete?(d, kl, k); + // return (r, ()); + // } else { + // return (udict_set(d, kl, k, v), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_uint_slice", () => { + // ctx.signature( + // `slice __tact_dict_get_uint_slice(cell d, int kl, int k)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = udict_get?(d, kl, k); + // if (ok) { + // return r; + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_uint_slice", () => { + // ctx.signature( + // `(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = udict_get_min?(d, kl); + // if (flag) { + // return (key, value, flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_uint_slice", () => { + // ctx.signature( + // `(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = udict_get_next?(d, kl, pivot); + // if (flag) { + // return (key, value, flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Slice -> Int + // + // + // ctx.fun("__tact_dict_set_slice_int", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); + // return (r, ()); + // } else { + // return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_slice_int", () => { + // ctx.signature( + // `int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); + // if (ok) { + // return r~load_int(vl); + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_slice_int", () => { + // ctx.signature( + // `(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); + // if (flag) { + // return (key, value~load_int(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_slice_int", () => { + // ctx.signature( + // `(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); + // if (flag) { + // return (key, value~load_int(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Slice -> UInt + // + // + // ctx.fun("__tact_dict_set_slice_uint", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); + // return (r, ()); + // } else { + // return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_get_slice_uint", () => { + // ctx.signature( + // `int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); + // if (ok) { + // return r~load_uint(vl); + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_min_slice_uint", () => { + // ctx.signature( + // `(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); + // if (flag) { + // return (key, value~load_uint(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun("__tact_dict_next_slice_uint", () => { + // ctx.signature( + // `(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); + // if (flag) { + // return (key, value~load_uint(vl), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Slice -> Cell + // + // + // ctx.fun("__tact_dict_set_slice_cell", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); + // return (r, ()); + // } else { + // return ${ctx.used(`__tact_dict_set_ref`)}(d, kl, k, v); + // } + // `); + // }); + // }); + + // ctx.fun(`__tact_dict_get_slice_cell`, () => { + // ctx.signature( + // `cell __tact_dict_get_slice_cell(cell d, int kl, slice k)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = ${ctx.used(`__tact_dict_get_ref`)}(d, kl, k); + // if (ok) { + // return r; + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun(`__tact_dict_min_slice_cell`, () => { + // ctx.signature( + // `(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = ${ctx.used(`__tact_dict_min_ref`)}(d, kl); + // if (flag) { + // return (key, value, flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun(`__tact_dict_next_slice_cell`, () => { + // ctx.signature( + // `(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); + // if (flag) { + // return (key, value~load_ref(), flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // Dict Slice -> Slice + // + // + // ctx.fun("__tact_dict_set_slice_slice", () => { + // ctx.signature( + // `(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // if (null?(v)) { + // var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); + // return (r, ()); + // } else { + // return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); + // } + // `); + // }); + // }); + + // ctx.fun(`__tact_dict_get_slice_slice`, () => { + // ctx.signature( + // `slice __tact_dict_get_slice_slice(cell d, int kl, slice k)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); + // if (ok) { + // return r; + // } else { + // return null(); + // } + // `); + // }); + // }); + + // ctx.fun(`__tact_dict_min_slice_slice`, () => { + // ctx.signature( + // `(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); + // if (flag) { + // return (key, value, flag); + // } else { + // return (null(), null(), flag); + // } + // `); + // }); + // }); + + // ctx.fun(`__tact_dict_next_slice_slice`, () => { + // ctx.signature( + // `(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); + // `); + // }); + // }); + + // Address + // + // + // ctx.fun(`__tact_slice_eq_bits`, () => { + // ctx.signature(`int __tact_slice_eq_bits(slice a, slice b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return equal_slice_bits(a, b); + // `); + // }); + // }); + + // ctx.fun(`__tact_slice_eq_bits_nullable_one`, () => { + // ctx.signature( + // `int __tact_slice_eq_bits_nullable_one(slice a, slice b)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (null?(a)) ? (false) : (equal_slice_bits(a, b)); + // `); + // }); + // }); + + // ctx.fun(`__tact_slice_eq_bits_nullable`, () => { + // ctx.signature(`int __tact_slice_eq_bits_nullable(slice a, slice b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var a_is_null = null?(a); + // var b_is_null = null?(b); + // return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( equal_slice_bits(a, b) ) : ( false ) ); + // `); + // }); + // }); + + // Int Eq + // + // + // ctx.fun(`__tact_int_eq_nullable_one`, () => { + // ctx.signature(`int __tact_int_eq_nullable_one(int a, int b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (null?(a)) ? (false) : (a == b); + // `); + // }); + // }); + + // ctx.fun(`__tact_int_neq_nullable_one`, () => { + // ctx.signature(`int __tact_int_neq_nullable_one(int a, int b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (null?(a)) ? (true) : (a != b); + // `); + // }); + // }); + + // ctx.fun(`__tact_int_eq_nullable`, () => { + // ctx.signature(`int __tact_int_eq_nullable(int a, int b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var a_is_null = null?(a); + // var b_is_null = null?(b); + // return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a == b ) : ( false ) ); + // `); + // }); + // }); + + // ctx.fun(`__tact_int_neq_nullable`, () => { + // ctx.signature(`int __tact_int_neq_nullable(int a, int b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var a_is_null = null?(a); + // var b_is_null = null?(b); + // return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a != b ) : ( true ) ); + // `); + // }); + // }); + + // Cell Eq + // + // + // ctx.fun(`__tact_cell_eq`, () => { + // ctx.signature(`int __tact_cell_eq(cell a, cell b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (a.cell_hash() == b.cell_hash()); + // `); + // }); + // }); + + // ctx.fun(`__tact_cell_neq`, () => { + // ctx.signature(`int __tact_cell_neq(cell a, cell b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (a.cell_hash() != b.cell_hash()); + // `); + // }); + // }); + + // ctx.fun(`__tact_cell_eq_nullable_one`, () => { + // ctx.signature(`int __tact_cell_eq_nullable_one(cell a, cell b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash()); + // `); + // }); + // }); + + // ctx.fun(`__tact_cell_neq_nullable_one`, () => { + // ctx.signature(`int __tact_cell_neq_nullable_one(cell a, cell b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash()); + // `); + // }); + // }); + + // ctx.fun(`__tact_cell_eq_nullable`, () => { + // ctx.signature(`int __tact_cell_eq_nullable(cell a, cell b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var a_is_null = null?(a); + // var b_is_null = null?(b); + // return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() == b.cell_hash() ) : ( false ) ); + // `); + // }); + // }); + + // ctx.fun(`__tact_cell_neq_nullable`, () => { + // ctx.signature(`int __tact_cell_neq_nullable(cell a, cell b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var a_is_null = null?(a); + // var b_is_null = null?(b); + // return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() != b.cell_hash() ) : ( true ) ); + // `); + // }); + // }); + + // Slice Eq + // + // + // ctx.fun(`__tact_slice_eq`, () => { + // ctx.signature(`int __tact_slice_eq(slice a, slice b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (a.slice_hash() == b.slice_hash()); + // `); + // }); + // }); + + // ctx.fun(`__tact_slice_neq`, () => { + // ctx.signature(`int __tact_slice_neq(slice a, slice b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (a.slice_hash() != b.slice_hash()); + // `); + // }); + // }); + + // ctx.fun(`__tact_slice_eq_nullable_one`, () => { + // ctx.signature(`int __tact_slice_eq_nullable_one(slice a, slice b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash()); + // `); + // }); + // }); + + // ctx.fun(`__tact_slice_neq_nullable_one`, () => { + // ctx.signature(`int __tact_slice_neq_nullable_one(slice a, slice b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash()); + // `); + // }); + // }); + + // ctx.fun(`__tact_slice_eq_nullable`, () => { + // ctx.signature(`int __tact_slice_eq_nullable(slice a, slice b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var a_is_null = null?(a); + // var b_is_null = null?(b); + // return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() == b.slice_hash() ) : ( false ) ); + // `); + // }); + // }); + + // ctx.fun(`__tact_slice_neq_nullable`, () => { + // ctx.signature(`int __tact_slice_neq_nullable(slice a, slice b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var a_is_null = null?(a); + // var b_is_null = null?(b); + // return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() != b.slice_hash() ) : ( true ) ); + // `); + // }); + // }); + + // Sys Dict + // + // + // ctx.fun(`__tact_dict_set_code`, () => { + // ctx.signature( + // `cell __tact_dict_set_code(cell dict, int id, cell code)`, + // ); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return udict_set_ref(dict, 16, id, code); + // `); + // }); + // }); + + // ctx.fun(`__tact_dict_get_code`, () => { + // ctx.signature(`cell __tact_dict_get_code(cell dict, int id)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var (data, ok) = udict_get_ref?(dict, 16, id); + // throw_unless(${contractErrors.codeNotFound.id}, ok); + // return data; + // `); + // }); + // }); + + // Tuples + // + // + // ctx.fun(`__tact_tuple_create_0`, () => { + // ctx.signature(`tuple __tact_tuple_create_0()`); + // ctx.context("stdlib"); + // ctx.asm(`asm "NIL"`); + // }); + // ctx.fun(`__tact_tuple_destroy_0`, () => { + // ctx.signature(`() __tact_tuple_destroy_0()`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.append(`return ();`); + // }); + // }); + + // for (let i = 1; i < 64; i++) { + // ctx.fun(`__tact_tuple_create_${i}`, () => { + // const args: string[] = []; + // for (let j = 0; j < i; j++) { + // args.push(`X${j}`); + // } + // ctx.signature( + // `forall ${args.join(", ")} -> tuple __tact_tuple_create_${i}((${args.join(", ")}) v)`, + // ); + // ctx.context("stdlib"); + // ctx.asm(`asm "${i} TUPLE"`); + // }); + // ctx.fun(`__tact_tuple_destroy_${i}`, () => { + // const args: string[] = []; + // for (let j = 0; j < i; j++) { + // args.push(`X${j}`); + // } + // ctx.signature( + // `forall ${args.join(", ")} -> (${args.join(", ")}) __tact_tuple_destroy_${i}(tuple v)`, + // ); + // ctx.context("stdlib"); + // ctx.asm(`asm "${i} UNTUPLE"`); + // }); + // } + + // Strings + // + // + // ctx.fun(`__tact_string_builder_start_comment`, () => { + // ctx.signature(`tuple __tact_string_builder_start_comment()`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return ${ctx.used("__tact_string_builder_start")}(begin_cell().store_uint(0, 32)); + // `); + // }); + // }); + + // ctx.fun(`__tact_string_builder_start_tail_string`, () => { + // ctx.signature(`tuple __tact_string_builder_start_tail_string()`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return ${ctx.used("__tact_string_builder_start")}(begin_cell().store_uint(0, 8)); + // `); + // }); + // }); + + // ctx.fun(`__tact_string_builder_start_string`, () => { + // ctx.signature(`tuple __tact_string_builder_start_string()`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return ${ctx.used("__tact_string_builder_start")}(begin_cell()); + // `); + // }); + // }); + + // ctx.fun(`__tact_string_builder_start`, () => { + // ctx.signature(`tuple __tact_string_builder_start(builder b)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return tpush(tpush(empty_tuple(), b), null()); + // `); + // }); + // }); + + // ctx.fun(`__tact_string_builder_end`, () => { + // ctx.signature(`cell __tact_string_builder_end(tuple builders)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // (builder b, tuple tail) = uncons(builders); + // cell c = b.end_cell(); + // while(~ null?(tail)) { + // (b, tail) = uncons(tail); + // c = b.store_ref(c).end_cell(); + // } + // return c; + // `); + // }); + // }); + + // ctx.fun(`__tact_string_builder_end_slice`, () => { + // ctx.signature(`slice __tact_string_builder_end_slice(tuple builders)`); + // ctx.flag("inline"); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // return ${ctx.used("__tact_string_builder_end")}(builders).begin_parse(); + // `); + // }); + // }); + + // ctx.fun(`__tact_string_builder_append`, () => { + // ctx.signature( + // `((tuple), ()) __tact_string_builder_append(tuple builders, slice sc)`, + // ); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // int sliceRefs = slice_refs(sc); + // int sliceBits = slice_bits(sc); + + // while((sliceBits > 0) | (sliceRefs > 0)) { + + // ;; Load the current builder + // (builder b, tuple tail) = uncons(builders); + // int remBytes = 127 - (builder_bits(b) / 8); + // int exBytes = sliceBits / 8; + + // ;; Append bits + // int amount = min(remBytes, exBytes); + // if (amount > 0) { + // slice read = sc~load_bits(amount * 8); + // b = b.store_slice(read); + // } + + // ;; Update builders + // builders = cons(b, tail); + + // ;; Check if we need to add a new cell and continue + // if (exBytes - amount > 0) { + // var bb = begin_cell(); + // builders = cons(bb, builders); + // sliceBits = (exBytes - amount) * 8; + // } elseif (sliceRefs > 0) { + // sc = sc~load_ref().begin_parse(); + // sliceRefs = slice_refs(sc); + // sliceBits = slice_bits(sc); + // } else { + // sliceBits = 0; + // sliceRefs = 0; + // } + // } + + // return ((builders), ()); + // `); + // }); + // }); + + // ctx.fun(`__tact_string_builder_append_not_mut`, () => { + // ctx.signature( + // `(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc)`, + // ); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // builders~${ctx.used("__tact_string_builder_append")}(sc); + // return builders; + // `); + // }); + // }); + + // ctx.fun(`__tact_int_to_string`, () => { + // ctx.signature(`slice __tact_int_to_string(int src)`); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // var b = begin_cell(); + // if (src < 0) { + // b = b.store_uint(45, 8); + // src = - src; + // } + + // if (src < ${(10n ** 30n).toString(10)}) { + // int len = 0; + // int value = 0; + // int mult = 1; + // do { + // (src, int res) = src.divmod(10); + // value = value + (res + 48) * mult; + // mult = mult * 256; + // len = len + 1; + // } until (src == 0); + + // b = b.store_uint(value, len * 8); + // } else { + // tuple t = empty_tuple(); + // int len = 0; + // do { + // int digit = src % 10; + // t~tpush(digit); + // len = len + 1; + // src = src / 10; + // } until (src == 0); + + // int c = len - 1; + // repeat(len) { + // int v = t.at(c); + // b = b.store_uint(v + 48, 8); + // c = c - 1; + // } + // } + // return b.end_cell().begin_parse(); + // `); + // }); + // }); + + // ctx.fun(`__tact_float_to_string`, () => { + // ctx.signature(`slice __tact_float_to_string(int src, int digits)`); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // throw_if(${contractErrors.invalidArgument.id}, (digits <= 0) | (digits > 77)); + // builder b = begin_cell(); + + // if (src < 0) { + // b = b.store_uint(45, 8); + // src = - src; + // } + + // ;; Process rem part + // int skip = true; + // int len = 0; + // int rem = 0; + // tuple t = empty_tuple(); + // repeat(digits) { + // (src, rem) = src.divmod(10); + // if ( ~ ( skip & ( rem == 0 ) ) ) { + // skip = false; + // t~tpush(rem + 48); + // len = len + 1; + // } + // } + + // ;; Process dot + // if (~ skip) { + // t~tpush(46); + // len = len + 1; + // } + + // ;; Main + // do { + // (src, rem) = src.divmod(10); + // t~tpush(rem + 48); + // len = len + 1; + // } until (src == 0); + + // ;; Assemble + // int c = len - 1; + // repeat(len) { + // int v = t.at(c); + // b = b.store_uint(v, 8); + // c = c - 1; + // } + + // ;; Result + // return b.end_cell().begin_parse(); + // `); + // }); + // }); + + // ctx.fun(`__tact_log2`, () => { + // ctx.signature(`int __tact_log2(int num)`); + // ctx.context("stdlib"); + // ctx.asm(`asm "DUP 5 THROWIFNOT UBITSIZE DEC"`); + // }); + + // ctx.fun(`__tact_log`, () => { + // ctx.signature(`int __tact_log(int num, int base)`); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // throw_unless(5, num > 0); + // throw_unless(5, base > 1); + // if (num < base) { + // return 0; + // } + // int result = 0; + // while (num >= base) { + // num /= base; + // result += 1; + // } + // return result; + // `); + // }); + // }); + + // ctx.fun(`__tact_pow`, () => { + // ctx.signature(`int __tact_pow(int base, int exp)`); + // ctx.context("stdlib"); + // ctx.body(() => { + // ctx.write(` + // throw_unless(5, exp >= 0); + // int result = 1; + // repeat (exp) { + // result *= base; + // } + // return result; + // `); + // }); + // }); + + // ctx.fun(`__tact_pow2`, () => { + // ctx.signature(`int __tact_pow2(int exp)`); + // ctx.context("stdlib"); + // ctx.asm(`asm "POW2"`); + // }); +} diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index dfb88cfee..f25c6b67d 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -265,6 +265,11 @@ export function vardef( names: string | string[] | FuncAstIdExpr | FuncAstIdExpr[], init?: FuncAstExpr, ): FuncAstVarDefStmt { + if (Array.isArray(names) && names.length === 0) { + throw new Error( + `Variable definition cannot have an empty set of names`, + ); + } return { kind: "var_def_stmt", names: Array.isArray(names) From 75b6952caedc1fe522534d35374754a55a3de570 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:06:26 +0200 Subject: [PATCH 085/162] test: small subset of functions in stdlib for testing FunC grammar --- src/func/grammar-test/__tact_crc16.fc | 29 +++++++++++++++++++ src/func/grammar-test/__tact_debug.fc | 3 ++ src/func/grammar-test/__tact_load_address.fc | 7 +++++ .../grammar-test/__tact_load_address_opt.fc | 12 ++++++++ src/func/grammar-test/__tact_load_bool.fc | 3 ++ src/func/grammar-test/__tact_store_address.fc | 6 ++++ .../grammar-test/__tact_store_address_opt.fc | 11 +++++++ .../grammar-test/__tact_verify_address.fc | 23 +++++++++++++++ src/func/grammar-test/include_stdlib.fc | 1 + src/func/grammar.spec.ts | 15 ++++++++++ src/func/grammar.ts | 23 +++++++++++++++ src/utils/loadCases.ts | 12 ++++++-- 12 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 src/func/grammar-test/__tact_crc16.fc create mode 100644 src/func/grammar-test/__tact_debug.fc create mode 100644 src/func/grammar-test/__tact_load_address.fc create mode 100644 src/func/grammar-test/__tact_load_address_opt.fc create mode 100644 src/func/grammar-test/__tact_load_bool.fc create mode 100644 src/func/grammar-test/__tact_store_address.fc create mode 100644 src/func/grammar-test/__tact_store_address_opt.fc create mode 100644 src/func/grammar-test/__tact_verify_address.fc create mode 100644 src/func/grammar-test/include_stdlib.fc create mode 100644 src/func/grammar.spec.ts create mode 100644 src/func/grammar.ts diff --git a/src/func/grammar-test/__tact_crc16.fc b/src/func/grammar-test/__tact_crc16.fc new file mode 100644 index 000000000..f52db071c --- /dev/null +++ b/src/func/grammar-test/__tact_crc16.fc @@ -0,0 +1,29 @@ +#include "include_stdlib.fc"; + +(slice) __tact_crc16(slice data) inline_ref { + slice new_data = begin_cell() + .store_slice(data) + .store_slice("0000"s) + .end_cell().begin_parse(); + int reg = 0; + while (~ new_data.slice_data_empty?()) { + int byte = new_data~load_uint(8); + int mask = 0x80; + while (mask > 0) { + reg <<= 1; + if (byte & mask) { + reg += 1; + } + mask >>= 1; + if (reg > 0xffff) { + reg &= 0xffff; + reg ^= 0x1021; + } + } + } + (int q, int r) = divmod(reg, 256); + return begin_cell() + .store_uint(q, 8) + .store_uint(r, 8) + .end_cell().begin_parse(); +} diff --git a/src/func/grammar-test/__tact_debug.fc b/src/func/grammar-test/__tact_debug.fc new file mode 100644 index 000000000..3953df093 --- /dev/null +++ b/src/func/grammar-test/__tact_debug.fc @@ -0,0 +1,3 @@ +#include "include_stdlib.fc"; + +forall X -> () __tact_debug(X value, slice debug_print) impure asm "STRDUMP" "DROP" "s0 DUMP" "DROP"; diff --git a/src/func/grammar-test/__tact_load_address.fc b/src/func/grammar-test/__tact_load_address.fc new file mode 100644 index 000000000..caf5354d3 --- /dev/null +++ b/src/func/grammar-test/__tact_load_address.fc @@ -0,0 +1,7 @@ +#include "include_stdlib.fc"; +#include "__tact_verify_address.fc"; + +(slice, slice) __tact_load_address(slice cs) inline { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); +} diff --git a/src/func/grammar-test/__tact_load_address_opt.fc b/src/func/grammar-test/__tact_load_address_opt.fc new file mode 100644 index 000000000..6e8b09bb2 --- /dev/null +++ b/src/func/grammar-test/__tact_load_address_opt.fc @@ -0,0 +1,12 @@ +#include "include_stdlib.fc"; +#include "__tact_verify_address.fc"; + +(slice, slice) __tact_load_address_opt(slice cs) inline { + if (cs.preload_uint(2) != 0) { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); + } else { + cs~skip_bits(2); + return (cs, null()); + } +} diff --git a/src/func/grammar-test/__tact_load_bool.fc b/src/func/grammar-test/__tact_load_bool.fc new file mode 100644 index 000000000..5f5e969bf --- /dev/null +++ b/src/func/grammar-test/__tact_load_bool.fc @@ -0,0 +1,3 @@ +#include "include_stdlib.fc"; + +(slice, int) __tact_load_bool(slice s) asm( -> 1 0) "1 LDI"; diff --git a/src/func/grammar-test/__tact_store_address.fc b/src/func/grammar-test/__tact_store_address.fc new file mode 100644 index 000000000..a40511015 --- /dev/null +++ b/src/func/grammar-test/__tact_store_address.fc @@ -0,0 +1,6 @@ +#include "include_stdlib.fc"; +#include "__tact_verify_address.fc"; + +builder __tact_store_address(builder b, slice address) inline { + return b.store_slice(__tact_verify_address(address)); +} diff --git a/src/func/grammar-test/__tact_store_address_opt.fc b/src/func/grammar-test/__tact_store_address_opt.fc new file mode 100644 index 000000000..aa3314a9f --- /dev/null +++ b/src/func/grammar-test/__tact_store_address_opt.fc @@ -0,0 +1,11 @@ +#include "include_stdlib.fc"; +#include "__tact_store_address.fc"; + +builder __tact_store_address_opt(builder b, slice address) inline { + if (null?(address)) { + b = b.store_uint(0, 2); + return b; + } else { + return __tact_store_address(b, address); + } +} diff --git a/src/func/grammar-test/__tact_verify_address.fc b/src/func/grammar-test/__tact_verify_address.fc new file mode 100644 index 000000000..fb2d43c7b --- /dev/null +++ b/src/func/grammar-test/__tact_verify_address.fc @@ -0,0 +1,23 @@ +#include "include_stdlib.fc"; + +const int INVALID_ADDRESS = 136; +const int MC_NOT_ENABLED = 137; + +;; Without masterchain enabled +slice __tact_verify_address(slice address) inline { + throw_unless(INVALID_ADDRESS, address.slice_bits() == 267); + var h = address.preload_uint(11); + throw_if(MC_NOT_ENABLED, h == 1279); + throw_unless(INVALID_ADDRESS, h == 1024); + + return address; +} + +;; With masterchain enabled +slice __tact_verify_address_masterchain(slice address) inline { + throw_unless(INVALID_ADDRESS, address.slice_bits() == 267); + var h = address.preload_uint(11); + throw_unless(INVALID_ADDRESS, (h == 1024) | (h == 1279)); + + return address; +} diff --git a/src/func/grammar-test/include_stdlib.fc b/src/func/grammar-test/include_stdlib.fc new file mode 100644 index 000000000..d0d52fd2a --- /dev/null +++ b/src/func/grammar-test/include_stdlib.fc @@ -0,0 +1 @@ +#include "../../../stdlib/stdlib.fc"; diff --git a/src/func/grammar.spec.ts b/src/func/grammar.spec.ts new file mode 100644 index 000000000..7e0975d69 --- /dev/null +++ b/src/func/grammar.spec.ts @@ -0,0 +1,15 @@ +import { match } from "./grammar"; +import { loadCases } from "../utils/loadCases"; + +describe("FunC parser", () => { + beforeEach(() => {}); + + // Checking that FunC files match with the grammar + for (const r of loadCases(__dirname + "/test/")) { + it(r.name + " should match with the grammar", () => { + expect(match(r.code).ok).toStrictEqual(true); + }); + } + + // TODO: Tests with snapshots, once semantics and `parse` function are defined +}); diff --git a/src/func/grammar.ts b/src/func/grammar.ts new file mode 100644 index 000000000..02460221e --- /dev/null +++ b/src/func/grammar.ts @@ -0,0 +1,23 @@ +import { Interval } from "ohm-js"; +import FuncGrammar from "./grammar.ohm-bundle"; + +type Match = { ok: false; message: string; interval: Interval } | { ok: true }; + +/** + * Checks that given `src` string of FunC code matches with the FunC grammar + */ +export function match(src: string): Match { + const matchResult = FuncGrammar.match(src); + + if (matchResult.failed()) { + return { + ok: false, + message: `Parse error: expected ${(matchResult as any).getExpectedText()}\n`, + interval: matchResult.getInterval(), + }; + } + + return { ok: true }; +} + +// TODO: semantics and parsing, with errors diff --git a/src/utils/loadCases.ts b/src/utils/loadCases.ts index afe948bb8..b297650d2 100644 --- a/src/utils/loadCases.ts +++ b/src/utils/loadCases.ts @@ -1,12 +1,18 @@ import fs from "fs"; -export function loadCases(src: string) { +/** + * @param src Path to the directory with files + * @param ext Optional extension of the file, without the dot prefix + */ +export function loadCases(src: string, ext?: string) { const recs = fs.readdirSync(src); const res: { name: string; code: string }[] = []; + const extWithDot = `.${ext ? ext.toLowerCase() : "tact"}`; + for (const r of recs) { - if (r.endsWith(".tact")) { + if (r.endsWith(extWithDot)) { res.push({ - name: r.slice(0, r.length - ".tact".length), + name: r.slice(0, r.length - extWithDot.length), code: fs.readFileSync(src + r, "utf8"), }); } From 33b6b65fd5d59c3edfcf0e5545259854bd37d29b Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:07:56 +0200 Subject: [PATCH 086/162] WIP: FunC grammar & parser Needs statements, expressions, and a bit of polishing. Then, I'll add semantical analysis and exhaustive tests of all the items. --- .eslintignore | 4 +- .gitignore | 2 + .prettierignore | 2 + package.json | 2 +- src/func/grammar.ohm | 145 +++++++++++++++++++++++++++++++++++++++ src/func/grammar.spec.ts | 4 +- src/func/grammar.ts | 2 +- 7 files changed, 156 insertions(+), 5 deletions(-) create mode 100644 src/func/grammar.ohm diff --git a/.eslintignore b/.eslintignore index 882f7100d..5a4a9e3e7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,5 +6,7 @@ src/test/**/output/ src/func/funcfiftlib.js src/grammar/grammar.ohm*.ts src/grammar/grammar.ohm*.js +src/func/grammar.ohm*.ts +src/func/grammar.ohm*.js jest.setup.js -jest.teardown.js \ No newline at end of file +jest.teardown.js diff --git a/.gitignore b/.gitignore index 505434aed..9e43a843d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ dist output/ src/grammar/grammar.ohm-bundle.js src/grammar/grammar.ohm-bundle.d.ts +src/func/grammar.ohm*.ts +src/func/grammar.ohm*.js src/func/funcfiftlib.wasm.js src/codegen/contracts/*.config.json diff --git a/.prettierignore b/.prettierignore index 1af3219a2..37bb0107d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,5 +4,7 @@ /src/func/funcfiftlib.wasm.js /src/grammar/grammar.ohm-bundle.d.ts /src/grammar/grammar.ohm-bundle.js +/src/func/grammar.ohm*.ts +/src/func/grammar.ohm*.js /src/imports/stdlib.ts /grammar diff --git a/package.json b/package.json index 9774c5a84..0860ba031 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "author": "Steve Korshakov ", "license": "MIT", "scripts": { - "gen:grammar": "ohm generateBundles --withTypes src/grammar/*.ohm", + "gen:grammar": "ohm generateBundles --withTypes src/grammar/*.ohm src/func/*.ohm", "gen:pack": "ts-node ./scripts/pack.ts", "gen:compiler": "ts-node ./scripts/prepare.ts", "gen": "yarn gen:grammar && yarn gen:pack && yarn gen:compiler", diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm new file mode 100644 index 000000000..942e4f202 --- /dev/null +++ b/src/func/grammar.ohm @@ -0,0 +1,145 @@ +FunC { + Module = Pragma* Include* ModuleItem* + + // + // Compiler pragmas and includes + // + + Pragma = pragma ("allow-post-modification" | "compute-asm-ltr") ";" --string + | pragma ("version" | "not-version") versionRange ";" --versionRange + | pragma "test-version-set" stringLiteral ";" --versionString + + Include = include stringLiteral ";" + + // + // Top-level, module items + // + + ModuleItem = FunctionDeclaration + | FunctionDefinition + | AsmFunctionDefinition + | GlobalVariables + | Constants + + FunctionDeclaration = FunctionCommon ";" + + FunctionDefinition = FunctionCommon "{" Statement* "}" + + AsmFunctionDefinition = FunctionCommon "asm" ("(" AsmArrangement ")")? stringLiteral+ --singleLine + | FunctionCommon "asm" ("(" AsmArrangement ")")? multiLineString --multiLine + + AsmArrangement = "->" integerLiteralDec+ --returns + | id+ ~"->" --arguments + | id+ "->" integerLiteralDec+ --argumentsToReturns + + // Common parts of function declarations and definitions + FunctionCommon = Forall? Type functionId Parameters FunctionAttribute* + + // Called "specifiers" in https://docs.ton.org/develop/func/functions#specifiers + FunctionAttribute = "impure" + | "inline" + | "inline_ref" + | "method_id" + | MethodId + MethodId = "method_id" "(" integerLiteralNonNegative ")" + + GlobalVariables = "global" NonemptyListOf ";" + GlobalVariableDeclaration = Type id + + Constants = "const" NonemptyListOf ";" + ConstantDefinition = Type? id "=" Expression + + // + // Statements + // + + // TODO: + Statement = "TODO" + + // OK, this one is interesting + // And the following expressions one too! + + // + // Expressions, ordered by precedence + // NOTE: they should parse exactly as FunC 0.4.4 does it, including the issues with precedences of ^ | and similar + // + + // TODO: + Expression = "TODO" + + // + // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical + // + + Parameters = "(" ListOf ")" + Parameter = Type id + + Forall = forall NonemptyListOf "->" + Type = id + + // + // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical + // + + // TODO: Test if they can be names of variables, constants, functions + // Reserved keywords, order matters + keyword = pragma + | include + | forall + + pragma = "#pragma" ~idPart + include = "#include" ~idPart + forall = "forall" ~idPart + + // TODO: pre-defined function names? + // main, recv_internal, recv_external, run_ticktock + + // Identifiers + // TODO: Validate against https://docs.ton.org/develop/func/literals_identifiers#identifiers and https://github.com/ton-blockchain/ton/blob/master/crypto/func/parse-func.cpp + // They allow much more freedom it seems, which makes `funcId` in Tact's grammar.ohm invalid :/ + functionId = ("." | "~")? id + id = ~keyword #idStart #(idPart*) + idStart = letterAscii | "_" | "'" | "?" | "!" | "::" | "&" + idPart = idStart | digit + + // Letters + letterAscii = letterAsciiLC | letterAsciiUC + letterAsciiLC = "a".."z" + letterAsciiUC = "A".."Z" + + // Version ranges + versionRange = ("=" | "^" | "<" | "<=" | ">" | ">=")? integerLiteralDec ("." integerLiteralDec)? ("." integerLiteralDec)? + + // Integers + integerLiteral = "-"? integerLiteralNonNegative + integerLiteralNonNegative = integerLiteralHex + | integerLiteralDec + + // hexDigit defined in Ohm's built-in rules (otherwise: hexDigit = "0".."9" | "a".."f" | "A".."F") + integerLiteralHex = "0x" hexDigit+ + + // digit defined in Ohm's built-in rules (otherwise: digit = "0".."9") + integerLiteralDec = digit+ + + // Strings + stringLiteral = "\"" (~"\"" any)* "\"" stringType? + stringType = "s" --sliceHex + | "a" --sliceInternalAddress + | "u" --intHex + | "h" --int32Sha256 + | "H" --int256Sha256 + | "c" --intCrc32 + multiLineString = "\"\"\"" (~"\"\"\"" any)* "\"\"\"" + + // Comments + space += comment | lineTerminator + + // For semantic actions comment_singleLine and comment_multiLine + comment = ";;" (~lineTerminator any)* --singleLine + | multiLineComment --multiLine + + // Nested multi-line comments + multiLineComment = "{-" (~("-}" | "{-") any)* multiLineComment? (~"-}" any)* "-}" + + lineTerminator = "\n" | "\r" | "\u2028" | "\u2029" +} diff --git a/src/func/grammar.spec.ts b/src/func/grammar.spec.ts index 7e0975d69..81676f8f0 100644 --- a/src/func/grammar.spec.ts +++ b/src/func/grammar.spec.ts @@ -4,9 +4,9 @@ import { loadCases } from "../utils/loadCases"; describe("FunC parser", () => { beforeEach(() => {}); - // Checking that FunC files match with the grammar + // Checking that FunC files match the grammar for (const r of loadCases(__dirname + "/test/")) { - it(r.name + " should match with the grammar", () => { + it(r.name + " should match the grammar", () => { expect(match(r.code).ok).toStrictEqual(true); }); } diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 02460221e..d9a4d1132 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -4,7 +4,7 @@ import FuncGrammar from "./grammar.ohm-bundle"; type Match = { ok: false; message: string; interval: Interval } | { ok: true }; /** - * Checks that given `src` string of FunC code matches with the FunC grammar + * Checks if the given `src` string of FunC code matches the FunC grammar */ export function match(src: string): Match { const matchResult = FuncGrammar.match(src); From 8d32ff8865c9670b363c90a887630b8efa0f8982 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Sat, 27 Jul 2024 01:21:28 +0200 Subject: [PATCH 087/162] feat(func-parser): mostly finished the expressions and fixed types --- src/func/grammar.ohm | 227 ++++++++++++++++++++++++++++++++------- src/func/grammar.spec.ts | 6 +- 2 files changed, 194 insertions(+), 39 deletions(-) diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 942e4f202..8024043a1 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -33,79 +33,230 @@ FunC { | id+ "->" integerLiteralDec+ --argumentsToReturns // Common parts of function declarations and definitions - FunctionCommon = Forall? Type functionId Parameters FunctionAttribute* + FunctionCommon = Forall? TypeMapped functionId Parameters FunctionAttribute* // Called "specifiers" in https://docs.ton.org/develop/func/functions#specifiers FunctionAttribute = "impure" | "inline" | "inline_ref" | "method_id" - | MethodId - MethodId = "method_id" "(" integerLiteralNonNegative ")" + | MethodIdValue + + MethodIdValue = "method_id" "(" integerLiteralNonNegative ")" GlobalVariables = "global" NonemptyListOf ";" - GlobalVariableDeclaration = Type id + GlobalVariableDeclaration = TypeMapped? id Constants = "const" NonemptyListOf ";" - ConstantDefinition = Type? id "=" Expression + ConstantDefinition = constantType? id "=" Expression // // Statements // - // TODO: - Statement = "TODO" - - // OK, this one is interesting - // And the following expressions one too! + Statement = StatementReturn + | StatementBlock + | StatementEmpty + | StatementCondition + | StatementRepeat + | StatementUntil + | StatementWhile + | StatementTryCatch + | StatementExpression + + StatementReturn = "return" Expression ";" + StatementBlock = "{" Statement* "}" + StatementEmpty = ";" + StatementCondition = ("if" | "ifnot") Expression "{" Statement* "}" --noElse + | ("if" | "ifnot") Expression "{" Statement* "}" "else" "{" Statement* "}" --withElse + | ("if" | "ifnot") Expression "{" Statement* "}" ("elseif" | "elseifnot") "{" Statement* "}" --withElseCondition + StatementRepeat = "repeat" Expression "{" Statement* "}" + StatementUntil = "do" "{" Statement* "}" "until" Expression ";" + StatementWhile = "while" Expression "{" Statement* "}" + StatementTryCatch = "try" "{" Statement* "}" "catch" "(" (unusedId | id) "," (unusedId | id) ")" "{" Statement* "}" + StatementExpression = Expression ";" // - // Expressions, ordered by precedence - // NOTE: they should parse exactly as FunC 0.4.4 does it, including the issues with precedences of ^ | and similar + // Expressions, ordered by precedence (from lowest to highest), + // with comments referencing exact function names in C++ code of FunC's parser: + // https://github.com/ton-blockchain/ton/blob/master/crypto/func/parse-func.cpp // - // TODO: - Expression = "TODO" + // NOTE: they should parse exactly as FunC 0.4.4 does it, including the issues with precedences of ^ | and similar + + // parse_expr + Expression = ExpressionAssign + + // parse_expr10 + ExpressionAssign = ExpressionConditional "=" ExpressionAssign --assign + | ExpressionConditional "+=" ExpressionAssign --addAssign + | ExpressionConditional "-=" ExpressionAssign --subAssign + | ExpressionConditional "*=" ExpressionAssign --mulAssign + | ExpressionConditional "/=" ExpressionAssign --divAssign + | ExpressionConditional "%=" ExpressionAssign --modAssign + | ExpressionConditional "~/=" ExpressionAssign --divRoundAssign + | ExpressionConditional "~%=" ExpressionAssign --modRoundAssign + | ExpressionConditional "^/=" ExpressionAssign --divCeilAssign + | ExpressionConditional "^%=" ExpressionAssign --modCeilAssign + | ExpressionConditional "&=" ExpressionAssign --bitwiseAndAssign + | ExpressionConditional "|=" ExpressionAssign --bitwiseOrAssign + | ExpressionConditional "^=" ExpressionAssign --bitwiseXorAssign + | ExpressionConditional "<<=" ExpressionAssign --shlAssign + | ExpressionConditional ">>=" ExpressionAssign --shrAssign + | ExpressionConditional "~>>=" ExpressionAssign --shrRoundAssign + | ExpressionConditional "^>>=" ExpressionAssign --shrCeilAssign + | ExpressionConditional + + // parse_expr13 + ExpressionConditional = ExpressionCompare "?" Expression ":" ExpressionConditional --ternary + | ExpressionCompare + + // parse_expr15 + ExpressionCompare = ExpressionBitwiseShift "==" ExpressionBitwiseShift --eq + | ExpressionBitwiseShift "<" ExpressionBitwiseShift --lt + | ExpressionBitwiseShift ">" ExpressionBitwiseShift --gt + | ExpressionBitwiseShift "<=" ExpressionBitwiseShift --lte + | ExpressionBitwiseShift ">=" ExpressionBitwiseShift --gte + | ExpressionBitwiseShift "!=" ExpressionBitwiseShift --neq + | ExpressionBitwiseShift "<=>" ExpressionBitwiseShift --spaceship + | ExpressionBitwiseShift + + // parse_expr17 + ExpressionBitwiseShift = ExpressionAddBitwise "<<" ExpressionAddBitwise --shl + | ExpressionAddBitwise ">>" ExpressionAddBitwise --shr + | ExpressionAddBitwise "~>>" ExpressionAddBitwise --shrRound + | ExpressionAddBitwise "^>>" ExpressionAddBitwise --shrCeil + | ExpressionAddBitwise + + // parse_expr20 + ExpressionAddBitwise = "-"? ExpressionMulBitwise "+" ExpressionMulBitwise --add + | "-"? ExpressionMulBitwise "-" ExpressionMulBitwise --sub + | "-"? ExpressionMulBitwise "|" ExpressionMulBitwise --bitwiseOr + | "-"? ExpressionMulBitwise "^" ExpressionMulBitwise --bitwiseXor + | "-" ExpressionMulBitwise --minus + | ExpressionMulBitwise + + // parse_expr30 + ExpressionMulBitwise = ExpressionUnary "*" ExpressionUnary --mul + | ExpressionUnary "/%" ExpressionUnary --divMod + | ExpressionUnary "/" ExpressionUnary --div + | ExpressionUnary "%" ExpressionUnary --mod + | ExpressionUnary "~/" ExpressionUnary --divRound + | ExpressionUnary "~%" ExpressionUnary --modRound + | ExpressionUnary "^/" ExpressionUnary --divCeil + | ExpressionUnary "^%" ExpressionUnary --modCeil + | ExpressionUnary "&" ExpressionUnary --bitwiseAnd + | ExpressionUnary + + // parse_expr75 + ExpressionUnary = "~" ExpressionMethodCall --bitwiseNot + | ExpressionMethodCall + + // parse_expr80 + ExpressionMethodCall = ExpressionSequence ("." | "~") id ExpressionPrimary --call + | ExpressionSequence + + // parse_expr90, FIXME: this is wrong and has to be re-made :) + // TODO: function call + // TODO: variable declaration + ExpressionSequence = ExpressionPrimary &"(" ExpressionPrimary --call + | ExpressionPrimary &"[" ExpressionPrimary --access + | ExpressionPrimary ~("." | "~") id ExpressionPrimary --id + | ExpressionPrimary + + // parse_expr100, order is important + ExpressionPrimary = ExpressionTuple + | ExpressionTensor + | integerLiteral + | stringLiteral + | hole + | var + | primitiveType // TODO: re-make this one. + | id // includes true|false, null|Null + // TODO: parens + // TODO: unit + // TODO: slice_string_ident? + + // TODO: ... + ExpressionTuple = "(" "TODO:" ")" + ExpressionTensor = "[" "TODO:" "]" // // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // + // Parameters TODO: check the type Parameters = "(" ListOf ")" Parameter = Type id - Forall = forall NonemptyListOf "->" - Type = id + // Arguments + // TODO: + + // forall type1, ..., typeN -> + Forall = forall NonemptyListOf "->" + ForallType = "type"? id + + // TE ::= TA | TA -> TE + // TypeMapped = Type ("->" TypeMapped)? + TypeMapped = Type "->" TypeMapped --mapped + | Type --unmapped + + // TA ::= int | ... | cont | var | _ | () | ( TE { , TE } ) | [ TE { , TE } ] + Type = "int" + | "cell" + | "slice" + | "builder" + | "cont" + | "tuple" + | hole + | unit + | Tensor + | Tuple + + Tensor = "(" NonemptyListOf ")" + Tuple = "[" NonemptyListOf "]" // // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // + // TODO: Move over the remaining keywords // TODO: Test if they can be names of variables, constants, functions - // Reserved keywords, order matters + // Reserved keywords, order matters (TODO: does it?) keyword = pragma | include | forall + | var + | primitiveType + + pragma = "#pragma" ~id + include = "#include" ~id + forall = "forall" ~id + var = "var" ~id - pragma = "#pragma" ~idPart - include = "#include" ~idPart - forall = "forall" ~idPart + // Types + hole = "_" | "var" + unit = "()" + constantType = "int" | "slice" + // TODO: ... + tuple = "" + // TODO: ... + tensor = "" - // TODO: pre-defined function names? - // main, recv_internal, recv_external, run_ticktock + // Primitive types, FIXME: ... + primitiveType = "int" | "cell" | "slice" | "builder" | "cont" | "type" | "tuple" + + // Function identifiers + functionId = ~("\"" | "{-") ("." | "~")? id // Identifiers - // TODO: Validate against https://docs.ton.org/develop/func/literals_identifiers#identifiers and https://github.com/ton-blockchain/ton/blob/master/crypto/func/parse-func.cpp - // They allow much more freedom it seems, which makes `funcId` in Tact's grammar.ohm invalid :/ - functionId = ("." | "~")? id - id = ~keyword #idStart #(idPart*) - idStart = letterAscii | "_" | "'" | "?" | "!" | "::" | "&" - idPart = idStart | digit - - // Letters - letterAscii = letterAsciiLC | letterAsciiUC - letterAsciiLC = "a".."z" - letterAsciiUC = "A".."Z" + id = ~keyword ~("\"" | "{-") (quotedId | plainId) + + plainId = "_"? "-"? "0x"? hexDigit* ~hexDigit (~(whiteSpace | "(" | ")" | "," | "." | ";" | "~") any)+ + + quotedId = "`" (~("`" | "\n") any)+ "`" + + unusedId = "_" // Version ranges versionRange = ("=" | "^" | "<" | "<=" | ">" | ">=")? integerLiteralDec ("." integerLiteralDec)? ("." integerLiteralDec)? @@ -113,12 +264,12 @@ FunC { // Integers integerLiteral = "-"? integerLiteralNonNegative integerLiteralNonNegative = integerLiteralHex - | integerLiteralDec + | integerLiteralDec - // hexDigit defined in Ohm's built-in rules (otherwise: hexDigit = "0".."9" | "a".."f" | "A".."F") + // hexDigit is defined in Ohm's built-in rules as: hexDigit = "0".."9" | "a".."f" | "A".."F" integerLiteralHex = "0x" hexDigit+ - // digit defined in Ohm's built-in rules (otherwise: digit = "0".."9") + // digit is defined in Ohm's built-in rules as: digit = "0".."9" integerLiteralDec = digit+ // Strings @@ -131,9 +282,11 @@ FunC { | "c" --intCrc32 multiLineString = "\"\"\"" (~"\"\"\"" any)* "\"\"\"" - // Comments + // Whitespace space += comment | lineTerminator + whiteSpace = "\t" | " " | lineTerminator + // Comments // For semantic actions comment_singleLine and comment_multiLine comment = ";;" (~lineTerminator any)* --singleLine | multiLineComment --multiLine diff --git a/src/func/grammar.spec.ts b/src/func/grammar.spec.ts index 81676f8f0..3d2a3bc1b 100644 --- a/src/func/grammar.spec.ts +++ b/src/func/grammar.spec.ts @@ -1,11 +1,13 @@ import { match } from "./grammar"; import { loadCases } from "../utils/loadCases"; -describe("FunC parser", () => { +describe("FunC grammar and parser", () => { beforeEach(() => {}); // Checking that FunC files match the grammar - for (const r of loadCases(__dirname + "/test/")) { + for (const r of loadCases(__dirname + "/grammar-test/", "fc")) { + // if (r.name !== "include_stdlib") continue; + it(r.name + " should match the grammar", () => { expect(match(r.code).ok).toStrictEqual(true); }); From 8bc2486e496a6d00cca452b2c78ed28ed204a0c2 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:11:03 +0200 Subject: [PATCH 088/162] feat: tested top-level things, added more tests for identifiers Fully tested: * Asm Functions * Globals * Pragmas * Constants Partially tested: Function definitions and declarations Next up: Statements Broght over identifier tests from the funcId fixing PRs. Almost re-wrote the universally correct identifier recognition, stuck with underscores for a bit. Will move past that and finilize all other things, up to (and perhaps including) expressions + semantics. In the background I'll try to polish identifiers some more :) --- cspell.json | 7 +- .../grammar-test-failed/id-arith-operator.fc | 1 + .../grammar-test-failed/id-assign-operator.fc | 1 + .../id-bitwise-operator.fc | 1 + src/func/grammar-test-failed/id-comma.fc | 1 + .../id-comparison-operator.fc | 1 + .../grammar-test-failed/id-control-keyword.fc | 1 + src/func/grammar-test-failed/id-delimiter.fc | 1 + src/func/grammar-test-failed/id-directive.fc | 1 + src/func/grammar-test-failed/id-dot.fc | 1 + src/func/grammar-test-failed/id-keyword.fc | 1 + .../id-multiline-comments.fc | 1 + .../grammar-test-failed/id-number-decimal.fc | 1 + .../id-number-hexadecimal-2.fc | 1 + .../id-number-hexadecimal.fc | 1 + .../id-number-neg-decimal.fc | 2 + .../id-number-neg-hexadecimal.fc | 1 + src/func/grammar-test-failed/id-number.fc | 1 + .../grammar-test-failed/id-only-underscore.fc | 1 + src/func/grammar-test-failed/id-parens.fc | 1 + src/func/grammar-test-failed/id-semicolons.fc | 1 + src/func/grammar-test-failed/id-space.fc | 1 + src/func/grammar-test-failed/id-string.fc | 1 + .../grammar-test-failed/id-type-keyword.fc | 1 + .../grammar-test-failed/id-unclosed-parens.fc | 1 + src/func/grammar-test/asm-functions.fc | 31 +++++++ src/func/grammar-test/constants.fc | 8 ++ src/func/grammar-test/globals.fc | 14 +++ src/func/grammar-test/identifiers.fc | 44 +++++++++ src/func/grammar-test/pragmas.fc | 30 ++++++ src/func/grammar.ohm | 92 +++++++++++-------- src/func/grammar.spec.ts | 21 ++++- 32 files changed, 232 insertions(+), 40 deletions(-) create mode 100644 src/func/grammar-test-failed/id-arith-operator.fc create mode 100644 src/func/grammar-test-failed/id-assign-operator.fc create mode 100644 src/func/grammar-test-failed/id-bitwise-operator.fc create mode 100644 src/func/grammar-test-failed/id-comma.fc create mode 100644 src/func/grammar-test-failed/id-comparison-operator.fc create mode 100644 src/func/grammar-test-failed/id-control-keyword.fc create mode 100644 src/func/grammar-test-failed/id-delimiter.fc create mode 100644 src/func/grammar-test-failed/id-directive.fc create mode 100644 src/func/grammar-test-failed/id-dot.fc create mode 100644 src/func/grammar-test-failed/id-keyword.fc create mode 100644 src/func/grammar-test-failed/id-multiline-comments.fc create mode 100644 src/func/grammar-test-failed/id-number-decimal.fc create mode 100644 src/func/grammar-test-failed/id-number-hexadecimal-2.fc create mode 100644 src/func/grammar-test-failed/id-number-hexadecimal.fc create mode 100644 src/func/grammar-test-failed/id-number-neg-decimal.fc create mode 100644 src/func/grammar-test-failed/id-number-neg-hexadecimal.fc create mode 100644 src/func/grammar-test-failed/id-number.fc create mode 100644 src/func/grammar-test-failed/id-only-underscore.fc create mode 100644 src/func/grammar-test-failed/id-parens.fc create mode 100644 src/func/grammar-test-failed/id-semicolons.fc create mode 100644 src/func/grammar-test-failed/id-space.fc create mode 100644 src/func/grammar-test-failed/id-string.fc create mode 100644 src/func/grammar-test-failed/id-type-keyword.fc create mode 100644 src/func/grammar-test-failed/id-unclosed-parens.fc create mode 100644 src/func/grammar-test/asm-functions.fc create mode 100644 src/func/grammar-test/constants.fc create mode 100644 src/func/grammar-test/globals.fc create mode 100644 src/func/grammar-test/identifiers.fc create mode 100644 src/func/grammar-test/pragmas.fc diff --git a/cspell.json b/cspell.json index bb280eeb5..300167f87 100644 --- a/cspell.json +++ b/cspell.json @@ -84,7 +84,12 @@ "node_modules", "dist", "examples/__snapshots__/multisig-3.spec.ts.snap", - "func", + "/func", + "scripts/func", + "src/func/grammar.ohm*", + "src/func/funcfiftlib*", + "src/func/grammar-test/*", + "src/func/grammar-test-failed/*", "grammar/sample.json", "src/generator/writers/writeStdlib.ts", "src/generator/writers/__snapshots__/writeSerialization.spec.ts.snap", diff --git a/src/func/grammar-test-failed/id-arith-operator.fc b/src/func/grammar-test-failed/id-arith-operator.fc new file mode 100644 index 000000000..9ab3bcc39 --- /dev/null +++ b/src/func/grammar-test-failed/id-arith-operator.fc @@ -0,0 +1 @@ +() /(); diff --git a/src/func/grammar-test-failed/id-assign-operator.fc b/src/func/grammar-test-failed/id-assign-operator.fc new file mode 100644 index 000000000..e2ae7f1e6 --- /dev/null +++ b/src/func/grammar-test-failed/id-assign-operator.fc @@ -0,0 +1 @@ +() ^>>=(); diff --git a/src/func/grammar-test-failed/id-bitwise-operator.fc b/src/func/grammar-test-failed/id-bitwise-operator.fc new file mode 100644 index 000000000..ea7c369ea --- /dev/null +++ b/src/func/grammar-test-failed/id-bitwise-operator.fc @@ -0,0 +1 @@ +() ~(); diff --git a/src/func/grammar-test-failed/id-comma.fc b/src/func/grammar-test-failed/id-comma.fc new file mode 100644 index 000000000..c66116762 --- /dev/null +++ b/src/func/grammar-test-failed/id-comma.fc @@ -0,0 +1 @@ +() send_message,then_terminate(); diff --git a/src/func/grammar-test-failed/id-comparison-operator.fc b/src/func/grammar-test-failed/id-comparison-operator.fc new file mode 100644 index 000000000..8b1d65d51 --- /dev/null +++ b/src/func/grammar-test-failed/id-comparison-operator.fc @@ -0,0 +1 @@ +() <=>(); diff --git a/src/func/grammar-test-failed/id-control-keyword.fc b/src/func/grammar-test-failed/id-control-keyword.fc new file mode 100644 index 000000000..1f655d470 --- /dev/null +++ b/src/func/grammar-test-failed/id-control-keyword.fc @@ -0,0 +1 @@ +() elseifnot(); diff --git a/src/func/grammar-test-failed/id-delimiter.fc b/src/func/grammar-test-failed/id-delimiter.fc new file mode 100644 index 000000000..238252258 --- /dev/null +++ b/src/func/grammar-test-failed/id-delimiter.fc @@ -0,0 +1 @@ +() [(); diff --git a/src/func/grammar-test-failed/id-directive.fc b/src/func/grammar-test-failed/id-directive.fc new file mode 100644 index 000000000..36ab4d67a --- /dev/null +++ b/src/func/grammar-test-failed/id-directive.fc @@ -0,0 +1 @@ +() #include(); diff --git a/src/func/grammar-test-failed/id-dot.fc b/src/func/grammar-test-failed/id-dot.fc new file mode 100644 index 000000000..c9eeaa3f0 --- /dev/null +++ b/src/func/grammar-test-failed/id-dot.fc @@ -0,0 +1 @@ +() msg.sender(); diff --git a/src/func/grammar-test-failed/id-keyword.fc b/src/func/grammar-test-failed/id-keyword.fc new file mode 100644 index 000000000..29407c70e --- /dev/null +++ b/src/func/grammar-test-failed/id-keyword.fc @@ -0,0 +1 @@ +() global(); diff --git a/src/func/grammar-test-failed/id-multiline-comments.fc b/src/func/grammar-test-failed/id-multiline-comments.fc new file mode 100644 index 000000000..fd5a725ba --- /dev/null +++ b/src/func/grammar-test-failed/id-multiline-comments.fc @@ -0,0 +1 @@ +() {-aaa-}(); diff --git a/src/func/grammar-test-failed/id-number-decimal.fc b/src/func/grammar-test-failed/id-number-decimal.fc new file mode 100644 index 000000000..83d4de354 --- /dev/null +++ b/src/func/grammar-test-failed/id-number-decimal.fc @@ -0,0 +1 @@ +() 0(); diff --git a/src/func/grammar-test-failed/id-number-hexadecimal-2.fc b/src/func/grammar-test-failed/id-number-hexadecimal-2.fc new file mode 100644 index 000000000..84a5b35d3 --- /dev/null +++ b/src/func/grammar-test-failed/id-number-hexadecimal-2.fc @@ -0,0 +1 @@ +() 0xDEADBEEF(); diff --git a/src/func/grammar-test-failed/id-number-hexadecimal.fc b/src/func/grammar-test-failed/id-number-hexadecimal.fc new file mode 100644 index 000000000..c35553ca5 --- /dev/null +++ b/src/func/grammar-test-failed/id-number-hexadecimal.fc @@ -0,0 +1 @@ +() 0x0(); diff --git a/src/func/grammar-test-failed/id-number-neg-decimal.fc b/src/func/grammar-test-failed/id-number-neg-decimal.fc new file mode 100644 index 000000000..373dc4deb --- /dev/null +++ b/src/func/grammar-test-failed/id-number-neg-decimal.fc @@ -0,0 +1,2 @@ +() -1(); +native idTest(); diff --git a/src/func/grammar-test-failed/id-number-neg-hexadecimal.fc b/src/func/grammar-test-failed/id-number-neg-hexadecimal.fc new file mode 100644 index 000000000..e970ae28d --- /dev/null +++ b/src/func/grammar-test-failed/id-number-neg-hexadecimal.fc @@ -0,0 +1 @@ +() -0x0(); diff --git a/src/func/grammar-test-failed/id-number.fc b/src/func/grammar-test-failed/id-number.fc new file mode 100644 index 000000000..7e8936ab5 --- /dev/null +++ b/src/func/grammar-test-failed/id-number.fc @@ -0,0 +1 @@ +() 123(); diff --git a/src/func/grammar-test-failed/id-only-underscore.fc b/src/func/grammar-test-failed/id-only-underscore.fc new file mode 100644 index 000000000..cb6453698 --- /dev/null +++ b/src/func/grammar-test-failed/id-only-underscore.fc @@ -0,0 +1 @@ +() _(); diff --git a/src/func/grammar-test-failed/id-parens.fc b/src/func/grammar-test-failed/id-parens.fc new file mode 100644 index 000000000..7519de180 --- /dev/null +++ b/src/func/grammar-test-failed/id-parens.fc @@ -0,0 +1 @@ +() take(first)Entry(); diff --git a/src/func/grammar-test-failed/id-semicolons.fc b/src/func/grammar-test-failed/id-semicolons.fc new file mode 100644 index 000000000..d4efb416c --- /dev/null +++ b/src/func/grammar-test-failed/id-semicolons.fc @@ -0,0 +1 @@ +() pa;;in"`aaa`"(); diff --git a/src/func/grammar-test-failed/id-space.fc b/src/func/grammar-test-failed/id-space.fc new file mode 100644 index 000000000..500f4d62f --- /dev/null +++ b/src/func/grammar-test-failed/id-space.fc @@ -0,0 +1 @@ +() foo foo(); diff --git a/src/func/grammar-test-failed/id-string.fc b/src/func/grammar-test-failed/id-string.fc new file mode 100644 index 000000000..87323b295 --- /dev/null +++ b/src/func/grammar-test-failed/id-string.fc @@ -0,0 +1 @@ +() "not_a_string(); diff --git a/src/func/grammar-test-failed/id-type-keyword.fc b/src/func/grammar-test-failed/id-type-keyword.fc new file mode 100644 index 000000000..7b1471218 --- /dev/null +++ b/src/func/grammar-test-failed/id-type-keyword.fc @@ -0,0 +1 @@ +() ->(); diff --git a/src/func/grammar-test-failed/id-unclosed-parens.fc b/src/func/grammar-test-failed/id-unclosed-parens.fc new file mode 100644 index 000000000..b63e7a582 --- /dev/null +++ b/src/func/grammar-test-failed/id-unclosed-parens.fc @@ -0,0 +1 @@ +() aa(bb(); diff --git a/src/func/grammar-test/asm-functions.fc b/src/func/grammar-test/asm-functions.fc new file mode 100644 index 000000000..a7b624b16 --- /dev/null +++ b/src/func/grammar-test/asm-functions.fc @@ -0,0 +1,31 @@ +;; Single assembly string +int inc_then_negate(int x) asm "INC NEGATE"; + +;; Multiple assembly strings +int inc_then_negate'(int x) asm "INC" "NEGATE"; + +;; Multi-line strings + +int inc_then_negate''(int x) asm """INC NEGATE"""; + +slice hello_world() asm """ + "Hello" + " " + "World" + $+ $+ $>s + PUSHSLICE +"""; + +;; Arrangement of return values (and whitespaces check) + (builder, int) +store_uint_quiet (builder b, int x, int len) +asm (x b len) +"STUXQ"; + +;; Arrangement of arguments +(int, builder) store_uint_quite(int x, builder b, int len) + asm( -> 1 0) "STUXQ"; + +;; Arrangement of arguments mapped to return values +(int, builder) store_uint_quite(builder b, int x, int len) + asm(x b len -> 1 0) "STUXQ"; diff --git a/src/func/grammar-test/constants.fc b/src/func/grammar-test/constants.fc new file mode 100644 index 000000000..a6fa81da2 --- /dev/null +++ b/src/func/grammar-test/constants.fc @@ -0,0 +1,8 @@ +;; Inferred type +const c1 = 42; + +;; Inferred type for multiple ones with using prior constants +const c2 = 27, c3 = c1; + +;; int, inferred int or slice from a string +const int c4 = 0, c5 = 0, slice c6 = "It's Zendaya"s; diff --git a/src/func/grammar-test/globals.fc b/src/func/grammar-test/globals.fc new file mode 100644 index 000000000..4eb7884da --- /dev/null +++ b/src/func/grammar-test/globals.fc @@ -0,0 +1,14 @@ +;; No type +global glob1; + +;; Primitive type +global int glob2; + +;; Mapped type +global int -> int glob3; + +;; Convoluted example +global ((int, (_, cont, cell, (), [int])) -> int) glob4; + +;; Multiple at once +global int glob5, (builder, tuple) glob6, glob7; diff --git a/src/func/grammar-test/identifiers.fc b/src/func/grammar-test/identifiers.fc new file mode 100644 index 000000000..5fa29ad3b --- /dev/null +++ b/src/func/grammar-test/identifiers.fc @@ -0,0 +1,44 @@ +;; Identifiers +global query'; +global query''; +global CHECK; +global _internal_val; +global message_found?; +global get_pubkeys&signatures; +global dict::udict_set_builder; +global _+_; +global __; +global fatal!; +global 123validname; +global 2+2=2*2; +global -alsovalidname; +global 0xefefefhahaha; +global {hehehe}; +global pa{--}in"`aaa`"; +global `I'm a function too`; +global `any symbols ; ~ () are allowed here...`; +global C4; +global C4g; +global 4C; +global _0x0; +global _0; +global 0x_; +global 0x0_; +global 0_; +global hash#256; +global 💀💀💀0xDEADBEEF💀💀💀; +global __tact_verify_address; +global __tact_pow2; +global randomize_lt; +global fixed248::asin; +global fixed248::nrand_fast; +global atan_f261_inlined; +global f̷̨͈͚́͌̀i̵̩͔̭̐͐̊n̸̟̝̻̩̎̓͋̕e̸̝̙̒̿͒̾̕; +global ❤️❤️❤️thanks❤️❤️❤️; +global intslice; +global int2; + +;; Function identifiers, which can start with . or ~ +() ~impure_touch(); +() ~udict::delete_get_min(); +() .something(); diff --git a/src/func/grammar-test/pragmas.fc b/src/func/grammar-test/pragmas.fc new file mode 100644 index 000000000..72415dddf --- /dev/null +++ b/src/func/grammar-test/pragmas.fc @@ -0,0 +1,30 @@ +;; Literals +#pragma allow-post-modification; +#pragma compute-asm-ltr; + +;; Version ranges +#pragma version 0; +#pragma version 0.0; +#pragma version 0.0.0; +#pragma version =0; +#pragma version =0.0; +#pragma version =0.0.0; +#pragma version ^0; +#pragma version <0; +#pragma version >0; +#pragma version <=0; +#pragma version >=0; +#pragma not-version 0; +#pragma not-version 0.0; +#pragma not-version 0.0.0; +#pragma not-version =0; +#pragma not-version =0.0; +#pragma not-version =0.0.0; +#pragma not-version ^0; +#pragma not-version <0; +#pragma not-version >0; +#pragma not-version <=0; +#pragma not-version >=0; + +;; Used in internal tests of FunC in ton-blockchain/ton monorepo +#pragma test-version-set "0.4.4"; diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 8024043a1..8aca2669c 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -5,7 +5,7 @@ FunC { // Compiler pragmas and includes // - Pragma = pragma ("allow-post-modification" | "compute-asm-ltr") ";" --string + Pragma = pragma ("allow-post-modification" | "compute-asm-ltr") ";" --literal | pragma ("version" | "not-version") versionRange ";" --versionRange | pragma "test-version-set" stringLiteral ";" --versionString @@ -15,41 +15,36 @@ FunC { // Top-level, module items // - ModuleItem = FunctionDeclaration - | FunctionDefinition - | AsmFunctionDefinition - | GlobalVariables + ModuleItem = GlobalVariables | Constants + | AsmFunctionDefinition + | FunctionDeclaration + | FunctionDefinition - FunctionDeclaration = FunctionCommon ";" + GlobalVariables = "global" NonemptyListOf ";" + GlobalVariableDeclaration = TypeMapped? id - FunctionDefinition = FunctionCommon "{" Statement* "}" + Constants = "const" NonemptyListOf ";" + ConstantDefinition = TypeConstant? id "=" Expression - AsmFunctionDefinition = FunctionCommon "asm" ("(" AsmArrangement ")")? stringLiteral+ --singleLine - | FunctionCommon "asm" ("(" AsmArrangement ")")? multiLineString --multiLine + AsmFunctionDefinition = FunctionCommon "asm" ("(" AsmArrangement ")")? stringLiteral+ ";" --singleLine + | FunctionCommon "asm" ("(" AsmArrangement ")")? multiLineString ";" --multiLine AsmArrangement = "->" integerLiteralDec+ --returns | id+ ~"->" --arguments | id+ "->" integerLiteralDec+ --argumentsToReturns + FunctionDeclaration = FunctionCommon ";" + + FunctionDefinition = FunctionCommon "{" Statement* "}" + // Common parts of function declarations and definitions FunctionCommon = Forall? TypeMapped functionId Parameters FunctionAttribute* // Called "specifiers" in https://docs.ton.org/develop/func/functions#specifiers - FunctionAttribute = "impure" - | "inline" - | "inline_ref" - | "method_id" - | MethodIdValue - + FunctionAttribute = "impure" | "inline_ref" | "inline" | MethodIdValue | "method_id" MethodIdValue = "method_id" "(" integerLiteralNonNegative ")" - GlobalVariables = "global" NonemptyListOf ";" - GlobalVariableDeclaration = TypeMapped? id - - Constants = "const" NonemptyListOf ";" - ConstantDefinition = constantType? id "=" Expression - // // Statements // @@ -187,7 +182,7 @@ FunC { // Parameters TODO: check the type Parameters = "(" ListOf ")" - Parameter = Type id + Parameter = TypeMapped id // Arguments // TODO: @@ -196,10 +191,12 @@ FunC { Forall = forall NonemptyListOf "->" ForallType = "type"? id + // Allowed types of constants + TypeConstant = "int" | "slice" + // TE ::= TA | TA -> TE - // TypeMapped = Type ("->" TypeMapped)? TypeMapped = Type "->" TypeMapped --mapped - | Type --unmapped + | Type // TA ::= int | ... | cont | var | _ | () | ( TE { , TE } ) | [ TE { , TE } ] Type = "int" @@ -221,7 +218,9 @@ FunC { // // TODO: Move over the remaining keywords - // TODO: Test if they can be names of variables, constants, functions + // TODO: Test if they can be names of variables, constants, functions -- yup, they cannot!!! + // Also, operators cannot too! And some other things!!! + // TODO: actually put everything from https://github.com/ton-blockchain/ton/blob/master/crypto/func/keywords.cpp // Reserved keywords, order matters (TODO: does it?) keyword = pragma | include @@ -234,32 +233,53 @@ FunC { forall = "forall" ~id var = "var" ~id - // Types + // Special types hole = "_" | "var" unit = "()" - constantType = "int" | "slice" - // TODO: ... - tuple = "" - // TODO: ... - tensor = "" - // Primitive types, FIXME: ... + // Primitive types, FIXME: delete or something primitiveType = "int" | "cell" | "slice" | "builder" | "cont" | "type" | "tuple" // Function identifiers functionId = ~("\"" | "{-") ("." | "~")? id // Identifiers - id = ~keyword ~("\"" | "{-") (quotedId | plainId) - - plainId = "_"? "-"? "0x"? hexDigit* ~hexDigit (~(whiteSpace | "(" | ")" | "," | "." | ";" | "~") any)+ + id = ~("\"" | "{-") (quotedId | plainId) quotedId = "`" (~("`" | "\n") any)+ "`" + plainId = ~(reservedId ~idPart) idPart + // plainId = ~reservedId idPart + + idPart = (~(whiteSpace | "(" | ")" | "," | "." | ";" | "~") any)+ + // TODO: make tests for each of those individually ^^^ + + // Order matters + reservedId = "_" + | integerLiteral | "-=" | "->" |"-" + | "#include" | "#pragma" + | "!=" | "==" | "=" + | "<<=" | "<<" | "<=>" | "<=" | "<" | ">>=" | ">>" | ">=" | ">" + | "~>>=" | "~>>" | "~/=" | "~/" | "~%=" | "~%" | "~" + | "^>>=" | "^>>" | "^/=" | "^/" | "^%=" | "^%" | "^=" | "^" + | "+=" | "+" | "*=" | "*" | "/=" | "/%" | "/" | "%=" | "%" | "&=" | "&" | "|=" | "|" + | "(" | ")" | "[" | "]" | "{" | "}" | "?" | ":" | "," | ";" | "." | "~" + | "asm" | "auto_apply" | "builder" | "catch" | "cell" | "const" | "cont" | "do" + | "elseifnot" | "elseif" | "else" | "extern" | "forall" | "global" | "ifnot" | "if" + | "impure" | "infixl" | "infixr" | "infix" | "inline_ref" | "inline" | "int" + | "method_id" | "operator" | "repeat" | "return" | "slice" | "then" | "try" | "tuple" + | "type" | "until" | "var" | "while" + unusedId = "_" + /* + 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. + */ + // Version ranges - versionRange = ("=" | "^" | "<" | "<=" | ">" | ">=")? integerLiteralDec ("." integerLiteralDec)? ("." integerLiteralDec)? + versionRange = ("=" | "^" | "<=" | ">=" | "<" | ">")? integerLiteralDec ("." integerLiteralDec)? ("." integerLiteralDec)? // Integers integerLiteral = "-"? integerLiteralNonNegative diff --git a/src/func/grammar.spec.ts b/src/func/grammar.spec.ts index 3d2a3bc1b..cb370c9a4 100644 --- a/src/func/grammar.spec.ts +++ b/src/func/grammar.spec.ts @@ -4,12 +4,27 @@ import { loadCases } from "../utils/loadCases"; describe("FunC grammar and parser", () => { beforeEach(() => {}); + const target = "asm-functions"; + // const target = "identifiers"; + // Checking that FunC files match the grammar for (const r of loadCases(__dirname + "/grammar-test/", "fc")) { - // if (r.name !== "include_stdlib") continue; - + if (r.name !== target) continue; it(r.name + " should match the grammar", () => { - expect(match(r.code).ok).toStrictEqual(true); + const res = match(r.code); + + if (res.ok === false) { + console.log(res.message, res.interval.getLineAndColumn()); + } + + expect(res.ok).toStrictEqual(true); + }); + } + + // Checking that certain FunC files DON'T match the grammar + for (const r of loadCases(__dirname + "/grammar-test-failed/", "fc")) { + it(r.name + " should not match the grammar", () => { + expect(match(r.code).ok).toStrictEqual(false); }); } From bfab588a88d2c43a2f5abe44e10d94859466cbcc Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Tue, 30 Jul 2024 00:24:33 +0200 Subject: [PATCH 089/162] feat(func-parser): 1/3 of types and semantics Later on, `FuncAst...` types from `grammar.ts` need to be merged with ones in `syntax.ts`, in favor of the former --- package.json | 1 + src/func/grammar.ohm | 144 +++++------- src/func/grammar.spec.ts | 37 +-- src/func/grammar.ts | 487 ++++++++++++++++++++++++++++++++++++++- src/func/syntax.ts | 1 + 5 files changed, 564 insertions(+), 106 deletions(-) diff --git a/package.json b/package.json index 0860ba031..b208d0414 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "clean": "rm -fr dist", "build": "tsc && cp ./src/grammar/grammar.ohm* ./dist/grammar/ && cp ./src/func/funcfiftlib.* ./dist/func", "test": "jest", + "test:func": "yarn gen:grammar && jest -t 'FunC grammar and parser'", "coverage": "cross-env COVERAGE=true jest", "release": "yarn clean && yarn build && yarn coverage && yarn release-it --npm.yarn1", "lint": "yarn eslint .", diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 8aca2669c..207edbf12 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -5,41 +5,42 @@ FunC { // Compiler pragmas and includes // - Pragma = pragma ("allow-post-modification" | "compute-asm-ltr") ";" --literal - | pragma ("version" | "not-version") versionRange ";" --versionRange - | pragma "test-version-set" stringLiteral ";" --versionString + Pragma = "#pragma" ("allow-post-modification" | "compute-asm-ltr") ";" --literal + | "#pragma" ("version" | "not-version") versionRange ";" --versionRange + | "#pragma" "test-version-set" stringLiteral ";" --versionString - Include = include stringLiteral ";" + Include = "#include" stringLiteral ";" // // Top-level, module items // - ModuleItem = GlobalVariables - | Constants + ModuleItem = GlobalVariablesDeclaration + | ConstantsDefinition | AsmFunctionDefinition | FunctionDeclaration | FunctionDefinition - GlobalVariables = "global" NonemptyListOf ";" - GlobalVariableDeclaration = TypeMapped? id + GlobalVariablesDeclaration = "global" NonemptyListOf ";" + GlobalVariableDeclaration = Type? id - Constants = "const" NonemptyListOf ";" + ConstantsDefinition = "const" NonemptyListOf ";" ConstantDefinition = TypeConstant? id "=" Expression - AsmFunctionDefinition = FunctionCommon "asm" ("(" AsmArrangement ")")? stringLiteral+ ";" --singleLine - | FunctionCommon "asm" ("(" AsmArrangement ")")? multiLineString ";" --multiLine + AsmFunctionDefinition = FunctionCommonPrefix "asm" AsmArrangement? stringLiteral+ ";" --singleLine + | FunctionCommonPrefix "asm" AsmArrangement? multiLineString+ ";" --multiLine - AsmArrangement = "->" integerLiteralDec+ --returns - | id+ ~"->" --arguments - | id+ "->" integerLiteralDec+ --argumentsToReturns + AsmArrangement = "(" "->" integerLiteralDec+ ")" --returns + | "(" id+ ~"->" ")" --arguments + | "(" id+ "->" integerLiteralDec+ ")" --argumentsToReturns - FunctionDeclaration = FunctionCommon ";" - FunctionDefinition = FunctionCommon "{" Statement* "}" + FunctionDeclaration = FunctionCommonPrefix ";" - // Common parts of function declarations and definitions - FunctionCommon = Forall? TypeMapped functionId Parameters FunctionAttribute* + FunctionDefinition = FunctionCommonPrefix "{" Statement* "}" + + // Common prefix of function declarations and definitions + FunctionCommonPrefix = Forall? Type functionId Parameters FunctionAttribute* // Called "specifiers" in https://docs.ton.org/develop/func/functions#specifiers FunctionAttribute = "impure" | "inline_ref" | "inline" | MethodIdValue | "method_id" @@ -80,7 +81,8 @@ FunC { // NOTE: they should parse exactly as FunC 0.4.4 does it, including the issues with precedences of ^ | and similar // parse_expr - Expression = ExpressionAssign + Expression = integerLiteral | stringLiteral | id // FIXME temporary, for tests prior to expressions + // Expression = ExpressionAssign // parse_expr10 ExpressionAssign = ExpressionConditional "=" ExpressionAssign --assign @@ -165,8 +167,7 @@ FunC { | integerLiteral | stringLiteral | hole - | var - | primitiveType // TODO: re-make this one. + // | primitiveType // TODO: re-make this one. | id // includes true|false, null|Null // TODO: parens // TODO: unit @@ -180,96 +181,63 @@ FunC { // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // + // forall type1, ..., typeN -> + Forall = "forall" NonemptyListOf "->" + TypeVar = "type"? id + // Parameters TODO: check the type Parameters = "(" ListOf ")" - Parameter = TypeMapped id + Parameter = Type id --regular + | id id --typeVar // Arguments - // TODO: - - // forall type1, ..., typeN -> - Forall = forall NonemptyListOf "->" - ForallType = "type"? id + Arguments = "(" ListOf ")" + Argument = id + + // Mapped or unmapped builtin types, where "mapped" refers to: + // https://docs.ton.org/develop/func/types#functional-type + Type = TypeBuiltin "->" Type --mapped + | TypeBuiltin + + // Builtin types + TypeBuiltin = "int" + | "cell" + | "slice" + | "builder" + | "cont" + | "tuple" + | hole + | unit + | Tensor + | Tuple + + // Non-functional composite builtin types + Tensor = "(" NonemptyListOf ")" + Tuple = "[" NonemptyListOf "]" // Allowed types of constants TypeConstant = "int" | "slice" - // TE ::= TA | TA -> TE - TypeMapped = Type "->" TypeMapped --mapped - | Type - - // TA ::= int | ... | cont | var | _ | () | ( TE { , TE } ) | [ TE { , TE } ] - Type = "int" - | "cell" - | "slice" - | "builder" - | "cont" - | "tuple" - | hole - | unit - | Tensor - | Tuple - - Tensor = "(" NonemptyListOf ")" - Tuple = "[" NonemptyListOf "]" - // // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // - // TODO: Move over the remaining keywords - // TODO: Test if they can be names of variables, constants, functions -- yup, they cannot!!! - // Also, operators cannot too! And some other things!!! - // TODO: actually put everything from https://github.com/ton-blockchain/ton/blob/master/crypto/func/keywords.cpp - // Reserved keywords, order matters (TODO: does it?) - keyword = pragma - | include - | forall - | var - | primitiveType - - pragma = "#pragma" ~id - include = "#include" ~id - forall = "forall" ~id - var = "var" ~id - // Special types hole = "_" | "var" unit = "()" - // Primitive types, FIXME: delete or something - primitiveType = "int" | "cell" | "slice" | "builder" | "cont" | "type" | "tuple" - // Function identifiers functionId = ~("\"" | "{-") ("." | "~")? id - // Identifiers + // Identifiers, with validation during semantic analysis + // This makes this parser closer to the C++ one, and also improves error messages + id = ~("\"" | "{-") (quotedId | plainId) quotedId = "`" (~("`" | "\n") any)+ "`" + plainId = (~(whiteSpace | "(" | ")" | "[ | ]" | "," | "." | ";" | "~") any)+ - plainId = ~(reservedId ~idPart) idPart - // plainId = ~reservedId idPart - - idPart = (~(whiteSpace | "(" | ")" | "," | "." | ";" | "~") any)+ - // TODO: make tests for each of those individually ^^^ - - // Order matters - reservedId = "_" - | integerLiteral | "-=" | "->" |"-" - | "#include" | "#pragma" - | "!=" | "==" | "=" - | "<<=" | "<<" | "<=>" | "<=" | "<" | ">>=" | ">>" | ">=" | ">" - | "~>>=" | "~>>" | "~/=" | "~/" | "~%=" | "~%" | "~" - | "^>>=" | "^>>" | "^/=" | "^/" | "^%=" | "^%" | "^=" | "^" - | "+=" | "+" | "*=" | "*" | "/=" | "/%" | "/" | "%=" | "%" | "&=" | "&" | "|=" | "|" - | "(" | ")" | "[" | "]" | "{" | "}" | "?" | ":" | "," | ";" | "." | "~" - | "asm" | "auto_apply" | "builder" | "catch" | "cell" | "const" | "cont" | "do" - | "elseifnot" | "elseif" | "else" | "extern" | "forall" | "global" | "ifnot" | "if" - | "impure" | "infixl" | "infixr" | "infix" | "inline_ref" | "inline" | "int" - | "method_id" | "operator" | "repeat" | "return" | "slice" | "then" | "try" | "tuple" - | "type" | "until" | "var" | "while" - + // Unused identifiers unusedId = "_" /* diff --git a/src/func/grammar.spec.ts b/src/func/grammar.spec.ts index cb370c9a4..414513e2b 100644 --- a/src/func/grammar.spec.ts +++ b/src/func/grammar.spec.ts @@ -1,19 +1,18 @@ -import { match } from "./grammar"; +import { match, parseFile } from "./grammar"; import { loadCases } from "../utils/loadCases"; describe("FunC grammar and parser", () => { beforeEach(() => {}); + const ext = "fc"; + let matchedAll = true; - const target = "asm-functions"; - // const target = "identifiers"; - - // Checking that FunC files match the grammar - for (const r of loadCases(__dirname + "/grammar-test/", "fc")) { - if (r.name !== target) continue; + // Checking that valid FunC files match the grammar + for (const r of loadCases(__dirname + "/grammar-test/", ext)) { it(r.name + " should match the grammar", () => { const res = match(r.code); if (res.ok === false) { + matchedAll = false; console.log(res.message, res.interval.getLineAndColumn()); } @@ -21,12 +20,22 @@ describe("FunC grammar and parser", () => { }); } - // Checking that certain FunC files DON'T match the grammar - for (const r of loadCases(__dirname + "/grammar-test-failed/", "fc")) { - it(r.name + " should not match the grammar", () => { - expect(match(r.code).ok).toStrictEqual(false); - }); - } + // If didn't match the grammar, don't throw any more errors from full parse + if (!matchedAll) { return; } + + // Checking that valid FunC files parse + // for (const r of loadCases(__dirname + "/grammar-test/", ext)) { + // it("should parse " + r.name, () => { + // expect(parseFile(r.code, r.name + `.${ext}`)).toMatchSnapshot(); + // }); + // } - // TODO: Tests with snapshots, once semantics and `parse` function are defined + // Checking that invalid FunC files does NOT parse + // for (const r of loadCases(__dirname + "/grammar-test-failed/", ext)) { + // it("should NOT parse " + r.name, () => { + // expect(() => + // parseFile(r.code, r.name + `.${ext}`) + // ).toThrowErrorMatchingSnapshot(); + // }); + // } }); diff --git a/src/func/grammar.ts b/src/func/grammar.ts index d9a4d1132..ff67aa7e8 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -1,12 +1,468 @@ -import { Interval } from "ohm-js"; +import { Interval as RawInterval, IterationNode, MatchResult, Node } from "ohm-js"; +import path from "path"; +import { cwd } from "process"; import FuncGrammar from "./grammar.ohm-bundle"; -type Match = { ok: false; message: string; interval: Interval } | { ok: true }; +// +// Utility declarations and definitions +// + +/** Currently processed file */ +let currentFile: string | undefined; + +/** + * Information about source code location (file and interval within it) + * and the source code contents. + */ +export class FuncSrcInfo { + readonly #interval: RawInterval; + readonly #file: string | undefined; + + constructor(interval: RawInterval, file: string | undefined) { + this.#interval = interval; + this.#file = file; + } + + get file() { + return this.#file; + } + + get contents() { + return this.#interval.contents; + } + + get interval() { + return this.#interval; + } +} + +/** + * Generic FunC error in FunC parser + */ +export class FuncError extends Error { + readonly loc: FuncSrcInfo; + + constructor(message: string, loc: FuncSrcInfo) { + super(message); + this.loc = loc; + } +} + +/** + * FunC parser error, which generally occurs when either the sources didn't match the grammar, or the AST couldn't be constructed + */ +export class FuncParseError extends FuncError { + constructor(message: string, loc: FuncSrcInfo) { + super(message, loc); + } +} + +/** + * Constructs a location string based on the `sourceInfo` + */ +function locationStr(sourceInfo: FuncSrcInfo): string { + if (sourceInfo.file === undefined) { + return ""; + } + + const loc = sourceInfo.interval.getLineAndColumn() as { + lineNum: number; + colNum: number; + }; + const file = path.relative(cwd(), sourceInfo.file); + return `${file}:${loc.lineNum}:${loc.colNum}: `; +} + +/** + * Throws a FunC parse error of the given `path` file + */ +export function throwFuncParseError( + matchResult: MatchResult, + path: string | undefined, +): never { + const interval = matchResult.getInterval(); + const source = new FuncSrcInfo(interval, path); + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const message = `Parse error: expected ${(matchResult as any).getExpectedText()}\n`; + throw new FuncParseError( + `${locationStr(source)}${message}\n${interval.getLineAndColumnMessage()}`, + source, + ); +} + +/** + * Temporarily sets `currentFile` to `path`, calls a callback function, then resets `currentValue` + * Returns a value produced by a callback function call + */ +export function inFile(path: string, callback: () => T) { + currentFile = path; + const r = callback(); + currentFile = undefined; + return r; +} + +/** + * Creates a `FuncSrcInfo` reference to a Node and `currentFile` + */ +export function createRef(s: Node) { + return new FuncSrcInfo(s.source, currentFile); +} + +/** + * Unwraps optional grammar elements (marked with "?"), + * since ohm-js represents those as lists (IterationNodes) + */ +function unwrapOptNode( + optional: IterationNode, + f: (n: Node) => T, +): T | null { + const optNode = optional.children[0] as Node | undefined; + return optNode !== undefined ? f(optNode) : null; +} + +// +// FIXME: Those are directly matching contents of the grammar.ohm +// TODO: Unite with syntax.ts and refactor dependant files +// FIXME: Would need help once parser is done on my side :) +// + +type FuncAstNode = + | FuncAstModule + | FuncAstPragma + | FuncAstInclude + | FuncAstModuleItem + | FuncAstComment + ; + +type FuncAstModule = { + kind: "module"; + pragmas: FuncAstPragma; + includes: FuncAstInclude; + items: FuncAstModuleItem; +}; + +// +// Compiler pragmas and includes +// + +/** + * #pragma ... + */ +type FuncAstPragma = + | FuncAstPragmaLiteral + | FuncAstPragmaVersionRange + | FuncAstPragmaVersionString + ; + +/** + * #pragma something-something-something; + */ +type FuncAstPragmaLiteral = { + kind: "pragma_literal"; + literal: "allow-post-modification" | "compute-asm-ltr"; +}; + +/** + * `allow` — if set to `true` corresponds to version enforcement + * `allow` — if set to `false` corresponds to version prohibiting (or not-version enforcement) + * + * #pragma (version | not-version) semverRange; + */ +type FuncAstPragmaVersionRange = { + kind: "pragma_version_range"; + allow: boolean; + range: FuncAstVersionRange; +}; + +/** + * #pragma test-version-set "exact.version.semver"; + */ +type FuncAstPragmaVersionString = { + kind: "pragma_version_string"; + version: string; +}; + +/** + * #include "path/to/file"; + */ +type FuncAstInclude = { + kind: "include"; + path: string; +}; + +// +// Top-level, module items +// + +type FuncAstModuleItem = + | {} + ; + +type FuncAstGlobalVariablesDeclaration = { + kind: "global_variables_declaration", + globals: FuncAstGlobalVariable, +}; + +type FuncAstGlobalVariable = { + kind: "global_variable", + type: FuncAstType | undefined; + name: FuncAstId; +}; + +// +// Statements +// TODO +// + +// +// Expressions +// TODO +// + +// +// Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical +// + +// TODO: +type FuncAstType = + | {}; + +// +// Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical +// + +type FuncAstHole = { + kind: "hole"; + value: "_" | "var"; +}; + +type FuncAstUnit = { + kind: "unit"; + value: "()"; +}; + +type FuncAstFunctionId = { + kind: "function_id"; + value: string; +}; + +type FuncAstId = + | FuncAstIdQuoted + | FuncAstIdPlain + ; + +type FuncAstIdQuoted = { + kind: "id_quoted"; + value: string; +}; + +type FuncAstIdPlain = { + kind: "id_plain"; + value: string; +}; + +type FuncAstUnusedId = { + kind: "unused_id"; + value: "_"; +}; + +type FuncAstVersionRange = { + kind: "version_range"; + op: string | undefined; + major: bigint; + minor: bigint | undefined; + patch: bigint | undefined; +}; + +/** + * "..."ty? + */ +type FuncAstStringLiteral = { + kind: "string_literal"; + value: string; + ty: undefined | FuncAstStringType; +}; + +/** + * An additional modifier. See: https://docs.ton.org/develop/func/literals_identifiers#string-literals + */ +type FuncAstStringType = "s" | "a" | "u" | "h" | "H" | "c"; + +/** + * """ ... """ + */ +type FuncAstMultiLineString = { + kind: "multiline_string"; + value: string; + // TODO: alignIndent: boolean; + // TODO: trim: boolean; +}; + +type FuncAstWhiteSpace = { + kind: "whitespace"; + value: `\t` | ` ` | `\n` | `\r` | `\u2028` | `\u2029`; +}; + +/** + * ;; ... + * or + * {- ... -} + */ +type FuncAstComment = + | FuncAstCommentSingleLine + | FuncAstCommentMultiLine + ; + +/** + * Doesn't include the starting ;; characters + * + * ;; ... + */ +type FuncAstCommentSingleLine = { + kind: "comment_singleline"; + line: string; +}; + +/** + * `skipCR` — if set to true, skips CR before the next line + * + * {- ... -} + */ +type FuncAstCommentMultiLine = { + kind: "comment_multiline"; + contents: string; + skipCR: boolean; +}; + +// +// Semantic analysis +// + +// TODO: ids for nodes via a function wrapper like in Tact? +const semantics = FuncGrammar.createSemantics(); + +semantics.addOperation("astOfModule", { + Module(pragmas, includes, items) { + return { + kind: "module", + pragmas: pragmas.children.map(x => x.astOfPragma()), + includes: includes.children.map(x => x.astOfInclude()), + items: items.children.map(x => x.astOfModuleItem()), + }; + }, + comment(cmt) { + return cmt.astOfModule(); + }, + comment_singleLine(_commentStart, lineContents) { + return { + kind: "comment_singleline", + line: lineContents.sourceString, + }; + }, + comment_multiLine(cmt) { + return cmt.astOfModule(); + }, + multiLineComment(_commentStart, preInnerComment, innerComment, postInnerComment, _commentEnd) { + return { + kind: "comment_multiline", + contents: [ + preInnerComment.sourceString, + (innerComment.children.map(x => x.astOfModule()).join("") ?? ""), + postInnerComment.sourceString, + ].join(""), + skipCR: false, + }; + }, +}); + +semantics.addOperation("astOfPragma", { + Pragma(pragma) { + return pragma.astOfPragma(); + }, + Pragma_literal(_pragmaKwd, literal, _semicolon) { + return { + kind: "pragma_literal", + literal: literal.sourceString, + }; + }, + Pragma_versionRange(_pragmaKwd, literal, range, _semicolon) { + return { + kind: "pragma_version_range", + allow: literal.sourceString === "version" ? true : false, + range: range.astOfVersionRange(), + }; + }, + Pragma_versionString(_pragmaKwd, _literal, value, _semicolon) { + return { + kind: "pragma_version_string", + version: value.astOfExpression(), + }; + }, +}); + +semantics.addOperation("astOfInclude", { + Include(_includeKwd, path, _semicolon) { + return { + kind: "include", + path: path.astOfExpression(), + }; + }, +}); + +semantics.addOperation("astOfModuleItem", { + ModuleItem(item) { + return item.astOfModuleItem(); + }, + GlobalVariablesDeclaration(_globalKwd, globals, _semicolon) { + return { + kind: "global_variables_declaration", + globals: globals.children.map(x => x.astOfGlobalVariable()), + }; + }, + ConstantsDefinition(_constKwd, constants, _semicolon) { + return { + kind: "constants_definition", + constants: constants.children.map(x => x.astOfConstant()), + }; + }, + AsmFunctionDefinition_singleLine(fnCommonPrefix, _asmKwd, optArrangement, asmStrings, _semicolon) { + return { + kind: "asm_function_definition", + // TODO: fnCommonPrefix, optArrangement + }; + }, + // AsmFunctionDefinition_multiLine(fnCommon, _asmKwd, optArrangement, multilineAsmStrings, _semicolon) { + // // TODO: + // }, + // FunctionDeclaration(arg0, arg1) { + // // TODO: ... + // }, + // FunctionDefinition(arg0, arg1, arg2, arg3) { + // // TODO: ... + // }, +}); + +semantics.addOperation("astOfGlobalVariable", { }); + +semantics.addOperation("astOfConstant", { }); + +semantics.addOperation("astOfFunctionCommonPrefix", { }); + +// +// Utility parsing functions +// + +/** If the match wasn't successful, provides error message and interval */ +type GrammarMatch = + | { ok: false; message: string; interval: RawInterval } + | { ok: true }; /** * Checks if the given `src` string of FunC code matches the FunC grammar + * Doesn't throw an error, unlike `parse()` functions */ -export function match(src: string): Match { +export function match(src: string): GrammarMatch { const matchResult = FuncGrammar.match(src); if (matchResult.failed()) { @@ -20,4 +476,27 @@ export function match(src: string): Match { return { ok: true }; } -// TODO: semantics and parsing, with errors +/** + * Checks if the given `src` string of FunC code is parsable, returning an AST in case of success or throwing a `FuncParseError` otherwise + * + * Uses semantic analysis, unlike simple `match()` + */ +export function parse(src: string) { + const matchResult = FuncGrammar.match(src); + + if (matchResult.failed()) { throwFuncParseError(matchResult, undefined); } + try { return semantics(matchResult).astOfModule(); } finally {} +} + +/** + * Similar to `parse()`, but also uses provided `path` in error messages + * Unlike `parse()`, wraps its body in a call to `inFile()` with the `path` provided + */ +export function parseFile(src: string, path: string) { + return inFile(path, () => { + const matchResult = FuncGrammar.match(src); + + if (matchResult.failed()) { throwFuncParseError(matchResult, path); } + try { return semantics(matchResult).astOfModule(); } finally {} + }); +} diff --git a/src/func/syntax.ts b/src/func/syntax.ts index b755265ff..d8cf79527 100644 --- a/src/func/syntax.ts +++ b/src/func/syntax.ts @@ -30,6 +30,7 @@ export type FuncType = | { kind: "hole" } // hole type (`_`) filled in local type inference | { kind: "type" }; +// FIXME: there's no unary plus, and unary minus is handled separately from ~ export type FuncAstUnaryOp = "-" | "~" | "+"; export type FuncAstBinaryOp = From 21e52537d816be6d8b9fd380defa29fdf890f432 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:24:52 +0200 Subject: [PATCH 090/162] test(func-parser): covered everything but expressions in tests Not all pass due to the complicated things with polymorphic types and identifiers. To be resolved tomorrow, with semantic actions and expressions. --- src/func/__snapshots__/grammar.spec.ts.snap | 138 ++++++++++++++++++ src/func/grammar-test/asm-functions.fc | 7 +- src/func/grammar-test/expressions.fc | 1 + src/func/grammar-test/functions.fc | 20 +++ .../grammar-test/literals-and-comments.fc | 61 ++++++++ src/func/grammar-test/statements.fc | 84 +++++++++++ src/func/grammar.ohm | 47 +++--- 7 files changed, 335 insertions(+), 23 deletions(-) create mode 100644 src/func/__snapshots__/grammar.spec.ts.snap create mode 100644 src/func/grammar-test/expressions.fc create mode 100644 src/func/grammar-test/functions.fc create mode 100644 src/func/grammar-test/literals-and-comments.fc create mode 100644 src/func/grammar-test/statements.fc diff --git a/src/func/__snapshots__/grammar.spec.ts.snap b/src/func/__snapshots__/grammar.spec.ts.snap new file mode 100644 index 000000000..dc5705ea1 --- /dev/null +++ b/src/func/__snapshots__/grammar.spec.ts.snap @@ -0,0 +1,138 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FunC grammar and parser should NOT parse id-arith-operator 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-assign-operator 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-bitwise-operator 1`] = ` +"id-bitwise-operator.fc:1:5: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~") or "\`" + +Line 1, col 5: +> 1 | () ~(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-comma 1`] = ` +"id-comma.fc:1:16: Parse error: expected "(" + +Line 1, col 16: +> 1 | () send_message,then_terminate(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-comparison-operator 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-control-keyword 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-delimiter 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-directive 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-dot 1`] = ` +"id-dot.fc:1:7: Parse error: expected "(" + +Line 1, col 7: +> 1 | () msg.sender(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-keyword 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-multiline-comments 1`] = ` +"id-multiline-comments.fc:1:11: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~"), "\`", or "->" + +Line 1, col 11: +> 1 | () {-aaa-}(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-number 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-number-decimal 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-number-hexadecimal 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-number-hexadecimal-2 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-number-neg-decimal 1`] = ` +"id-number-neg-decimal.fc:2:1: Parse error: expected end of input, "[", "(", "()", "var", "_", "tuple", "cont", "builder", "slice", "cell", "int", "const", or "global" + +Line 2, col 1: + 1 | () -1(); +> 2 | native idTest(); + ^ + 3 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-number-neg-hexadecimal 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-only-underscore 1`] = `"semantics(...).astOfModule is not a function"`; + +exports[`FunC grammar and parser should NOT parse id-parens 1`] = ` +"id-parens.fc:1:14: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~") or "\`" + +Line 1, col 14: +> 1 | () take(first)Entry(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-semicolons 1`] = ` +"id-semicolons.fc:2:1: Parse error: expected "(" + +Line 2, col 1: + 1 | () pa;;in"\`aaa\`"(); +> 2 | + ^ +" +`; + +exports[`FunC grammar and parser should NOT parse id-space 1`] = ` +"id-space.fc:1:8: Parse error: expected "(" + +Line 1, col 8: +> 1 | () foo foo(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-string 1`] = ` +"id-string.fc:1:4: Parse error: expected not ("\\"" or "{-") or "->" + +Line 1, col 4: +> 1 | () "not_a_string(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-type-keyword 1`] = ` +"id-type-keyword.fc:1:8: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~") or "\`" + +Line 1, col 8: +> 1 | () ->(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-unclosed-parens 1`] = ` +"id-unclosed-parens.fc:1:9: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~") or "\`" + +Line 1, col 9: +> 1 | () aa(bb(); + ^ + 2 | +" +`; diff --git a/src/func/grammar-test/asm-functions.fc b/src/func/grammar-test/asm-functions.fc index a7b624b16..ba6eb13bd 100644 --- a/src/func/grammar-test/asm-functions.fc +++ b/src/func/grammar-test/asm-functions.fc @@ -23,9 +23,12 @@ asm (x b len) "STUXQ"; ;; Arrangement of arguments -(int, builder) store_uint_quite(int x, builder b, int len) +(int, builder) store_uint_quiet'(int x, builder b, int len) asm( -> 1 0) "STUXQ"; ;; Arrangement of arguments mapped to return values -(int, builder) store_uint_quite(builder b, int x, int len) +(int, builder) store_uint_quiet''(builder b, int x, int len) asm(x b len -> 1 0) "STUXQ"; + +;; Parametric polymorphism with forall +forall X, Y -> (X, Y) store_uint_quiet'''(builder b, int x, int len) asm(x b len -> 1 0) "STUXQ"; diff --git a/src/func/grammar-test/expressions.fc b/src/func/grammar-test/expressions.fc new file mode 100644 index 000000000..aa1737692 --- /dev/null +++ b/src/func/grammar-test/expressions.fc @@ -0,0 +1 @@ +;; TODO: ... diff --git a/src/func/grammar-test/functions.fc b/src/func/grammar-test/functions.fc new file mode 100644 index 000000000..d38bf4911 --- /dev/null +++ b/src/func/grammar-test/functions.fc @@ -0,0 +1,20 @@ +;; Void +() void(); + +;; Regular parameters +() params(int p1, cell p2, () p3, (slice) p4, [builder] p5); + +;; Parametric polymorphism with forall +forall X -> () poly(X p1); +forall X, Y -> (Y, X) poly'(); + +;; Attributes (called specifiers in TON Docs) +() attr() impure inline_ref inline method_id(0x2A); +() attr'() method_id(42); +() attr''() method_id; + +;; Empty body (note, that {} is an identifier, so there must be whitespace in-between) +() body() { } + +;; Everything +forall XXX -> XXX everything(XXX x) impure inline_ref inline method_id(0x2A) method_id { } diff --git a/src/func/grammar-test/literals-and-comments.fc b/src/func/grammar-test/literals-and-comments.fc new file mode 100644 index 000000000..de116c921 --- /dev/null +++ b/src/func/grammar-test/literals-and-comments.fc @@ -0,0 +1,61 @@ +;; Integer literals +() integers() { + 42; + 0x2A; + 0x2a; + + -42; + -0x2A; + -0x2a; +} + +;; String literals +() strings() { + "slice"; + "2A"s; + "EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT"a; + "int hex"u; + "int 32 bits of sha256"h; + "int 256 bits of sha256"H; + "int crc32"c; + + """ + multi + line + """; + + """2A"""s; + """EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT"""a; + """ + ... + """u; + """ + ... + """h; + """ + ... + """H; + """ + ... + """c; +} + +;; Single-line comment +{- + Multi-line comment + {- + Nested! "Not a string, part of the comment!" + ;; Also a part of the nested multi-line comment, not a single-line one + -} +-} + +;; Comment madness +forall ;; ... +X, Y ;; ... +-> ;; ... +() {- + ... +-} ;; ... +comments! ;; ... +() ;; ... +{ {- ... -} return (); {- ... -} } diff --git a/src/func/grammar-test/statements.fc b/src/func/grammar-test/statements.fc new file mode 100644 index 000000000..fcae9b902 --- /dev/null +++ b/src/func/grammar-test/statements.fc @@ -0,0 +1,84 @@ +;; return +() return_stmt() { return (); } +int return_stmt'() { return 42; } + +;; Block +() block_stmt() { + { + { return (); } + } +} + +;; Empty +() empty_stmt() { ; + ; ; ; ; +} + +;; Condition +() cond_stmt() { + if 1 { } + ifnot 0 { } + + if 1 { ; ; } + ifnot 0 { ; ; } + + if 0 { ; ; } else { ; ; } + ifnot 1 { ; ; } else { ; ; } + + if 0 { } elseif 1 { } + if 0 { } elseifnot 0 { } + ifnot 1 { } elseif 1 { } + ifnot 1 { } elseifnot 0 { } + + if 0 { ; ; } elseif 1 { ; ; } + if 0 { ; ; } elseifnot 0 { ; ; } + ifnot 1 { ; ; } elseif 1 { ; ; } + ifnot 1 { ; ; } elseifnot 0 { ; ; } +} + +;; repeat +() repeat_stmt() { + repeat 1 { } + + repeat 1 { + ; ; ; + } +} + +;; do...until +() until_stmt() { + do { } until 0; + + do { + ; ; ; + { repeat 1 { } } + } until 0; +} + +;; while +() while_stmt() { + while 0 { } + + while 0 { + ; ; ; + { repeat 1 { } } + } +} + +;; try...catch +() try_catch_stmt() { + try { + ; ; ; + { } + } catch (_, _) { + ; ; ; + { } + } + + try { } catch (exception, exit_code) { } +} + +;; Expression (most of the related tests are in another file) +() expression_stmt() { + 42; +} diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 207edbf12..092d1fbd0 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -81,8 +81,8 @@ FunC { // NOTE: they should parse exactly as FunC 0.4.4 does it, including the issues with precedences of ^ | and similar // parse_expr - Expression = integerLiteral | stringLiteral | id // FIXME temporary, for tests prior to expressions - // Expression = ExpressionAssign + // Expression = integerLiteral | stringLiteral | id // FIXME temporary, for tests prior to expressions + Expression = ExpressionAssign // parse_expr10 ExpressionAssign = ExpressionConditional "=" ExpressionAssign --assign @@ -153,25 +153,29 @@ FunC { ExpressionMethodCall = ExpressionSequence ("." | "~") id ExpressionPrimary --call | ExpressionSequence + // FIXME: Temporary definition for debugging purposes. + ExpressionSequence = integerLiteral | multiLineString | stringLiteral | id + ExpressionPrimary = integerLiteral | multiLineString | stringLiteral | id + // parse_expr90, FIXME: this is wrong and has to be re-made :) // TODO: function call // TODO: variable declaration - ExpressionSequence = ExpressionPrimary &"(" ExpressionPrimary --call - | ExpressionPrimary &"[" ExpressionPrimary --access - | ExpressionPrimary ~("." | "~") id ExpressionPrimary --id - | ExpressionPrimary + // ExpressionSequence = ExpressionPrimary &"(" ExpressionPrimary --call + // | ExpressionPrimary &"[" ExpressionPrimary --access + // | ExpressionPrimary ~("." | "~") id ExpressionPrimary --id + // | ExpressionPrimary // parse_expr100, order is important - ExpressionPrimary = ExpressionTuple - | ExpressionTensor - | integerLiteral - | stringLiteral - | hole - // | primitiveType // TODO: re-make this one. - | id // includes true|false, null|Null - // TODO: parens - // TODO: unit - // TODO: slice_string_ident? + // ExpressionPrimary = ExpressionTuple + // | ExpressionTensor + // | integerLiteral + // | stringLiteral + // | hole + // | primitiveType // TODO: re-make this one. + // | id // includes true|false, null|Null + // TODO: parens! + // TODO: unit? + // TODO: slice_string_ident? // TODO: ... ExpressionTuple = "(" "TODO:" ")" @@ -185,12 +189,12 @@ FunC { Forall = "forall" NonemptyListOf "->" TypeVar = "type"? id - // Parameters TODO: check the type + // Parameters, with type holes prohibited during syntax analysis Parameters = "(" ListOf ")" Parameter = Type id --regular | id id --typeVar - // Arguments + // Arguments -- unused? Arguments = "(" ListOf ")" Argument = id @@ -210,6 +214,8 @@ FunC { | unit | Tensor | Tuple + // | id + // TODO: Use different type signatures in forall functions? // Non-functional composite builtin types Tensor = "(" NonemptyListOf ")" @@ -229,8 +235,8 @@ FunC { // Function identifiers functionId = ~("\"" | "{-") ("." | "~")? id - // Identifiers, with validation during semantic analysis - // This makes this parser closer to the C++ one, and also improves error messages + // Identifiers, with invalidation (keywords, numbers, etc.) during syntax analysis + // — this makes this parser closer to the C++ one, and also improves error messages id = ~("\"" | "{-") (quotedId | plainId) @@ -275,7 +281,6 @@ FunC { whiteSpace = "\t" | " " | lineTerminator // Comments - // For semantic actions comment_singleLine and comment_multiLine comment = ";;" (~lineTerminator any)* --singleLine | multiLineComment --multiLine From c6b4916fa8b39c2f1252a29755230a039e1b8e79 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:35:27 +0200 Subject: [PATCH 091/162] fix: statements, expressions and types in different contexts --- src/func/grammar.ohm | 75 +++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 092d1fbd0..0b35adf84 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -22,19 +22,18 @@ FunC { | FunctionDefinition GlobalVariablesDeclaration = "global" NonemptyListOf ";" - GlobalVariableDeclaration = Type? id + GlobalVariableDeclaration = TypeStatic? id ConstantsDefinition = "const" NonemptyListOf ";" ConstantDefinition = TypeConstant? id "=" Expression AsmFunctionDefinition = FunctionCommonPrefix "asm" AsmArrangement? stringLiteral+ ";" --singleLine - | FunctionCommonPrefix "asm" AsmArrangement? multiLineString+ ";" --multiLine + | FunctionCommonPrefix "asm" AsmArrangement? multiLineStringLiteral+ ";" --multiLine AsmArrangement = "(" "->" integerLiteralDec+ ")" --returns | "(" id+ ~"->" ")" --arguments | "(" id+ "->" integerLiteralDec+ ")" --argumentsToReturns - FunctionDeclaration = FunctionCommonPrefix ";" FunctionDefinition = FunctionCommonPrefix "{" Statement* "}" @@ -63,9 +62,9 @@ FunC { StatementReturn = "return" Expression ";" StatementBlock = "{" Statement* "}" StatementEmpty = ";" - StatementCondition = ("if" | "ifnot") Expression "{" Statement* "}" --noElse - | ("if" | "ifnot") Expression "{" Statement* "}" "else" "{" Statement* "}" --withElse - | ("if" | "ifnot") Expression "{" Statement* "}" ("elseif" | "elseifnot") "{" Statement* "}" --withElseCondition + StatementCondition = ("ifnot" | "if" ) Expression "{" Statement* "}" ("elseifnot" | "elseif") Expression "{" Statement* "}" --withElseCondition + | ("ifnot" | "if" ) Expression "{" Statement* "}" "else" "{" Statement* "}" --withElse + | ("ifnot" | "if" ) Expression "{" Statement* "}" --noElse StatementRepeat = "repeat" Expression "{" Statement* "}" StatementUntil = "do" "{" Statement* "}" "until" Expression ";" StatementWhile = "while" Expression "{" Statement* "}" @@ -110,12 +109,12 @@ FunC { // parse_expr15 ExpressionCompare = ExpressionBitwiseShift "==" ExpressionBitwiseShift --eq - | ExpressionBitwiseShift "<" ExpressionBitwiseShift --lt - | ExpressionBitwiseShift ">" ExpressionBitwiseShift --gt + | ExpressionBitwiseShift "<=>" ExpressionBitwiseShift --spaceship | ExpressionBitwiseShift "<=" ExpressionBitwiseShift --lte + | ExpressionBitwiseShift "<" ExpressionBitwiseShift --lt | ExpressionBitwiseShift ">=" ExpressionBitwiseShift --gte + | ExpressionBitwiseShift ">" ExpressionBitwiseShift --gt | ExpressionBitwiseShift "!=" ExpressionBitwiseShift --neq - | ExpressionBitwiseShift "<=>" ExpressionBitwiseShift --spaceship | ExpressionBitwiseShift // parse_expr17 @@ -154,8 +153,7 @@ FunC { | ExpressionSequence // FIXME: Temporary definition for debugging purposes. - ExpressionSequence = integerLiteral | multiLineString | stringLiteral | id - ExpressionPrimary = integerLiteral | multiLineString | stringLiteral | id + ExpressionSequence = ExpressionPrimary // parse_expr90, FIXME: this is wrong and has to be re-made :) // TODO: function call @@ -166,20 +164,15 @@ FunC { // | ExpressionPrimary // parse_expr100, order is important - // ExpressionPrimary = ExpressionTuple - // | ExpressionTensor - // | integerLiteral - // | stringLiteral - // | hole - // | primitiveType // TODO: re-make this one. - // | id // includes true|false, null|Null - // TODO: parens! - // TODO: unit? - // TODO: slice_string_ident? - - // TODO: ... - ExpressionTuple = "(" "TODO:" ")" - ExpressionTensor = "[" "TODO:" "]" + ExpressionPrimary = + // TODO: parens? + | integerLiteral + | multiLineStringLiteral + | stringLiteral + | TypeStatic + | id + + // ExpressionParens = "(" Expression ")" // // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical @@ -191,17 +184,22 @@ FunC { // Parameters, with type holes prohibited during syntax analysis Parameters = "(" ListOf ")" - Parameter = Type id --regular - | id id --typeVar + Parameter = Type id - // Arguments -- unused? - Arguments = "(" ListOf ")" - Argument = id + // Arguments -- TODO: unused, remove? + // Arguments = "(" ListOf ")" + // Argument = id - // Mapped or unmapped builtin types, where "mapped" refers to: - // https://docs.ton.org/develop/func/types#functional-type + // Mapped or unmapped builtin types or type variables, + // where "mapped" refers to: https://docs.ton.org/develop/func/types#functional-type + // and type variables refer to parametric polymorphism with `forall` Type = TypeBuiltin "->" Type --mapped - | TypeBuiltin + | TypeBuiltin --builtin + | id --var + + // Non-polymorphic types + TypeStatic = TypeBuiltin "->" Type --mapped + | TypeBuiltin --builtin // Builtin types TypeBuiltin = "int" @@ -210,12 +208,10 @@ FunC { | "builder" | "cont" | "tuple" - | hole - | unit | Tensor | Tuple - // | id - // TODO: Use different type signatures in forall functions? + | hole + | unit // Non-functional composite builtin types Tensor = "(" NonemptyListOf ")" @@ -223,7 +219,7 @@ FunC { // Allowed types of constants TypeConstant = "int" | "slice" - + // // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // @@ -268,13 +264,14 @@ FunC { // Strings stringLiteral = "\"" (~"\"" any)* "\"" stringType? + multiLineStringLiteral = "\"\"\"" (~"\"\"\"" any)* "\"\"\"" stringType? + stringType = "s" --sliceHex | "a" --sliceInternalAddress | "u" --intHex | "h" --int32Sha256 | "H" --int256Sha256 | "c" --intCrc32 - multiLineString = "\"\"\"" (~"\"\"\"" any)* "\"\"\"" // Whitespace space += comment | lineTerminator From 8f781f629038acc3fba2329268f5453515067009 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Thu, 1 Aug 2024 22:58:45 +0200 Subject: [PATCH 092/162] test(func-parser): one more sample of an interesting asm function --- src/func/grammar-test/asm-functions.fc | 3 +++ src/func/grammar.ohm | 20 +++----------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/func/grammar-test/asm-functions.fc b/src/func/grammar-test/asm-functions.fc index ba6eb13bd..1faadf631 100644 --- a/src/func/grammar-test/asm-functions.fc +++ b/src/func/grammar-test/asm-functions.fc @@ -31,4 +31,7 @@ asm (x b len) asm(x b len -> 1 0) "STUXQ"; ;; Parametric polymorphism with forall + forall X, Y -> (X, Y) store_uint_quiet'''(builder b, int x, int len) asm(x b len -> 1 0) "STUXQ"; + +forall X -> X unsingle([X] t) asm "UNSINGLE"; diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 0b35adf84..9aa32fc8a 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -166,11 +166,7 @@ FunC { // parse_expr100, order is important ExpressionPrimary = // TODO: parens? - | integerLiteral - | multiLineStringLiteral - | stringLiteral - | TypeStatic - | id + | integerLiteral | multiLineStringLiteral | stringLiteral | TypeStatic | id // ExpressionParens = "(" Expression ")" @@ -202,16 +198,7 @@ FunC { | TypeBuiltin --builtin // Builtin types - TypeBuiltin = "int" - | "cell" - | "slice" - | "builder" - | "cont" - | "tuple" - | Tensor - | Tuple - | hole - | unit + TypeBuiltin = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" | Tensor | Tuple | hole | unit // Non-functional composite builtin types Tensor = "(" NonemptyListOf ")" @@ -253,8 +240,7 @@ FunC { // Integers integerLiteral = "-"? integerLiteralNonNegative - integerLiteralNonNegative = integerLiteralHex - | integerLiteralDec + integerLiteralNonNegative = integerLiteralHex | integerLiteralDec // hexDigit is defined in Ohm's built-in rules as: hexDigit = "0".."9" | "a".."f" | "A".."F" integerLiteralHex = "0x" hexDigit+ From 3c5564c9de2a7b2c3b0b6e03989256829b1e5fb2 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Fri, 2 Aug 2024 00:44:38 +0200 Subject: [PATCH 093/162] fix(func-parser): multi-line and single-line strings can be placed after each other in asm functions feat(func-parser): divide polymorphic and non-polymorphic, uniform types --- src/func/grammar-test/asm-functions.fc | 6 ++++++ src/func/grammar.ohm | 29 ++++++++++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/func/grammar-test/asm-functions.fc b/src/func/grammar-test/asm-functions.fc index 1faadf631..460d650a4 100644 --- a/src/func/grammar-test/asm-functions.fc +++ b/src/func/grammar-test/asm-functions.fc @@ -16,6 +16,12 @@ slice hello_world() asm """ PUSHSLICE """; +;; Mix single-line and multi-line strings + +int inc_then_negate'''(int x) asn "INC" """ + NEGATE +"""; + ;; Arrangement of return values (and whitespaces check) (builder, int) store_uint_quiet (builder b, int x, int len) diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 9aa32fc8a..7840b3dc0 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -22,13 +22,12 @@ FunC { | FunctionDefinition GlobalVariablesDeclaration = "global" NonemptyListOf ";" - GlobalVariableDeclaration = TypeStatic? id + GlobalVariableDeclaration = TypeUniform? id ConstantsDefinition = "const" NonemptyListOf ";" ConstantDefinition = TypeConstant? id "=" Expression - AsmFunctionDefinition = FunctionCommonPrefix "asm" AsmArrangement? stringLiteral+ ";" --singleLine - | FunctionCommonPrefix "asm" AsmArrangement? multiLineStringLiteral+ ";" --multiLine + AsmFunctionDefinition = FunctionCommonPrefix "asm" AsmArrangement? (multiLineStringLiteral | stringLiteral)+ ";" AsmArrangement = "(" "->" integerLiteralDec+ ")" --returns | "(" id+ ~"->" ")" --arguments @@ -166,7 +165,7 @@ FunC { // parse_expr100, order is important ExpressionPrimary = // TODO: parens? - | integerLiteral | multiLineStringLiteral | stringLiteral | TypeStatic | id + | integerLiteral | multiLineStringLiteral | stringLiteral | TypeUniform | id // ExpressionParens = "(" Expression ")" @@ -174,6 +173,9 @@ FunC { // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // + // Allowed types of constants + TypeConstant = "int" | "slice" + // forall type1, ..., typeN -> Forall = "forall" NonemptyListOf "->" TypeVar = "type"? id @@ -193,19 +195,24 @@ FunC { | TypeBuiltin --builtin | id --var - // Non-polymorphic types - TypeStatic = TypeBuiltin "->" Type --mapped - | TypeBuiltin --builtin - // Builtin types - TypeBuiltin = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" | Tensor | Tuple | hole | unit + TypeBuiltin = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" + | Tensor | Tuple | hole | unit // Non-functional composite builtin types Tensor = "(" NonemptyListOf ")" Tuple = "[" NonemptyListOf "]" - // Allowed types of constants - TypeConstant = "int" | "slice" + // Non-polymorphic, uniform types + TypeUniform = TypeBuiltinUniform "->" TypeUniform --mapped + | TypeBuiltinUniform --builtin + + TypeBuiltinUniform = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" + | TensorUniform | TupleUniform | hole | unit + + TensorUniform = "(" NonemptyListOf ")" + + TupleUniform = "[" NonemptyListOf "]" // // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical From a8fb7996ef0a1c8f090f929d32e9ab88dae79ec4 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Fri, 2 Aug 2024 00:50:28 +0200 Subject: [PATCH 094/162] feat/chore(func-parser): types, loc and formatting --- src/func/grammar.ts | 252 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 202 insertions(+), 50 deletions(-) diff --git a/src/func/grammar.ts b/src/func/grammar.ts index ff67aa7e8..a9c6d0a99 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -1,4 +1,9 @@ -import { Interval as RawInterval, IterationNode, MatchResult, Node } from "ohm-js"; +import { + Interval as RawInterval, + IterationNode, + MatchResult, + Node, +} from "ohm-js"; import path from "path"; import { cwd } from "process"; import FuncGrammar from "./grammar.ohm-bundle"; @@ -103,9 +108,9 @@ export function inFile(path: string, callback: () => T) { } /** - * Creates a `FuncSrcInfo` reference to a Node and `currentFile` + * Creates a `FuncSrcInfo` reference to the Node `s` and `currentFile` */ -export function createRef(s: Node) { +export function createSrcInfo(s: Node) { return new FuncSrcInfo(s.source, currentFile); } @@ -127,19 +132,19 @@ function unwrapOptNode( // FIXME: Would need help once parser is done on my side :) // -type FuncAstNode = +type FuncAstNode = | FuncAstModule | FuncAstPragma | FuncAstInclude | FuncAstModuleItem - | FuncAstComment - ; + | FuncAstComment; type FuncAstModule = { kind: "module"; pragmas: FuncAstPragma; includes: FuncAstInclude; items: FuncAstModuleItem; + loc: FuncSrcInfo; }; // @@ -152,8 +157,7 @@ type FuncAstModule = { type FuncAstPragma = | FuncAstPragmaLiteral | FuncAstPragmaVersionRange - | FuncAstPragmaVersionString - ; + | FuncAstPragmaVersionString; /** * #pragma something-something-something; @@ -161,6 +165,7 @@ type FuncAstPragma = type FuncAstPragmaLiteral = { kind: "pragma_literal"; literal: "allow-post-modification" | "compute-asm-ltr"; + loc: FuncSrcInfo; }; /** @@ -173,6 +178,7 @@ type FuncAstPragmaVersionRange = { kind: "pragma_version_range"; allow: boolean; range: FuncAstVersionRange; + loc: FuncSrcInfo; }; /** @@ -181,6 +187,7 @@ type FuncAstPragmaVersionRange = { type FuncAstPragmaVersionString = { kind: "pragma_version_string"; version: string; + loc: FuncSrcInfo; }; /** @@ -189,25 +196,32 @@ type FuncAstPragmaVersionString = { type FuncAstInclude = { kind: "include"; path: string; + loc: FuncSrcInfo; }; // // Top-level, module items // -type FuncAstModuleItem = - | {} - ; +type FuncAstModuleItem = FuncAstGlobalVariablesDeclaration; +/** + * global ..., ...; + */ type FuncAstGlobalVariablesDeclaration = { - kind: "global_variables_declaration", - globals: FuncAstGlobalVariable, + kind: "global_variables_declaration"; + globals: FuncAstGlobalVariable; + loc: FuncSrcInfo; }; +/** + * nonVarType? id + */ type FuncAstGlobalVariable = { - kind: "global_variable", - type: FuncAstType | undefined; + kind: "global_variable"; + type: FuncAstTypeUniform | undefined; name: FuncAstId; + loc: FuncSrcInfo; }; // @@ -215,6 +229,8 @@ type FuncAstGlobalVariable = { // TODO // +type FuncAstStatement = {}; + // // Expressions // TODO @@ -224,9 +240,106 @@ type FuncAstGlobalVariable = { // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // -// TODO: -type FuncAstType = - | {}; +/** + * Allowed types of constants + */ +type FuncAstTypeConstant = "int" | "slice"; + +/** + * forall type? typeName1, type? typeName2, ... -> + */ +type FuncAstForall = FuncAstTypeVar[]; +// TODO: or { kind: ..., etc. } + +/** + * "type"? id + */ +type FuncAstTypeVar = { + kind: "type_var"; + keyword: boolean; + ident: FuncAstId; + loc: FuncSrcInfo; +}; + +/** + * (type id, ...) + */ +type FuncAstParameters = FuncAstParameter[]; +// TODO: or { kind: ..., etc. } + +/** + * type id + */ +type FuncAstParameter = { + kind: "parameter"; + ty: FuncAstType; + loc: FuncSrcInfo; +}; + +/** + * Mapped or unmapped builtin types or type variables + */ +type FuncAstType = FuncAstTypeMapped | FuncAstTypeBuiltin | FuncAstTypeVar; + +type FuncAstTypeMapped = { + kind: "type_mapped"; + left: FuncAstTypeBuiltin; + right: FuncAstType; +}; + +type FuncAstTypeBuiltin = { + kind: "type_builtin"; + value: + | "int" + | "cell" + | "slice" + | "builder" + | "cont" + | "tuple" + | FuncAstTensor + | FuncAstTuple + | FuncAstHole + | FuncAstUnit; +}; + +/** (...) */ +type FuncAstTensor = FuncAstType[]; + +/** [...] */ +type FuncAstTuple = FuncAstType[]; + +/** + * Non-polymorphic, uniform types + */ + +type FuncAstTypeUniform = FuncAstTypeUniformMapped | FuncAstTypeUniformBuiltin; + +type FuncAstTypeUniformMapped = { + kind: "type_uniform_mapped"; + left: FuncAstTypeBuiltin; + right: FuncAstType; +}; + +type FuncAstTypeUniformBuiltin = { + kind: "type_uniform_builtin"; + value: + | "int" + | "cell" + | "slice" + | "builder" + | "cont" + | "tuple" + | FuncAstTensorUniform + | FuncAstTupleUniform + | FuncAstHole + | FuncAstUnit; +}; + +/** (...) */ +type FuncAstTensorUniform = FuncAstTypeUniform[]; + +/** [...] */ +type FuncAstTupleUniform = FuncAstTypeUniform[]; // // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical @@ -235,36 +348,39 @@ type FuncAstType = type FuncAstHole = { kind: "hole"; value: "_" | "var"; + loc: FuncSrcInfo; }; type FuncAstUnit = { kind: "unit"; value: "()"; + loc: FuncSrcInfo; }; type FuncAstFunctionId = { kind: "function_id"; value: string; + loc: FuncSrcInfo; }; -type FuncAstId = - | FuncAstIdQuoted - | FuncAstIdPlain - ; +type FuncAstId = FuncAstIdQuoted | FuncAstIdPlain; type FuncAstIdQuoted = { kind: "id_quoted"; value: string; + loc: FuncSrcInfo; }; type FuncAstIdPlain = { kind: "id_plain"; value: string; + loc: FuncSrcInfo; }; type FuncAstUnusedId = { kind: "unused_id"; value: "_"; + loc: FuncSrcInfo; }; type FuncAstVersionRange = { @@ -273,6 +389,11 @@ type FuncAstVersionRange = { major: bigint; minor: bigint | undefined; patch: bigint | undefined; + loc: FuncSrcInfo; +}; + +type FuncAstIntegerLiteral = { + loc: FuncSrcInfo; }; /** @@ -282,23 +403,26 @@ type FuncAstStringLiteral = { kind: "string_literal"; value: string; ty: undefined | FuncAstStringType; + loc: FuncSrcInfo; }; /** - * An additional modifier. See: https://docs.ton.org/develop/func/literals_identifiers#string-literals - */ -type FuncAstStringType = "s" | "a" | "u" | "h" | "H" | "c"; - -/** - * """ ... """ + * """ ... """ty? */ -type FuncAstMultiLineString = { +type FuncAstMultiLineStringLiteral = { kind: "multiline_string"; value: string; + ty: undefined | FuncAstStringType; // TODO: alignIndent: boolean; // TODO: trim: boolean; + loc: FuncSrcInfo; }; +/** + * An additional modifier. See: https://docs.ton.org/develop/func/literals_identifiers#string-literals + */ +type FuncAstStringType = "s" | "a" | "u" | "h" | "H" | "c"; + type FuncAstWhiteSpace = { kind: "whitespace"; value: `\t` | ` ` | `\n` | `\r` | `\u2028` | `\u2029`; @@ -309,10 +433,7 @@ type FuncAstWhiteSpace = { * or * {- ... -} */ -type FuncAstComment = - | FuncAstCommentSingleLine - | FuncAstCommentMultiLine - ; +type FuncAstComment = FuncAstCommentSingleLine | FuncAstCommentMultiLine; /** * Doesn't include the starting ;; characters @@ -322,6 +443,7 @@ type FuncAstComment = type FuncAstCommentSingleLine = { kind: "comment_singleline"; line: string; + loc: FuncSrcInfo; }; /** @@ -333,6 +455,7 @@ type FuncAstCommentMultiLine = { kind: "comment_multiline"; contents: string; skipCR: boolean; + loc: FuncSrcInfo; }; // @@ -346,9 +469,10 @@ semantics.addOperation("astOfModule", { Module(pragmas, includes, items) { return { kind: "module", - pragmas: pragmas.children.map(x => x.astOfPragma()), - includes: includes.children.map(x => x.astOfInclude()), - items: items.children.map(x => x.astOfModuleItem()), + pragmas: pragmas.children.map((x) => x.astOfPragma()), + includes: includes.children.map((x) => x.astOfInclude()), + items: items.children.map((x) => x.astOfModuleItem()), + loc: createSrcInfo(this), }; }, comment(cmt) { @@ -358,20 +482,29 @@ semantics.addOperation("astOfModule", { return { kind: "comment_singleline", line: lineContents.sourceString, + loc: createSrcInfo(this), }; }, comment_multiLine(cmt) { return cmt.astOfModule(); }, - multiLineComment(_commentStart, preInnerComment, innerComment, postInnerComment, _commentEnd) { + multiLineComment( + _commentStart, + preInnerComment, + innerComment, + postInnerComment, + _commentEnd, + ) { return { kind: "comment_multiline", contents: [ preInnerComment.sourceString, - (innerComment.children.map(x => x.astOfModule()).join("") ?? ""), + innerComment.children.map((x) => x.astOfModule()).join("") ?? + "", postInnerComment.sourceString, ].join(""), skipCR: false, + loc: createSrcInfo(this), }; }, }); @@ -384,6 +517,7 @@ semantics.addOperation("astOfPragma", { return { kind: "pragma_literal", literal: literal.sourceString, + loc: createSrcInfo(this), }; }, Pragma_versionRange(_pragmaKwd, literal, range, _semicolon) { @@ -391,12 +525,14 @@ semantics.addOperation("astOfPragma", { kind: "pragma_version_range", allow: literal.sourceString === "version" ? true : false, range: range.astOfVersionRange(), + loc: createSrcInfo(this), }; }, Pragma_versionString(_pragmaKwd, _literal, value, _semicolon) { return { kind: "pragma_version_string", version: value.astOfExpression(), + loc: createSrcInfo(this), }; }, }); @@ -406,6 +542,7 @@ semantics.addOperation("astOfInclude", { return { kind: "include", path: path.astOfExpression(), + loc: createSrcInfo(this), }; }, }); @@ -417,24 +554,29 @@ semantics.addOperation("astOfModuleItem", { GlobalVariablesDeclaration(_globalKwd, globals, _semicolon) { return { kind: "global_variables_declaration", - globals: globals.children.map(x => x.astOfGlobalVariable()), + globals: globals.children.map((x) => x.astOfGlobalVariable()), + loc: createSrcInfo(this), }; }, ConstantsDefinition(_constKwd, constants, _semicolon) { return { kind: "constants_definition", - constants: constants.children.map(x => x.astOfConstant()), + constants: constants.children.map((x) => x.astOfConstant()), + loc: createSrcInfo(this), }; }, - AsmFunctionDefinition_singleLine(fnCommonPrefix, _asmKwd, optArrangement, asmStrings, _semicolon) { + AsmFunctionDefinition( + fnCommonPrefix, + _asmKwd, + optArrangement, + asmStrings, + _semicolon, + ) { return { kind: "asm_function_definition", // TODO: fnCommonPrefix, optArrangement }; }, - // AsmFunctionDefinition_multiLine(fnCommon, _asmKwd, optArrangement, multilineAsmStrings, _semicolon) { - // // TODO: - // }, // FunctionDeclaration(arg0, arg1) { // // TODO: ... // }, @@ -456,7 +598,7 @@ semantics.addOperation("astOfFunctionCommonPrefix", { }); /** If the match wasn't successful, provides error message and interval */ type GrammarMatch = | { ok: false; message: string; interval: RawInterval } - | { ok: true }; + | { ok: true; res: MatchResult }; /** * Checks if the given `src` string of FunC code matches the FunC grammar @@ -473,7 +615,7 @@ export function match(src: string): GrammarMatch { }; } - return { ok: true }; + return { ok: true, res: matchResult }; } /** @@ -484,8 +626,13 @@ export function match(src: string): GrammarMatch { export function parse(src: string) { const matchResult = FuncGrammar.match(src); - if (matchResult.failed()) { throwFuncParseError(matchResult, undefined); } - try { return semantics(matchResult).astOfModule(); } finally {} + if (matchResult.failed()) { + throwFuncParseError(matchResult, undefined); + } + try { + return semantics(matchResult).astOfModule(); + } finally { + } } /** @@ -496,7 +643,12 @@ export function parseFile(src: string, path: string) { return inFile(path, () => { const matchResult = FuncGrammar.match(src); - if (matchResult.failed()) { throwFuncParseError(matchResult, path); } - try { return semantics(matchResult).astOfModule(); } finally {} + if (matchResult.failed()) { + throwFuncParseError(matchResult, path); + } + try { + return semantics(matchResult).astOfModule(); + } finally { + } }); } From cec8c179af7e8551672d627e1097a3ba7197232c Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:56:01 +0200 Subject: [PATCH 095/162] fix(func-parser): adjust expressions and identifiers --- src/func/grammar.ohm | 47 +++++++++++++++++++++----------------------- src/func/grammar.ts | 40 ++++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 30 deletions(-) diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 7840b3dc0..c3c2ca38e 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -25,7 +25,7 @@ FunC { GlobalVariableDeclaration = TypeUniform? id ConstantsDefinition = "const" NonemptyListOf ";" - ConstantDefinition = TypeConstant? id "=" Expression + ConstantDefinition = ("slice" | "int")? id "=" Expression AsmFunctionDefinition = FunctionCommonPrefix "asm" AsmArrangement? (multiLineStringLiteral | stringLiteral)+ ";" @@ -117,34 +117,34 @@ FunC { | ExpressionBitwiseShift // parse_expr17 - ExpressionBitwiseShift = ExpressionAddBitwise "<<" ExpressionAddBitwise --shl - | ExpressionAddBitwise ">>" ExpressionAddBitwise --shr - | ExpressionAddBitwise "~>>" ExpressionAddBitwise --shrRound - | ExpressionAddBitwise "^>>" ExpressionAddBitwise --shrCeil + ExpressionBitwiseShift = ExpressionAddBitwise ("<<" ExpressionAddBitwise)+ --shl + | ExpressionAddBitwise (">>" ExpressionAddBitwise)+ --shr + | ExpressionAddBitwise ("~>>" ExpressionAddBitwise)+ --shrRound + | ExpressionAddBitwise ("^>>" ExpressionAddBitwise)+ --shrCeil | ExpressionAddBitwise // parse_expr20 - ExpressionAddBitwise = "-"? ExpressionMulBitwise "+" ExpressionMulBitwise --add - | "-"? ExpressionMulBitwise "-" ExpressionMulBitwise --sub - | "-"? ExpressionMulBitwise "|" ExpressionMulBitwise --bitwiseOr - | "-"? ExpressionMulBitwise "^" ExpressionMulBitwise --bitwiseXor - | "-" ExpressionMulBitwise --minus + ExpressionAddBitwise = ("-" &whiteSpace)? ExpressionMulBitwise ("+" ExpressionMulBitwise)+ --add + | ("-" &whiteSpace)? ExpressionMulBitwise ("-" ExpressionMulBitwise)+ --sub + | ("-" &whiteSpace)? ExpressionMulBitwise ("|" ExpressionMulBitwise)+ --bitwiseOr + | ("-" &whiteSpace)? ExpressionMulBitwise ("^" ExpressionMulBitwise)+ --bitwiseXor + | ("-" &whiteSpace) ExpressionMulBitwise --minus | ExpressionMulBitwise // parse_expr30 - ExpressionMulBitwise = ExpressionUnary "*" ExpressionUnary --mul - | ExpressionUnary "/%" ExpressionUnary --divMod - | ExpressionUnary "/" ExpressionUnary --div - | ExpressionUnary "%" ExpressionUnary --mod - | ExpressionUnary "~/" ExpressionUnary --divRound - | ExpressionUnary "~%" ExpressionUnary --modRound - | ExpressionUnary "^/" ExpressionUnary --divCeil - | ExpressionUnary "^%" ExpressionUnary --modCeil - | ExpressionUnary "&" ExpressionUnary --bitwiseAnd + ExpressionMulBitwise = ExpressionUnary ("*" ExpressionUnary)+ --mul + | ExpressionUnary ("/%" ExpressionUnary)+ --divMod + | ExpressionUnary ("/" ExpressionUnary)+ --div + | ExpressionUnary ("%" ExpressionUnary)+ --mod + | ExpressionUnary ("~/" ExpressionUnary)+ --divRound + | ExpressionUnary ("~%" ExpressionUnary)+ --modRound + | ExpressionUnary ("^/" ExpressionUnary)+ --divCeil + | ExpressionUnary ("^%" ExpressionUnary)+ --modCeil + | ExpressionUnary ("&" ExpressionUnary)+ --bitwiseAnd | ExpressionUnary // parse_expr75 - ExpressionUnary = "~" ExpressionMethodCall --bitwiseNot + ExpressionUnary = "~" &whiteSpace ExpressionMethodCall --bitwiseNot | ExpressionMethodCall // parse_expr80 @@ -173,9 +173,6 @@ FunC { // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // - // Allowed types of constants - TypeConstant = "int" | "slice" - // forall type1, ..., typeN -> Forall = "forall" NonemptyListOf "->" TypeVar = "type"? id @@ -223,12 +220,12 @@ FunC { unit = "()" // Function identifiers - functionId = ~("\"" | "{-") ("." | "~")? id + functionId = ~("\"" | "{-") ("." | "~")? (quotedId | plainId) // Identifiers, with invalidation (keywords, numbers, etc.) during syntax analysis // — this makes this parser closer to the C++ one, and also improves error messages - id = ~("\"" | "{-") (quotedId | plainId) + id = ~("\"" | "{-" | "." | "~") (quotedId | plainId) quotedId = "`" (~("`" | "\n") any)+ "`" plainId = (~(whiteSpace | "(" | ")" | "[ | ]" | "," | "." | ";" | "~") any)+ diff --git a/src/func/grammar.ts b/src/func/grammar.ts index a9c6d0a99..69e2a9f7c 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -164,7 +164,8 @@ type FuncAstPragma = */ type FuncAstPragmaLiteral = { kind: "pragma_literal"; - literal: "allow-post-modification" | "compute-asm-ltr"; + literal: string; + // "allow-post-modification" | "compute-asm-ltr"; loc: FuncSrcInfo; }; @@ -203,14 +204,16 @@ type FuncAstInclude = { // Top-level, module items // -type FuncAstModuleItem = FuncAstGlobalVariablesDeclaration; +type FuncAstModuleItem = + | FuncAstGlobalVariablesDeclaration + | FuncAstConstantsDefinition; /** * global ..., ...; */ type FuncAstGlobalVariablesDeclaration = { kind: "global_variables_declaration"; - globals: FuncAstGlobalVariable; + globals: FuncAstGlobalVariable[]; loc: FuncSrcInfo; }; @@ -219,23 +222,48 @@ type FuncAstGlobalVariablesDeclaration = { */ type FuncAstGlobalVariable = { kind: "global_variable"; - type: FuncAstTypeUniform | undefined; + ty: FuncAstTypeUniform | undefined; name: FuncAstId; loc: FuncSrcInfo; }; +/** + * const ..., ...; + */ +type FuncAstConstantsDefinition = { + kind: "constants_definition"; + constants: FuncAstConstant[]; + loc: FuncSrcInfo; +} + +/** + * (slice | int)? id = Expression + */ +type FuncAstConstant = { + kind: "constant"; + ty: "slice" | "int" | undefined; + name: FuncAstId; + value: FuncAstExpression; + loc: FuncSrcInfo; +} + // // Statements // TODO // -type FuncAstStatement = {}; +type FuncAstStatement = + | {}; + // // Expressions // TODO // +type FuncAstExpression = + | {}; + // // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // @@ -393,6 +421,8 @@ type FuncAstVersionRange = { }; type FuncAstIntegerLiteral = { + kind: "integer_literal"; + value: bigint; loc: FuncSrcInfo; }; From e185cfecfbc1448f2eb3e71cbee6ec0ecf18fd75 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Mon, 5 Aug 2024 01:51:10 +0200 Subject: [PATCH 096/162] func(func-parser): grammar is finally completed, and most tests pass! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit However, I still have to restrain the identifiers — they parse too much. Then, the `grammar.ts` will be swiftly completed and the parser would be done. I'll do that ASAP --- src/func/grammar-test/asm-functions.fc | 2 +- src/func/grammar-test/statements.fc | 2 +- src/func/grammar.ohm | 71 ++++++++++++++------------ 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/func/grammar-test/asm-functions.fc b/src/func/grammar-test/asm-functions.fc index 460d650a4..49064db9a 100644 --- a/src/func/grammar-test/asm-functions.fc +++ b/src/func/grammar-test/asm-functions.fc @@ -18,7 +18,7 @@ slice hello_world() asm """ ;; Mix single-line and multi-line strings -int inc_then_negate'''(int x) asn "INC" """ +int inc_then_negate'''(int x) asm "INC" """ NEGATE """; diff --git a/src/func/grammar-test/statements.fc b/src/func/grammar-test/statements.fc index fcae9b902..bc748f8d9 100644 --- a/src/func/grammar-test/statements.fc +++ b/src/func/grammar-test/statements.fc @@ -38,7 +38,7 @@ int return_stmt'() { return 42; } ;; repeat () repeat_stmt() { - repeat 1 { } + repeat (1) { } repeat 1 { ; ; ; diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index c3c2ca38e..57ca41029 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -27,7 +27,7 @@ FunC { ConstantsDefinition = "const" NonemptyListOf ";" ConstantDefinition = ("slice" | "int")? id "=" Expression - AsmFunctionDefinition = FunctionCommonPrefix "asm" AsmArrangement? (multiLineStringLiteral | stringLiteral)+ ";" + AsmFunctionDefinition = FunctionCommonPrefix "asm" AsmArrangement? stringLiteral+ ";" AsmArrangement = "(" "->" integerLiteralDec+ ")" --returns | "(" id+ ~"->" ")" --arguments @@ -42,7 +42,8 @@ FunC { // Called "specifiers" in https://docs.ton.org/develop/func/functions#specifiers FunctionAttribute = "impure" | "inline_ref" | "inline" | MethodIdValue | "method_id" - MethodIdValue = "method_id" "(" integerLiteralNonNegative ")" + MethodIdValue = "method_id" "(" integerLiteral ")" --int + | "method_id" "(" stringLiteral ")" --string // // Statements @@ -76,10 +77,7 @@ FunC { // https://github.com/ton-blockchain/ton/blob/master/crypto/func/parse-func.cpp // - // NOTE: they should parse exactly as FunC 0.4.4 does it, including the issues with precedences of ^ | and similar - // parse_expr - // Expression = integerLiteral | stringLiteral | id // FIXME temporary, for tests prior to expressions Expression = ExpressionAssign // parse_expr10 @@ -144,30 +142,34 @@ FunC { | ExpressionUnary // parse_expr75 - ExpressionUnary = "~" &whiteSpace ExpressionMethodCall --bitwiseNot - | ExpressionMethodCall + ExpressionUnary = "~" &whiteSpace ExpressionMethod --bitwiseNot + | ExpressionMethod // parse_expr80 - ExpressionMethodCall = ExpressionSequence ("." | "~") id ExpressionPrimary --call - | ExpressionSequence + ExpressionMethod = ExpressionVarFun (&("." | "~") #functionId ExpressionPrimary)+ --call + | ExpressionVarFun + + // parse_expr90 + ExpressionVarFun = (hole | Type) &("(" | "[" | ~("{" | "}") id) ExpressionPrimary --decl + | ExpressionPrimary (&("(" | "[" | ~("{" | "}") id) ExpressionPrimary)+ --call + | ExpressionPrimary + - // FIXME: Temporary definition for debugging purposes. - ExpressionSequence = ExpressionPrimary - // parse_expr90, FIXME: this is wrong and has to be re-made :) - // TODO: function call - // TODO: variable declaration - // ExpressionSequence = ExpressionPrimary &"(" ExpressionPrimary --call - // | ExpressionPrimary &"[" ExpressionPrimary --access - // | ExpressionPrimary ~("." | "~") id ExpressionPrimary --id - // | ExpressionPrimary + // parse_expr100 + ExpressionPrimary = stringLiteral + | integerLiteral + | unit + | ExpressionTensor + | ExpressionParens + | tupleEmpty + | ExpressionTuple + | id - // parse_expr100, order is important - ExpressionPrimary = - // TODO: parens? - | integerLiteral | multiLineStringLiteral | stringLiteral | TypeUniform | id + ExpressionParens = "(" Expression ")" + ExpressionTensor = "(" ListOf ")" + ExpressionTuple = "[" ListOf "]" - // ExpressionParens = "(" Expression ")" // // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical @@ -177,12 +179,10 @@ FunC { Forall = "forall" NonemptyListOf "->" TypeVar = "type"? id - // Parameters, with type holes prohibited during syntax analysis + // Parameters, with holes allowed for identifiers Parameters = "(" ListOf ")" - Parameter = Type id - - // Arguments -- TODO: unused, remove? - // Arguments = "(" ListOf ")" + Parameter = Type id --regular + | id --inferredType // Argument = id // Mapped or unmapped builtin types or type variables, @@ -194,7 +194,8 @@ FunC { // Builtin types TypeBuiltin = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | Tensor | Tuple | hole | unit + | unit | tupleEmpty | Tensor | Tuple + // Non-functional composite builtin types Tensor = "(" NonemptyListOf ")" @@ -205,7 +206,7 @@ FunC { | TypeBuiltinUniform --builtin TypeBuiltinUniform = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | TensorUniform | TupleUniform | hole | unit + | hole | unit | tupleEmpty | TensorUniform | TupleUniform TensorUniform = "(" NonemptyListOf ")" @@ -215,9 +216,11 @@ FunC { // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // - // Special types + // Special types or values hole = "_" | "var" unit = "()" + tupleEmpty = "[]" + // Function identifiers functionId = ~("\"" | "{-") ("." | "~")? (quotedId | plainId) @@ -228,7 +231,7 @@ FunC { id = ~("\"" | "{-" | "." | "~") (quotedId | plainId) quotedId = "`" (~("`" | "\n") any)+ "`" - plainId = (~(whiteSpace | "(" | ")" | "[ | ]" | "," | "." | ";" | "~") any)+ + plainId = (~(whiteSpace | "(" | ")" | "[" | "]" | "," | "." | ";" | "~") any)+ // Unused identifiers unusedId = "_" @@ -253,8 +256,8 @@ FunC { integerLiteralDec = digit+ // Strings - stringLiteral = "\"" (~"\"" any)* "\"" stringType? - multiLineStringLiteral = "\"\"\"" (~"\"\"\"" any)* "\"\"\"" stringType? + stringLiteral = "\"\"\"" (~"\"\"\"" any)* "\"\"\"" stringType? --multiLine + | "\"" (~"\"" any)* "\"" stringType? --singleLine stringType = "s" --sliceHex | "a" --sliceInternalAddress From 7286760d95a3a0a987ab3a898a5955a77f725b80 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:15:12 +0200 Subject: [PATCH 097/162] fix(func-parser): fixed most of the bugs, working on identifiers starting with underscores ...and/or similar things --- src/func/grammar.ohm | 75 ++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 57ca41029..abade3c02 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -40,6 +40,15 @@ FunC { // Common prefix of function declarations and definitions FunctionCommonPrefix = Forall? Type functionId Parameters FunctionAttribute* + // forall type1, ..., typeN -> + Forall = "forall" NonemptyListOf "->" + TypeVar = "type"? id + + // Parameters, with holes allowed for identifiers + Parameters = "(" ListOf ")" + Parameter = Type id --regular + | id --inferredType + // Called "specifiers" in https://docs.ton.org/develop/func/functions#specifiers FunctionAttribute = "impure" | "inline_ref" | "inline" | MethodIdValue | "method_id" MethodIdValue = "method_id" "(" integerLiteral ")" --int @@ -122,11 +131,11 @@ FunC { | ExpressionAddBitwise // parse_expr20 - ExpressionAddBitwise = ("-" &whiteSpace)? ExpressionMulBitwise ("+" ExpressionMulBitwise)+ --add - | ("-" &whiteSpace)? ExpressionMulBitwise ("-" ExpressionMulBitwise)+ --sub - | ("-" &whiteSpace)? ExpressionMulBitwise ("|" ExpressionMulBitwise)+ --bitwiseOr - | ("-" &whiteSpace)? ExpressionMulBitwise ("^" ExpressionMulBitwise)+ --bitwiseXor - | ("-" &whiteSpace) ExpressionMulBitwise --minus + ExpressionAddBitwise = ("-" &#whiteSpace)? ExpressionMulBitwise ("+" ExpressionMulBitwise)+ --add + | ("-" &#whiteSpace)? ExpressionMulBitwise ("-" ExpressionMulBitwise)+ --sub + | ("-" &#whiteSpace)? ExpressionMulBitwise ("|" ExpressionMulBitwise)+ --bitwiseOr + | ("-" &#whiteSpace)? ExpressionMulBitwise ("^" ExpressionMulBitwise)+ --bitwiseXor + | ("-" &#whiteSpace) ExpressionMulBitwise --minus | ExpressionMulBitwise // parse_expr30 @@ -142,31 +151,34 @@ FunC { | ExpressionUnary // parse_expr75 - ExpressionUnary = "~" &whiteSpace ExpressionMethod --bitwiseNot + ExpressionUnary = "~" &#whiteSpace ExpressionMethod --bitwiseNot | ExpressionMethod // parse_expr80 - ExpressionMethod = ExpressionVarFun (&("." | "~") #functionId ExpressionPrimary)+ --call + ExpressionMethod = ExpressionVarFun (methodId &("(" | "[" | Id) ExpressionPrimary)+ --call | ExpressionVarFun // parse_expr90 - ExpressionVarFun = (hole | Type) &("(" | "[" | ~("{" | "}") id) ExpressionPrimary --decl - | ExpressionPrimary (&("(" | "[" | ~("{" | "}") id) ExpressionPrimary)+ --call - | ExpressionPrimary + ExpressionVarFun = + | ExpressionPrimary (&("(" | "[" | Id) ExpressionPrimary)+ --functionCall + | Type (&("(" | "[" | Id) ExpressionPrimary) --polymorphVarDecl + // hole in TypeUniform + | TypeUniform (&("(" | "[" | Id) ExpressionPrimary) --uniformVarDecl + | ExpressionPrimary // parse_expr100 ExpressionPrimary = stringLiteral | integerLiteral - | unit | ExpressionTensor - | ExpressionParens - | tupleEmpty + | unit | ExpressionTuple - | id + | tupleEmpty + | FunctionId // id??? + Id = ~(hole | integerLiteral | delimiter | operator) id + FunctionId = ~(hole | integerLiteral | delimiter | operator) functionId - ExpressionParens = "(" Expression ")" ExpressionTensor = "(" ListOf ")" ExpressionTuple = "[" ListOf "]" @@ -175,14 +187,6 @@ FunC { // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // - // forall type1, ..., typeN -> - Forall = "forall" NonemptyListOf "->" - TypeVar = "type"? id - - // Parameters, with holes allowed for identifiers - Parameters = "(" ListOf ")" - Parameter = Type id --regular - | id --inferredType // Argument = id // Mapped or unmapped builtin types or type variables, @@ -190,27 +194,27 @@ FunC { // and type variables refer to parametric polymorphism with `forall` Type = TypeBuiltin "->" Type --mapped | TypeBuiltin --builtin - | id --var + // | Id --var // Builtin types TypeBuiltin = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | unit | tupleEmpty | Tensor | Tuple + | Tensor | Tuple | unit | tupleEmpty | Id // Non-functional composite builtin types - Tensor = "(" NonemptyListOf ")" - Tuple = "[" NonemptyListOf "]" + Tensor = "(" ListOf ")" + Tuple = "[" ListOf "]" // Non-polymorphic, uniform types TypeUniform = TypeBuiltinUniform "->" TypeUniform --mapped | TypeBuiltinUniform --builtin TypeBuiltinUniform = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | hole | unit | tupleEmpty | TensorUniform | TupleUniform + | hole | TensorUniform | TupleUniform | unit | tupleEmpty - TensorUniform = "(" NonemptyListOf ")" + TensorUniform = "(" ListOf ")" - TupleUniform = "[" NonemptyListOf "]" + TupleUniform = "[" ListOf "]" // // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical @@ -221,9 +225,20 @@ FunC { unit = "()" tupleEmpty = "[]" + // Operators and delimiters + operator = ("+" | "-" | "*" | "/%" | "/" | "%" + | "~/" | "^/" | "~%" | "^%") --arithOperator + | ("<=>" | "<=" | "<" | ">=" | ">" | "!=" | "==") --comparisonOperator + | ("~>>" | "~" | "^>>" | "^" | "&" | "|" | "<<" | ">>") --bitwiseOperator + | ("=" | "+=" | "-=" | "*=" | "/=" | "%=" | "~>>=" + | "~/=" | "~%=" | "^>>=" | "^/=" | "^%=" | "^=" + | "<<=" | ">>=" | "&=" | "|=") --assignOperator + delimiter = "{" | "}" | "?" | ":" + // Function identifiers functionId = ~("\"" | "{-") ("." | "~")? (quotedId | plainId) + methodId = ~("\"" | "{-") ("." | "~") (quotedId | plainId) // Identifiers, with invalidation (keywords, numbers, etc.) during syntax analysis // — this makes this parser closer to the C++ one, and also improves error messages From f1519d206ea621a13e7c422aa3235a7bbe0438f6 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Tue, 6 Aug 2024 00:43:58 +0200 Subject: [PATCH 098/162] refactor(func-parser): types, expressions, and whitespace padding Next up: two highest-precedence sets of expressions and rework of identifiers. Then, if that works out, semantic actions (finally!). If even that won't, I'm calling FunC "context-sensitive", getting rid of Ohm and swiftly hand-rolling a recursive descent parsed based on the C++ sources of FunC. *sigh* --- src/func/grammar-test/functions.fc | 2 +- src/func/grammar.ohm | 216 ++++++++++++++++++----------- src/func/grammar.ts | 51 ++++--- 3 files changed, 171 insertions(+), 98 deletions(-) diff --git a/src/func/grammar-test/functions.fc b/src/func/grammar-test/functions.fc index d38bf4911..4da7e341f 100644 --- a/src/func/grammar-test/functions.fc +++ b/src/func/grammar-test/functions.fc @@ -6,7 +6,7 @@ ;; Parametric polymorphism with forall forall X -> () poly(X p1); -forall X, Y -> (Y, X) poly'(); +forall X, Y -> (Y, X) poly'(X p1, Y p2); ;; Attributes (called specifiers in TON Docs) () attr() impure inline_ref inline method_id(0x2A); diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index abade3c02..d7cb0f90b 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -21,33 +21,72 @@ FunC { | FunctionDeclaration | FunctionDefinition + // + // Declarations of global variables + // + GlobalVariablesDeclaration = "global" NonemptyListOf ";" - GlobalVariableDeclaration = TypeUniform? id + GlobalVariableDeclaration = TypeGlob? id + + TypeGlob = TypeBuiltinGlob ("->" TypeGlob)? + + TypeBuiltinGlob = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" + | "_" | unit | tupleEmpty | TensorGlob | TupleGlob + + TensorGlob = "(" ListOf ")" + TupleGlob = "[" ListOf "]" + + // + // Definitions of constants + // ConstantsDefinition = "const" NonemptyListOf ";" ConstantDefinition = ("slice" | "int")? id "=" Expression + // + // Definitions of asm functions + // + AsmFunctionDefinition = FunctionCommonPrefix "asm" AsmArrangement? stringLiteral+ ";" - AsmArrangement = "(" "->" integerLiteralDec+ ")" --returns + AsmArrangement = "(" "->" &#whiteSpace integerLiteralDec+ ")" --returns | "(" id+ ~"->" ")" --arguments - | "(" id+ "->" integerLiteralDec+ ")" --argumentsToReturns + | "(" id+ &#whiteSpace "->" &#whiteSpace integerLiteralDec+ ")" --argumentsToReturns - FunctionDeclaration = FunctionCommonPrefix ";" + // + // Function declarations, definitions and common prefix of their syntax + // + FunctionDeclaration = FunctionCommonPrefix ";" FunctionDefinition = FunctionCommonPrefix "{" Statement* "}" - - // Common prefix of function declarations and definitions - FunctionCommonPrefix = Forall? Type functionId Parameters FunctionAttribute* + FunctionCommonPrefix = Forall? TypeReturn functionId Parameters FunctionAttribute* // forall type1, ..., typeN -> - Forall = "forall" NonemptyListOf "->" - TypeVar = "type"? id + Forall = "forall" &#whiteSpace NonemptyListOf &#whiteSpace "->" &#whiteSpace + TypeVar = ("type" &#whiteSpace)? id - // Parameters, with holes allowed for identifiers + // Function return types + TypeReturn = TypeBuiltinReturn (&#whiteSpace "->" &#whiteSpace TypeReturn)? + + TypeBuiltinReturn = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" + | "_" | unit | tupleEmpty | TensorReturn | TupleReturn | id + + TensorReturn = "(" ListOf ")" + TupleReturn = "[" ListOf "]" + + // Function parameters Parameters = "(" ListOf ")" - Parameter = Type id --regular - | id --inferredType + Parameter = TypeParameter &#whiteSpace (hole | id) --regular + | (hole | id) --inferredType + + // Function parameter types + TypeParameter = TypeBuiltinParameter (&#whiteSpace "->" &#whiteSpace TypeParameter)? + + TypeBuiltinParameter = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" + | unit | tupleEmpty | TensorParameter | TupleParameter | id + + TensorParameter = "(" ListOf ")" + TupleParameter = "[" ListOf "]" // Called "specifiers" in https://docs.ton.org/develop/func/functions#specifiers FunctionAttribute = "impure" | "inline_ref" | "inline" | MethodIdValue | "method_id" @@ -55,7 +94,7 @@ FunC { | "method_id" "(" stringLiteral ")" --string // - // Statements + // Statements (with mandatory whitespace padding in most places ) // Statement = StatementReturn @@ -68,17 +107,37 @@ FunC { | StatementTryCatch | StatementExpression - StatementReturn = "return" Expression ";" - StatementBlock = "{" Statement* "}" - StatementEmpty = ";" - StatementCondition = ("ifnot" | "if" ) Expression "{" Statement* "}" ("elseifnot" | "elseif") Expression "{" Statement* "}" --withElseCondition - | ("ifnot" | "if" ) Expression "{" Statement* "}" "else" "{" Statement* "}" --withElse - | ("ifnot" | "if" ) Expression "{" Statement* "}" --noElse - StatementRepeat = "repeat" Expression "{" Statement* "}" - StatementUntil = "do" "{" Statement* "}" "until" Expression ";" - StatementWhile = "while" Expression "{" Statement* "}" - StatementTryCatch = "try" "{" Statement* "}" "catch" "(" (unusedId | id) "," (unusedId | id) ")" "{" Statement* "}" - StatementExpression = Expression ";" + StatementReturn = "return" &#whiteSpace Expression ";" + + StatementBlock = "{" &#whiteSpace Statement* &#whiteSpace "}" + + StatementEmpty = ";" + + StatementCondition = ("ifnot" | "if") &#whiteSpace + Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" &#whiteSpace + ("elseifnot" | "elseif") &#whiteSpace + Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" --withElseCondition + + | ("ifnot" | "if") &#whiteSpace + Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" &#whiteSpace + "else" &#whiteSpace + "{" &#whiteSpace Statement* &#whiteSpace "}" --withElse + + | ("ifnot" | "if") &#whiteSpace + Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" --noElse + + StatementRepeat = "repeat" &#whiteSpace Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" + + StatementUntil = "do" &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" &#whiteSpace "until" &#whiteSpace Expression ";" + + StatementWhile = "while" &#whiteSpace Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" + + StatementTryCatch = "try" &#whiteSpace + "{" &#whiteSpace Statement* &#whiteSpace "}" &#whiteSpace + "catch" &#whiteSpace "(" (unusedId | id) "," (unusedId | id) ")" &#whiteSpace + "{" &#whiteSpace Statement* &#whiteSpace "}" + + StatementExpression = Expression &#whiteSpace ";" // // Expressions, ordered by precedence (from lowest to highest), @@ -90,64 +149,43 @@ FunC { Expression = ExpressionAssign // parse_expr10 - ExpressionAssign = ExpressionConditional "=" ExpressionAssign --assign - | ExpressionConditional "+=" ExpressionAssign --addAssign - | ExpressionConditional "-=" ExpressionAssign --subAssign - | ExpressionConditional "*=" ExpressionAssign --mulAssign - | ExpressionConditional "/=" ExpressionAssign --divAssign - | ExpressionConditional "%=" ExpressionAssign --modAssign - | ExpressionConditional "~/=" ExpressionAssign --divRoundAssign - | ExpressionConditional "~%=" ExpressionAssign --modRoundAssign - | ExpressionConditional "^/=" ExpressionAssign --divCeilAssign - | ExpressionConditional "^%=" ExpressionAssign --modCeilAssign - | ExpressionConditional "&=" ExpressionAssign --bitwiseAndAssign - | ExpressionConditional "|=" ExpressionAssign --bitwiseOrAssign - | ExpressionConditional "^=" ExpressionAssign --bitwiseXorAssign - | ExpressionConditional "<<=" ExpressionAssign --shlAssign - | ExpressionConditional ">>=" ExpressionAssign --shrAssign - | ExpressionConditional "~>>=" ExpressionAssign --shrRoundAssign - | ExpressionConditional "^>>=" ExpressionAssign --shrCeilAssign + ExpressionAssign = ExpressionConditional + &#whiteSpace ("=" | "+=" | "-=" | "*=" | "/=" | "%=" + | "~/=" | "~%=" | "^/=" | "^%=" | "&=" + | "|=" | "^=" | "<<=" | ">>=" | "~>>=" | "^>>=") &#whiteSpace + ExpressionAssign --op | ExpressionConditional // parse_expr13 - ExpressionConditional = ExpressionCompare "?" Expression ":" ExpressionConditional --ternary + ExpressionConditional = ExpressionCompare + &#whiteSpace "?" &#whiteSpace Expression + &#whiteSpace ":" &#whiteSpace ExpressionConditional --ternary | ExpressionCompare // parse_expr15 - ExpressionCompare = ExpressionBitwiseShift "==" ExpressionBitwiseShift --eq - | ExpressionBitwiseShift "<=>" ExpressionBitwiseShift --spaceship - | ExpressionBitwiseShift "<=" ExpressionBitwiseShift --lte - | ExpressionBitwiseShift "<" ExpressionBitwiseShift --lt - | ExpressionBitwiseShift ">=" ExpressionBitwiseShift --gte - | ExpressionBitwiseShift ">" ExpressionBitwiseShift --gt - | ExpressionBitwiseShift "!=" ExpressionBitwiseShift --neq + ExpressionCompare = ExpressionBitwiseShift + &#whiteSpace ("==" | "<=>" | "<=" | "<" | ">=" | ">" | "!=") &#whiteSpace + ExpressionBitwiseShift --op | ExpressionBitwiseShift // parse_expr17 - ExpressionBitwiseShift = ExpressionAddBitwise ("<<" ExpressionAddBitwise)+ --shl - | ExpressionAddBitwise (">>" ExpressionAddBitwise)+ --shr - | ExpressionAddBitwise ("~>>" ExpressionAddBitwise)+ --shrRound - | ExpressionAddBitwise ("^>>" ExpressionAddBitwise)+ --shrCeil + ExpressionBitwiseShift = ExpressionAddBitwise + (&#whiteSpace ("<<" | ">>" | "~>>" | "^>>") &#whiteSpace + ExpressionAddBitwise)+ --ops | ExpressionAddBitwise // parse_expr20 - ExpressionAddBitwise = ("-" &#whiteSpace)? ExpressionMulBitwise ("+" ExpressionMulBitwise)+ --add - | ("-" &#whiteSpace)? ExpressionMulBitwise ("-" ExpressionMulBitwise)+ --sub - | ("-" &#whiteSpace)? ExpressionMulBitwise ("|" ExpressionMulBitwise)+ --bitwiseOr - | ("-" &#whiteSpace)? ExpressionMulBitwise ("^" ExpressionMulBitwise)+ --bitwiseXor - | ("-" &#whiteSpace) ExpressionMulBitwise --minus + ExpressionAddBitwise = ("-" &#whiteSpace)? + ExpressionMulBitwise + (&#whiteSpace ("+" | "-" | "|" | "^") &#whiteSpace + ExpressionMulBitwise)+ --ops | ExpressionMulBitwise // parse_expr30 - ExpressionMulBitwise = ExpressionUnary ("*" ExpressionUnary)+ --mul - | ExpressionUnary ("/%" ExpressionUnary)+ --divMod - | ExpressionUnary ("/" ExpressionUnary)+ --div - | ExpressionUnary ("%" ExpressionUnary)+ --mod - | ExpressionUnary ("~/" ExpressionUnary)+ --divRound - | ExpressionUnary ("~%" ExpressionUnary)+ --modRound - | ExpressionUnary ("^/" ExpressionUnary)+ --divCeil - | ExpressionUnary ("^%" ExpressionUnary)+ --modCeil - | ExpressionUnary ("&" ExpressionUnary)+ --bitwiseAnd + ExpressionMulBitwise = ExpressionUnary + (&#whiteSpace ("*" | "/%" | "/" | "%" + | "~/" | "~%" | "^/" | "^%" | "&") &#whiteSpace + ExpressionUnary)+ --ops | ExpressionUnary // parse_expr75 @@ -155,7 +193,7 @@ FunC { | ExpressionMethod // parse_expr80 - ExpressionMethod = ExpressionVarFun (methodId &("(" | "[" | Id) ExpressionPrimary)+ --call + ExpressionMethod = ExpressionVarFun (methodId &("(" | "[" | id) ExpressionPrimary)+ --calls | ExpressionVarFun // parse_expr90 @@ -169,16 +207,22 @@ FunC { // parse_expr100 - ExpressionPrimary = stringLiteral - | integerLiteral - | ExpressionTensor + ExpressionPrimary = | unit - | ExpressionTuple + | ExpressionTensor | tupleEmpty - | FunctionId // id??? - Id = ~(hole | integerLiteral | delimiter | operator) id - FunctionId = ~(hole | integerLiteral | delimiter | operator) functionId + | ExpressionTuple + | hole + | typePrimitive + | integerLiteral + | booleanExpression + | nilExpression + | stringLiteral + | id + + restrictedId = ~((hole | integerLiteral | delimiter | operator) ~id) id + restrictedFunctionId = ~((hole | integerLiteral | delimiter | operator) ~functionId) functionId ExpressionTensor = "(" ListOf ")" ExpressionTuple = "[" ListOf "]" @@ -195,10 +239,13 @@ FunC { Type = TypeBuiltin "->" Type --mapped | TypeBuiltin --builtin // | Id --var + // builtin -> primitive + typePrimitive = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" // Builtin types TypeBuiltin = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | Tensor | Tuple | unit | tupleEmpty | Id + | Tensor | Tuple | unit | tupleEmpty | restrictedId + // | Id // Non-functional composite builtin types @@ -221,7 +268,7 @@ FunC { // // Special types or values - hole = "_" | "var" + hole = "_" | "var" ~id unit = "()" tupleEmpty = "[]" @@ -237,13 +284,16 @@ FunC { // Function identifiers - functionId = ~("\"" | "{-") ("." | "~")? (quotedId | plainId) - methodId = ~("\"" | "{-") ("." | "~") (quotedId | plainId) + functionId = ~("\"" | "{-") ("." | "~")? rawId + methodId = ~("\"" | "{-") ("." | "~") rawId // Identifiers, with invalidation (keywords, numbers, etc.) during syntax analysis // — this makes this parser closer to the C++ one, and also improves error messages - id = ~("\"" | "{-" | "." | "~") (quotedId | plainId) + // TODO: re-work everything here!!!! Literally everything! + rawId = quotedId | plainId + + id = ~("\"" | "{-" | "." | "~") rawId quotedId = "`" (~("`" | "\n") any)+ "`" plainId = (~(whiteSpace | "(" | ")" | "[" | "]" | "," | "." | ";" | "~") any)+ @@ -270,6 +320,12 @@ FunC { // digit is defined in Ohm's built-in rules as: digit = "0".."9" integerLiteralDec = digit+ + // Boolean expressions (builtins.cpp) + booleanExpression = "true" | "false" + + // Nil expressions (builtins.cpp) + nilExpression = "nil" | "Nil" + // Strings stringLiteral = "\"\"\"" (~"\"\"\"" any)* "\"\"\"" stringType? --multiLine | "\"" (~"\"" any)* "\"" stringType? --singleLine diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 69e2a9f7c..66648d165 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -141,9 +141,9 @@ type FuncAstNode = type FuncAstModule = { kind: "module"; - pragmas: FuncAstPragma; - includes: FuncAstInclude; - items: FuncAstModuleItem; + pragmas: FuncAstPragma[]; + includes: FuncAstInclude[]; + items: FuncAstModuleItem[]; loc: FuncSrcInfo; }; @@ -268,16 +268,10 @@ type FuncAstExpression = // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // -/** - * Allowed types of constants - */ -type FuncAstTypeConstant = "int" | "slice"; - /** * forall type? typeName1, type? typeName2, ... -> */ type FuncAstForall = FuncAstTypeVar[]; -// TODO: or { kind: ..., etc. } /** * "type"? id @@ -293,14 +287,30 @@ type FuncAstTypeVar = { * (type id, ...) */ type FuncAstParameters = FuncAstParameter[]; -// TODO: or { kind: ..., etc. } + +/** + * Parameters + */ +type FuncAstParameter = + | FuncAstParameterRegular + | FuncAstParameterInferredType; /** * type id */ -type FuncAstParameter = { - kind: "parameter"; +type FuncAstParameterRegular = { + kind: "parameter_regular"; ty: FuncAstType; + ident: FuncAstId; + loc: FuncSrcInfo; +}; + +/** + * id + */ +type FuncAstParameterInferredType = { + kind: "parameter_inferred_type"; + ident: FuncAstId; loc: FuncSrcInfo; }; @@ -420,27 +430,34 @@ type FuncAstVersionRange = { loc: FuncSrcInfo; }; +/** + * -? dec | -? hex + */ type FuncAstIntegerLiteral = { kind: "integer_literal"; value: bigint; loc: FuncSrcInfo; }; +type FuncAstStringLiteral = + | FuncAstStringLiteralSingleLine + | FuncAstStringLiteralMultiLine; + /** * "..."ty? */ -type FuncAstStringLiteral = { - kind: "string_literal"; +type FuncAstStringLiteralSingleLine = { + kind: "string_singleline"; value: string; ty: undefined | FuncAstStringType; loc: FuncSrcInfo; }; /** - * """ ... """ty? + * """ ... """ty? */ -type FuncAstMultiLineStringLiteral = { - kind: "multiline_string"; +type FuncAstStringLiteralMultiLine = { + kind: "string_multiline"; value: string; ty: undefined | FuncAstStringType; // TODO: alignIndent: boolean; From c60104adc448235c9b01f361d4eb53b01ef83e92 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Wed, 7 Aug 2024 12:32:17 +0200 Subject: [PATCH 099/162] feat(func-parser): grammar is finally complete and able to parse stdlib.fc and Tact's stdlib Note, that generic types in variable declarations are temporarily omitted, as they turn FunC into a context-sensitive grammar. This could be resolved in the future, by either doing some hacks during syntax analysis, or by introducing, say, a `decl` keyword into FunC to prefix all variable declarations: `decl var/_/type(s) ids...` --- src/func/grammar.ohm | 158 ++++++++++++++++++++----------------------- 1 file changed, 74 insertions(+), 84 deletions(-) diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index d7cb0f90b..53abaf9f3 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -30,11 +30,11 @@ FunC { TypeGlob = TypeBuiltinGlob ("->" TypeGlob)? - TypeBuiltinGlob = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | "_" | unit | tupleEmpty | TensorGlob | TupleGlob + TypeBuiltinGlob = #("int" | "cell" | "slice" | "builder" | "cont" | "tuple" | "_") ~#rawId --simple + | unit | tupleEmpty | TensorGlob | TupleGlob - TensorGlob = "(" ListOf ")" - TupleGlob = "[" ListOf "]" + TensorGlob = "(" NonemptyListOf ")" + TupleGlob = "[" NonemptyListOf "]" // // Definitions of constants @@ -68,11 +68,12 @@ FunC { // Function return types TypeReturn = TypeBuiltinReturn (&#whiteSpace "->" &#whiteSpace TypeReturn)? - TypeBuiltinReturn = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | "_" | unit | tupleEmpty | TensorReturn | TupleReturn | id + TypeBuiltinReturn = id + | "int" | "cell" | "slice" | "builder" | "cont" | "tuple" + | "_" | unit | tupleEmpty | TensorReturn | TupleReturn - TensorReturn = "(" ListOf ")" - TupleReturn = "[" ListOf "]" + TensorReturn = "(" NonemptyListOf ")" + TupleReturn = "[" NonemptyListOf "]" // Function parameters Parameters = "(" ListOf ")" @@ -82,11 +83,12 @@ FunC { // Function parameter types TypeParameter = TypeBuiltinParameter (&#whiteSpace "->" &#whiteSpace TypeParameter)? - TypeBuiltinParameter = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | unit | tupleEmpty | TensorParameter | TupleParameter | id + TypeBuiltinParameter = id + | "int" | "cell" | "slice" | "builder" | "cont" | "tuple" + | unit | tupleEmpty | TensorParameter | TupleParameter - TensorParameter = "(" ListOf ")" - TupleParameter = "[" ListOf "]" + TensorParameter = "(" NonemptyListOf ")" + TupleParameter = "[" NonemptyListOf "]" // Called "specifiers" in https://docs.ton.org/develop/func/functions#specifiers FunctionAttribute = "impure" | "inline_ref" | "inline" | MethodIdValue | "method_id" @@ -137,7 +139,7 @@ FunC { "catch" &#whiteSpace "(" (unusedId | id) "," (unusedId | id) ")" &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" - StatementExpression = Expression &#whiteSpace ";" + StatementExpression = Expression ";" // // Expressions, ordered by precedence (from lowest to highest), @@ -197,14 +199,25 @@ FunC { | ExpressionVarFun // parse_expr90 - ExpressionVarFun = - | ExpressionPrimary (&("(" | "[" | Id) ExpressionPrimary)+ --functionCall - | Type (&("(" | "[" | Id) ExpressionPrimary) --polymorphVarDecl - // hole in TypeUniform - | TypeUniform (&("(" | "[" | Id) ExpressionPrimary) --uniformVarDecl - | ExpressionPrimary + ExpressionVarFun = | ExpressionVarDecl | ExpressionFunCall | ExpressionPrimary + // Variable declarations + ExpressionVarDecl = TypeVarDecl ExpressionVarDeclPart + ExpressionVarDeclPart = id + | unusedId + | ExpressionTensor + | ExpressionTuple + + // Function calls + ExpressionFunCall = (functionId | ExpressionParens) ExpressionArgument+ + + ExpressionParens = "(" ExpressionFunCall ")" + ExpressionArgument = functionId + | unit + | ExpressionTensor + | tupleEmpty + | ExpressionTuple // parse_expr100 ExpressionPrimary = @@ -212,56 +225,24 @@ FunC { | ExpressionTensor | tupleEmpty | ExpressionTuple - | hole - | typePrimitive + | primitive | integerLiteral - | booleanExpression - | nilExpression | stringLiteral - | id - + | functionId + | unusedId - restrictedId = ~((hole | integerLiteral | delimiter | operator) ~id) id - restrictedFunctionId = ~((hole | integerLiteral | delimiter | operator) ~functionId) functionId ExpressionTensor = "(" ListOf ")" ExpressionTuple = "[" ListOf "]" + // Variable declaration types + TypeVarDecl = TypeBuiltinVarDecl (&#whiteSpace "->" &#whiteSpace TypeVarDecl)? - // - // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical - // - - // Argument = id - - // Mapped or unmapped builtin types or type variables, - // where "mapped" refers to: https://docs.ton.org/develop/func/types#functional-type - // and type variables refer to parametric polymorphism with `forall` - Type = TypeBuiltin "->" Type --mapped - | TypeBuiltin --builtin - // | Id --var - // builtin -> primitive - typePrimitive = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - - // Builtin types - TypeBuiltin = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | Tensor | Tuple | unit | tupleEmpty | restrictedId - // | Id - + TypeBuiltinVarDecl = #("int" | "cell" | "slice" | "builder" | "cont" | "tuple" | hole) ~#rawId --simple + | unit | tupleEmpty | TensorVarDecl | TupleVarDecl + // TODO: return `| id`, differentiate between function calls and variable declarations during syntax analysis and AST construction (through careful use of declared type variables in `forall`) - // Non-functional composite builtin types - Tensor = "(" ListOf ")" - Tuple = "[" ListOf "]" - - // Non-polymorphic, uniform types - TypeUniform = TypeBuiltinUniform "->" TypeUniform --mapped - | TypeBuiltinUniform --builtin - - TypeBuiltinUniform = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | hole | TensorUniform | TupleUniform | unit | tupleEmpty - - TensorUniform = "(" ListOf ")" - - TupleUniform = "[" ListOf "]" + TensorVarDecl = "(" NonemptyListOf ")" + TupleVarDecl = "[" NonemptyListOf "]" // // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical @@ -269,33 +250,44 @@ FunC { // Special types or values hole = "_" | "var" ~id - unit = "()" - tupleEmpty = "[]" - - // Operators and delimiters - operator = ("+" | "-" | "*" | "/%" | "/" | "%" - | "~/" | "^/" | "~%" | "^%") --arithOperator - | ("<=>" | "<=" | "<" | ">=" | ">" | "!=" | "==") --comparisonOperator - | ("~>>" | "~" | "^>>" | "^" | "&" | "|" | "<<" | ">>") --bitwiseOperator - | ("=" | "+=" | "-=" | "*=" | "/=" | "%=" | "~>>=" - | "~/=" | "~%=" | "^>>=" | "^/=" | "^%=" | "^=" - | "<<=" | ">>=" | "&=" | "|=") --assignOperator - delimiter = "{" | "}" | "?" | ":" - + unit = "(" whiteSpace* ")" + tupleEmpty = "[" whiteSpace* "]" + primitive = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" + + // Operators and delimiters, order matters + operator = + | "!=" + | "%=" | "%" + | "&=" | "&" + | "*=" | "*" + | "+=" | "+" + | "-=" | "-" + | "/%" | "/=" | "/" + | "<=>" + | "<<=" | "<<" | "<=" | "<" + | "==" | "=" + | ">>=" | ">>" | ">=" | ">" + | "^>>=" | "^>>" | "^=" | "^/=" | "^/" | "^%=" | "^%" | "^" + | "|=" | "|" + | "~>>=" | "~>>" | "~/=" | "~/" | "~%" | "~" + delimiter = "->" | "{" | "}" | "?" | ":" // Function identifiers - functionId = ~("\"" | "{-") ("." | "~")? rawId - methodId = ~("\"" | "{-") ("." | "~") rawId + functionId = ~("\"" | "{-") ("." | "~")? ~((hole | integerLiteral | delimiter | operator | primitive) ~rawId) rawId + + // Method identifiers + methodId = ~("\"" | "{-") ("." | "~") ~((hole | integerLiteral | delimiter | operator | primitive) ~rawId) rawId // Identifiers, with invalidation (keywords, numbers, etc.) during syntax analysis // — this makes this parser closer to the C++ one, and also improves error messages + id = ~("\"" | "{-" | "." | "~") ~((hole | integerLiteral | delimiter | operator | primitive) ~rawId) rawId - // TODO: re-work everything here!!!! Literally everything! - rawId = quotedId | plainId - - id = ~("\"" | "{-" | "." | "~") rawId + // Contents of any identifiers + rawId = quotedId | operatorId | plainId + // Kinds quotedId = "`" (~("`" | "\n") any)+ "`" + operatorId = "_" plainId "_" plainId = (~(whiteSpace | "(" | ")" | "[" | "]" | "," | "." | ";" | "~") any)+ // Unused identifiers @@ -320,11 +312,9 @@ FunC { // digit is defined in Ohm's built-in rules as: digit = "0".."9" integerLiteralDec = digit+ - // Boolean expressions (builtins.cpp) - booleanExpression = "true" | "false" - + // TODO: put into syntax analysis + // Booleans (builtins.cpp) // Nil expressions (builtins.cpp) - nilExpression = "nil" | "Nil" // Strings stringLiteral = "\"\"\"" (~"\"\"\"" any)* "\"\"\"" stringType? --multiLine From 6e86d5e77fe7e7d2770d10507a0fad96dba3e104 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Wed, 7 Aug 2024 22:33:02 +0200 Subject: [PATCH 100/162] feat(func-parser): worked through most of the types, got to complete the AST construction (mostly typing stuff in), and we're done! --- src/func/grammar-test/statements.fc | 3 + src/func/grammar.ohm | 43 +-- src/func/grammar.ts | 561 ++++++++++++++++++++++++---- 3 files changed, 509 insertions(+), 98 deletions(-) diff --git a/src/func/grammar-test/statements.fc b/src/func/grammar-test/statements.fc index bc748f8d9..0ff788109 100644 --- a/src/func/grammar-test/statements.fc +++ b/src/func/grammar-test/statements.fc @@ -34,6 +34,9 @@ int return_stmt'() { return 42; } if 0 { ; ; } elseifnot 0 { ; ; } ifnot 1 { ; ; } elseif 1 { ; ; } ifnot 1 { ; ; } elseifnot 0 { ; ; } + + if 0 { ; ; } elseif 0 { ; ; } else { ; ; } + ifnot 1 { ; ; } elseifnot 1 { ; ; } else { ; ; } } ;; repeat diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 53abaf9f3..e59fadadb 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -109,35 +109,28 @@ FunC { | StatementTryCatch | StatementExpression - StatementReturn = "return" &#whiteSpace Expression ";" + StatementReturn = "return" Expression ";" - StatementBlock = "{" &#whiteSpace Statement* &#whiteSpace "}" + StatementBlock = "{" Statement* "}" StatementEmpty = ";" - StatementCondition = ("ifnot" | "if") &#whiteSpace - Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" &#whiteSpace - ("elseifnot" | "elseif") &#whiteSpace - Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" --withElseCondition + StatementCondition = ("ifnot" | "if") Expression "{" Statement* "}" + ("elseifnot" | "elseif") Expression "{" Statement* "}" + ("else" "{" Statement* "}")? --elseif + | ("ifnot" | "if") Expression "{" Statement* "}" + ("else" "{" Statement* "}")? --if - | ("ifnot" | "if") &#whiteSpace - Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" &#whiteSpace - "else" &#whiteSpace - "{" &#whiteSpace Statement* &#whiteSpace "}" --withElse + StatementRepeat = "repeat" Expression "{" Statement* "}" - | ("ifnot" | "if") &#whiteSpace - Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" --noElse + StatementUntil = "do" "{" Statement* "}" "until" Expression ";" - StatementRepeat = "repeat" &#whiteSpace Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" + StatementWhile = "while" Expression "{" Statement* "}" - StatementUntil = "do" &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" &#whiteSpace "until" &#whiteSpace Expression ";" - - StatementWhile = "while" &#whiteSpace Expression &#whiteSpace "{" &#whiteSpace Statement* &#whiteSpace "}" - - StatementTryCatch = "try" &#whiteSpace - "{" &#whiteSpace Statement* &#whiteSpace "}" &#whiteSpace - "catch" &#whiteSpace "(" (unusedId | id) "," (unusedId | id) ")" &#whiteSpace - "{" &#whiteSpace Statement* &#whiteSpace "}" + StatementTryCatch = "try" + "{" Statement* "}" + "catch" "(" (unusedId | id) "," (unusedId | id) ")" + "{" Statement* "}" StatementExpression = Expression ";" @@ -225,7 +218,6 @@ FunC { | ExpressionTensor | tupleEmpty | ExpressionTuple - | primitive | integerLiteral | stringLiteral | functionId @@ -251,6 +243,7 @@ FunC { // Special types or values hole = "_" | "var" ~id unit = "(" whiteSpace* ")" + // (not a separate type, added purely for convenience) tupleEmpty = "[" whiteSpace* "]" primitive = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" @@ -275,7 +268,7 @@ FunC { // Function identifiers functionId = ~("\"" | "{-") ("." | "~")? ~((hole | integerLiteral | delimiter | operator | primitive) ~rawId) rawId - // Method identifiers + // Method identifiers (not a separate type, added purely for convenience) methodId = ~("\"" | "{-") ("." | "~") ~((hole | integerLiteral | delimiter | operator | primitive) ~rawId) rawId // Identifiers, with invalidation (keywords, numbers, etc.) during syntax analysis @@ -312,10 +305,6 @@ FunC { // digit is defined in Ohm's built-in rules as: digit = "0".."9" integerLiteralDec = digit+ - // TODO: put into syntax analysis - // Booleans (builtins.cpp) - // Nil expressions (builtins.cpp) - // Strings stringLiteral = "\"\"\"" (~"\"\"\"" any)* "\"\"\"" stringType? --multiLine | "\"" (~"\"" any)* "\"" stringType? --singleLine diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 66648d165..414df7077 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -128,18 +128,22 @@ function unwrapOptNode( // // FIXME: Those are directly matching contents of the grammar.ohm -// TODO: Unite with syntax.ts and refactor dependant files +// FIXME: Unite with syntax.ts and refactor dependant files // FIXME: Would need help once parser is done on my side :) // -type FuncAstNode = +export type FuncAstNode = | FuncAstModule | FuncAstPragma | FuncAstInclude | FuncAstModuleItem + | FuncAstStatement + | FuncAstExpression + | FuncAstFunctionId + | FuncAstId | FuncAstComment; -type FuncAstModule = { +export type FuncAstModule = { kind: "module"; pragmas: FuncAstPragma[]; includes: FuncAstInclude[]; @@ -154,7 +158,7 @@ type FuncAstModule = { /** * #pragma ... */ -type FuncAstPragma = +export type FuncAstPragma = | FuncAstPragmaLiteral | FuncAstPragmaVersionRange | FuncAstPragmaVersionString; @@ -162,7 +166,7 @@ type FuncAstPragma = /** * #pragma something-something-something; */ -type FuncAstPragmaLiteral = { +export type FuncAstPragmaLiteral = { kind: "pragma_literal"; literal: string; // "allow-post-modification" | "compute-asm-ltr"; @@ -175,7 +179,7 @@ type FuncAstPragmaLiteral = { * * #pragma (version | not-version) semverRange; */ -type FuncAstPragmaVersionRange = { +export type FuncAstPragmaVersionRange = { kind: "pragma_version_range"; allow: boolean; range: FuncAstVersionRange; @@ -185,7 +189,7 @@ type FuncAstPragmaVersionRange = { /** * #pragma test-version-set "exact.version.semver"; */ -type FuncAstPragmaVersionString = { +export type FuncAstPragmaVersionString = { kind: "pragma_version_string"; version: string; loc: FuncSrcInfo; @@ -194,7 +198,7 @@ type FuncAstPragmaVersionString = { /** * #include "path/to/file"; */ -type FuncAstInclude = { +export type FuncAstInclude = { kind: "include"; path: string; loc: FuncSrcInfo; @@ -204,14 +208,14 @@ type FuncAstInclude = { // Top-level, module items // -type FuncAstModuleItem = +export type FuncAstModuleItem = | FuncAstGlobalVariablesDeclaration | FuncAstConstantsDefinition; /** * global ..., ...; */ -type FuncAstGlobalVariablesDeclaration = { +export type FuncAstGlobalVariablesDeclaration = { kind: "global_variables_declaration"; globals: FuncAstGlobalVariable[]; loc: FuncSrcInfo; @@ -220,7 +224,7 @@ type FuncAstGlobalVariablesDeclaration = { /** * nonVarType? id */ -type FuncAstGlobalVariable = { +export type FuncAstGlobalVariable = { kind: "global_variable"; ty: FuncAstTypeUniform | undefined; name: FuncAstId; @@ -230,39 +234,416 @@ type FuncAstGlobalVariable = { /** * const ..., ...; */ -type FuncAstConstantsDefinition = { +export type FuncAstConstantsDefinition = { kind: "constants_definition"; constants: FuncAstConstant[]; loc: FuncSrcInfo; -} +}; /** * (slice | int)? id = Expression */ -type FuncAstConstant = { +export type FuncAstConstant = { kind: "constant"; ty: "slice" | "int" | undefined; name: FuncAstId; value: FuncAstExpression; loc: FuncSrcInfo; -} +}; // // Statements -// TODO // -type FuncAstStatement = - | {}; +export type FuncAstStatement = + | FuncAstStatementReturn + | FuncAstStatementBlock + | FuncAstStatementEmpty + | FuncAstStatementCondition + | FuncAstStatementRepeat + | FuncAstStatementUntil + | FuncAstStatementWhile + | FuncAstStatementTryCatch + | FuncAstStatementExpression; + +/** + * return Expression; + */ +export type FuncAstStatementReturn = { + kind: "statement_return"; + expression: FuncAstExpression; + loc: FuncSrcInfo; +}; + +/** + * { ... } + */ +export type FuncAstStatementBlock = { + kind: "statement_block"; + statements: FuncAstStatement[]; + loc: FuncSrcInfo; +}; + +/** + * ; + */ +export type FuncAstStatementEmpty = { + kind: "statement_empty"; + loc: FuncSrcInfo; +}; + +/** + * (if | ifnot) Expression { ... } + * (else { ... })? + * + * or + * + * (if | ifnot) Expression { ... } + * (elseif | elseifnot) Expression { ... } + * (else { ... })? + */ +export type FuncAstStatementCondition = + | FuncAstStatementConditionIf + | FuncAstStatementConditionElseIf; + +/** + * (if | ifnot) Expression { ... } (else { ... })? + * + * @field positive If true, then it represents `if`. If false, it's an `ifnot`. + * @field condition Expression + * @field consequences Left branch (after `if`), truthy case (or falsy in case of `ifnot`) + * @field alternatives Optional right branch (after `else`), falsy case (or truthy in case of `ifnot`) + */ +export type FuncAstStatementConditionIf = { + kind: "statement_condition_if"; + // if | ifnot + positive: boolean; + // expression + condition: FuncAstExpression; + // left branch { ... } + consequences: FuncAstStatement[]; + // optional right branch { ... } + alternatives: undefined | FuncAstStatement[]; + loc: FuncSrcInfo; +}; + +/** + * (if | ifnot) Expression { ... } (elseif | elseifnot) Expression { ... } (else { ... })? + * + * @field positiveIf If true, then it represents `if`. If false, it's an `ifnot`. + * @field conditionIf Expression + * @field consequencesIf Branch after `if`, truthy case (or falsy in case of `ifnot`) + * @field positiveElseif If true, then it represents `elseif`. If false, it's an `elseifnot`. + * @field consequencesElseif Branch after `elseif`, truthy case (or falsy in case of `elseifnot`) + * @field alternativesElseif Optional third branch (after `else`), falsy case (or truthy in case of `elseifnot`) + */ +export type FuncAstStatementConditionElseIf = { + kind: "statement_condition_elseif"; + // if | ifnot + positiveIf: boolean; + // expression after if | ifnot + conditionIf: FuncAstExpression; + // branch after if | ifnot { ... } + consequencesIf: FuncAstStatement[]; + // elseif | elseifnot + positiveElseif: boolean; + // branch after elseif | elseifnot { ... } + consequencesElseif: FuncAstStatement[]; + // optional third branch after else { ... } + alternativesElseif: undefined | FuncAstStatement[]; + loc: FuncSrcInfo; +}; + +/** + * repeat Expression { ... } + */ +export type FuncAstStatementRepeat = { + kind: "statement_repeat"; + iterations: FuncAstExpression; + statements: FuncAstStatement[]; + loc: FuncSrcInfo; +}; + +/** + * do { ... } until Expression; + */ +export type FuncAstStatementUntil = { + kind: "statement_until"; + statements: FuncAstStatement[]; + condition: FuncAstExpression; + loc: FuncSrcInfo; +}; + +/** + * while Expression { ... } + */ +export type FuncAstStatementWhile = { + kind: "statement_while"; + condition: FuncAstExpression; + statements: FuncAstStatement[]; + loc: FuncSrcInfo; +}; + +/** + * try { ... } catch (id, id) { ... } + */ +export type FuncAstStatementTryCatch = { + kind: "statement_try_catch"; + statementsTry: FuncAstStatement[]; + statementsCatch: FuncAstStatement[]; + catchExceptionName: FuncAstId; + catchExitCodeName: FuncAstId; + loc: FuncSrcInfo; +}; +/** + * Expression; + */ +export type FuncAstStatementExpression = { + kind: "statement_expression"; + expression: FuncAstExpression; + loc: FuncSrcInfo; +}; // -// Expressions -// TODO +// Expressions, ordered by precedence (from lowest to highest), +// with comments referencing exact function names in C++ code of FunC's parser: +// https://github.com/ton-blockchain/ton/blob/master/crypto/func/parse-func.cpp // -type FuncAstExpression = - | {}; +/** + * parse_expr + */ +export type FuncAstExpression = + | FuncAstExpressionAssign + | FuncAstExpressionConditional + | FuncAstExpressionCompare + | FuncAstExpressionBitwiseShift + | FuncAstExpressionAddBitwise + | FuncAstExpressionMulBitwise + | FuncAstExpressionUnary + | FuncAstExpressionMethodCallChain + | FuncAstExpressionVarFun + | FuncAstExpressionPrimary; + +/** + * parse_expr10 + */ +export type FuncAstExpressionAssign = { + kind: "expression_assign"; + left: FuncAstExpressionConditional; + op: + | "=" + | "+=" + | "-=" + | "*=" + | "/=" + | "%=" + | "~/=" + | "~%=" + | "^/=" + | "^%=" + | "&=" + | "|=" + | "^=" + | "<<=" + | ">>=" + | "~>>=" + | "^>>="; + right: FuncAstExpressionConditional; + loc: FuncSrcInfo; +}; + +/** + * parse_expr13 + */ +export type FuncAstExpressionConditional = { + kind: "expression_conditional"; + condition: FuncAstExpressionCompare; + consequence: FuncAstExpression; + alternative: FuncAstExpressionConditional; + loc: FuncSrcInfo; +}; + +/** + * parse_expr15 + */ +export type FuncAstExpressionCompare = { + kind: "expression_compare"; + left: FuncAstExpressionBitwiseShift; + op: "==" | "<=>" | "<=" | "<" | ">=" | ">" | "!="; + right: FuncAstExpressionBitwiseShift; + loc: FuncSrcInfo; +}; + +/** + * parse_expr17 + */ +export type FuncAstExpressionBitwiseShift = { + kind: "expression_bitwise_shift"; + left: FuncAstExpressionAddBitwise; + op: "<<" | ">>" | "~>>" | "^>>"; + right: FuncAstExpressionAddBitwise; + loc: FuncSrcInfo; +}; + +/** + * parse_expr20 + */ +export type FuncAstExpressionAddBitwise = { + kind: "expression_add_bitwise"; + negateLeft: boolean; + left: FuncAstExpressionMulBitwise; + op: "+" | "-" | "|" | "^"; + right: FuncAstExpressionMulBitwise; + loc: FuncSrcInfo; +}; + +/** + * parse_expr30 + */ +export type FuncAstExpressionMulBitwise = { + kind: "expression_mul_bitwise"; + left: FuncAstExpressionUnary; + op: "*" | "/%" | "/" | "%" | "~/" | "~%" | "^/" | "^%" | "&"; + right: FuncAstExpressionUnary; + loc: FuncSrcInfo; +}; + +/** + * parse_expr75 + */ +export type FuncAstExpressionUnary = { + kind: "expression_unary"; + op: "~"; + operand: FuncAstExpressionMethodCallChain; + loc: FuncSrcInfo; +}; + +/** + * parse_expr80 + */ +export type FuncAstExpressionMethodCallChain = { + kind: "expression_method_call_chain"; + object: FuncAstExpressionVarFun; + methods: FuncAstExpressionMethodCall[]; + loc: FuncSrcInfo; +}; + +/** + * methodId ExpressionArgument + */ +export type FuncAstExpressionMethodCall = { + kind: "expression_method_call"; + name: FuncAstFunctionId; + argument: FuncAstExpressionArgument; + loc: FuncSrcInfo; +}; + +export type FuncAstExpressionArgument = + | FuncAstFunctionId + | FuncAstUnit + | FuncAstExpressionTensor + | FuncAstExpressionTuple; + +/** + * ( ExpressionFunctionCall ) + */ +export type FuncAstExpressionParens = FuncAstExpressionFunCall; + +/** + * parse_expr90 + */ +export type FuncAstExpressionVarFun = + | FuncAstExpressionVarDecl + | FuncAstExpressionFunCall + | FuncAstExpressionPrimary; + +/** + * Variable declaration + * + * Type SingleOrMultipleIds + */ +export type FuncAstExpressionVarDecl = { + kind: "expression_var_decl"; + ty: FuncAstType; + names: FuncAstExpressionVarDeclPart; + loc: FuncSrcInfo; +}; + +export type FuncAstExpressionVarDeclPart = + | FuncAstId + | FuncAstExpressionTensor + | FuncAstExpressionTuple; + +/** + * Function call + * + * (functionId | functionCallReturningFunction) Argument+ + */ +export type FuncAstExpressionFunCall = { + kind: "expression_fun_call"; + object: FuncAstFunctionId | FuncAstExpressionParens; + arguments: FuncAstExpressionArgument[]; + loc: FuncSrcInfo; +}; + +/** + * parse_expr100 + */ +export type FuncAstExpressionPrimary = + | FuncAstUnit + | FuncAstExpressionTensor + | FuncAstExpressionTuple + | FuncAstIntegerLiteral + | FuncAstStringLiteral + | FuncAstFunctionId + | FuncAstId; + +/** + * ( Expression, Expression, ... ) + */ +export type FuncAstExpressionTensor = { + kind: "expression_tensor"; + expressions: FuncAstExpression[]; + loc: FuncSrcInfo; +}; + +/** + * [ Expression, Expression, ... ] + */ +export type FuncAstExpressionTuple = { + kind: "expression_tuple"; + expressions: FuncAstExpression[]; + loc: FuncSrcInfo; +}; + +// +// Ternary, binary, unary expression utility sub-types +// + +/** + * Expression ? Expression : Expression + */ +export type FuncAstTernaryExpression = FuncAstExpressionConditional; + +/** + * Expression op Expression + */ +export type FuncAstBinaryExpression = + | FuncAstExpressionAssign + | FuncAstExpressionConditional + | FuncAstExpressionCompare + | FuncAstExpressionBitwiseShift + | FuncAstExpressionAddBitwise + | FuncAstExpressionMulBitwise; + +/** + * op Expression + * + * Note, that there are no unary plus, and unary minus is handled elsewhere! + */ +export type FuncAstUnaryExpression = FuncAstExpressionUnary; // // Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical @@ -271,12 +652,12 @@ type FuncAstExpression = /** * forall type? typeName1, type? typeName2, ... -> */ -type FuncAstForall = FuncAstTypeVar[]; +export type FuncAstForall = FuncAstTypeVar[]; /** * "type"? id */ -type FuncAstTypeVar = { +export type FuncAstTypeVar = { kind: "type_var"; keyword: boolean; ident: FuncAstId; @@ -286,19 +667,19 @@ type FuncAstTypeVar = { /** * (type id, ...) */ -type FuncAstParameters = FuncAstParameter[]; +export type FuncAstParameters = FuncAstParameter[]; /** * Parameters */ -type FuncAstParameter = +export type FuncAstParameter = | FuncAstParameterRegular | FuncAstParameterInferredType; /** * type id */ -type FuncAstParameterRegular = { +export type FuncAstParameterRegular = { kind: "parameter_regular"; ty: FuncAstType; ident: FuncAstId; @@ -308,24 +689,18 @@ type FuncAstParameterRegular = { /** * id */ -type FuncAstParameterInferredType = { +export type FuncAstParameterInferredType = { kind: "parameter_inferred_type"; ident: FuncAstId; loc: FuncSrcInfo; }; /** - * Mapped or unmapped builtin types or type variables + * Builtin types or type variables */ -type FuncAstType = FuncAstTypeMapped | FuncAstTypeBuiltin | FuncAstTypeVar; - -type FuncAstTypeMapped = { - kind: "type_mapped"; - left: FuncAstTypeBuiltin; - right: FuncAstType; -}; +export type FuncAstType = FuncAstTypeBuiltin | FuncAstTypeVar; -type FuncAstTypeBuiltin = { +export type FuncAstTypeBuiltin = { kind: "type_builtin"; value: | "int" @@ -338,27 +713,30 @@ type FuncAstTypeBuiltin = { | FuncAstTuple | FuncAstHole | FuncAstUnit; + mapsTo: undefined | FuncAstType; }; /** (...) */ -type FuncAstTensor = FuncAstType[]; +export type FuncAstTensor = FuncAstType[]; /** [...] */ -type FuncAstTuple = FuncAstType[]; +export type FuncAstTuple = FuncAstType[]; /** * Non-polymorphic, uniform types */ -type FuncAstTypeUniform = FuncAstTypeUniformMapped | FuncAstTypeUniformBuiltin; +export type FuncAstTypeUniform = + | FuncAstTypeUniformMapped + | FuncAstTypeUniformBuiltin; -type FuncAstTypeUniformMapped = { +export type FuncAstTypeUniformMapped = { kind: "type_uniform_mapped"; left: FuncAstTypeBuiltin; right: FuncAstType; }; -type FuncAstTypeUniformBuiltin = { +export type FuncAstTypeUniformBuiltin = { kind: "type_uniform_builtin"; value: | "int" @@ -374,54 +752,86 @@ type FuncAstTypeUniformBuiltin = { }; /** (...) */ -type FuncAstTensorUniform = FuncAstTypeUniform[]; +export type FuncAstTensorUniform = FuncAstTypeUniform[]; /** [...] */ -type FuncAstTupleUniform = FuncAstTypeUniform[]; +export type FuncAstTupleUniform = FuncAstTypeUniform[]; // // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // -type FuncAstHole = { +export type FuncAstHole = { kind: "hole"; value: "_" | "var"; loc: FuncSrcInfo; }; -type FuncAstUnit = { +export type FuncAstUnit = { kind: "unit"; value: "()"; loc: FuncSrcInfo; }; -type FuncAstFunctionId = { + +/** + * Identifier kinds, except for function names, which are a superset of those + */ +export type FuncAstId = + | FuncAstQuotedId + | FuncAstOperatorId + | FuncAstPlainId + | FuncAstUnusedId; + +/** + * Like identifier, but can start with . or ~ + */ +export type FuncAstFunctionId = { kind: "function_id"; value: string; loc: FuncSrcInfo; }; -type FuncAstId = FuncAstIdQuoted | FuncAstIdPlain; +/** + * `anything, except ` or new line` + */ +export type FuncAstQuotedId = { + kind: "quoted_id"; + value: string; + loc: FuncSrcInfo; +}; -type FuncAstIdQuoted = { - kind: "id_quoted"; +/** + * _+_, etc. + */ +export type FuncAstOperatorId = { + kind: "operator_id"; value: string; loc: FuncSrcInfo; }; -type FuncAstIdPlain = { - kind: "id_plain"; +/** + * *magic* + */ +export type FuncAstPlainId = { + kind: "plain_id"; value: string; loc: FuncSrcInfo; }; -type FuncAstUnusedId = { +/** + * _ + */ +export type FuncAstUnusedId = { kind: "unused_id"; value: "_"; loc: FuncSrcInfo; }; -type FuncAstVersionRange = { +/** + * op? decNum (. decNum)? (. decNum)? + */ +export type FuncAstVersionRange = { kind: "version_range"; op: string | undefined; major: bigint; @@ -431,22 +841,29 @@ type FuncAstVersionRange = { }; /** - * -? dec | -? hex + * -? decNum + * or + * -? hexNum */ -type FuncAstIntegerLiteral = { +export type FuncAstIntegerLiteral = { kind: "integer_literal"; value: bigint; loc: FuncSrcInfo; }; -type FuncAstStringLiteral = +/** + * "..."ty? + * or + * """ ... """ty? + */ +export type FuncAstStringLiteral = | FuncAstStringLiteralSingleLine | FuncAstStringLiteralMultiLine; /** * "..."ty? */ -type FuncAstStringLiteralSingleLine = { +export type FuncAstStringLiteralSingleLine = { kind: "string_singleline"; value: string; ty: undefined | FuncAstStringType; @@ -454,23 +871,23 @@ type FuncAstStringLiteralSingleLine = { }; /** - * """ ... """ty? + * """ ... """ty? */ -type FuncAstStringLiteralMultiLine = { +export type FuncAstStringLiteralMultiLine = { kind: "string_multiline"; value: string; ty: undefined | FuncAstStringType; - // TODO: alignIndent: boolean; - // TODO: trim: boolean; + // Perhaps: alignIndent: boolean; + // Perhaps: trim: boolean; loc: FuncSrcInfo; }; /** * An additional modifier. See: https://docs.ton.org/develop/func/literals_identifiers#string-literals */ -type FuncAstStringType = "s" | "a" | "u" | "h" | "H" | "c"; +export type FuncAstStringType = "s" | "a" | "u" | "h" | "H" | "c"; -type FuncAstWhiteSpace = { +export type FuncAstWhiteSpace = { kind: "whitespace"; value: `\t` | ` ` | `\n` | `\r` | `\u2028` | `\u2029`; }; @@ -480,25 +897,27 @@ type FuncAstWhiteSpace = { * or * {- ... -} */ -type FuncAstComment = FuncAstCommentSingleLine | FuncAstCommentMultiLine; +export type FuncAstComment = FuncAstCommentSingleLine | FuncAstCommentMultiLine; /** - * Doesn't include the starting ;; characters - * * ;; ... + * + * Doesn't include the leading ;; characters TODO: rm */ -type FuncAstCommentSingleLine = { +export type FuncAstCommentSingleLine = { kind: "comment_singleline"; line: string; loc: FuncSrcInfo; }; /** - * `skipCR` — if set to true, skips CR before the next line + * {- ...can be nested... -} * - * {- ... -} + * Doesn't include the leftmost {- and rightmost -} *ODO: rm + * + * @field skipCR If set to true, skips CR before the next line */ -type FuncAstCommentMultiLine = { +export type FuncAstCommentMultiLine = { kind: "comment_multiline"; contents: string; skipCR: boolean; From 148275455017a19749d4868d0cf88ed07fcb0582 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:41:10 +0200 Subject: [PATCH 101/162] feat(func-parser): 2/3 of the AST --- src/func/grammar.ohm | 24 +- src/func/grammar.ts | 894 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 778 insertions(+), 140 deletions(-) diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index e59fadadb..18d96800a 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -59,6 +59,8 @@ FunC { FunctionDeclaration = FunctionCommonPrefix ";" FunctionDefinition = FunctionCommonPrefix "{" Statement* "}" + + // (not a separate thing, added purely for convenience) FunctionCommonPrefix = Forall? TypeReturn functionId Parameters FunctionAttribute* // forall type1, ..., typeN -> @@ -96,7 +98,7 @@ FunC { | "method_id" "(" stringLiteral ")" --string // - // Statements (with mandatory whitespace padding in most places ) + // Statements (with mandatory whitespace padding in most places) // Statement = StatementReturn @@ -117,9 +119,12 @@ FunC { StatementCondition = ("ifnot" | "if") Expression "{" Statement* "}" ("elseifnot" | "elseif") Expression "{" Statement* "}" - ("else" "{" Statement* "}")? --elseif + ElseBlock? --elseif | ("ifnot" | "if") Expression "{" Statement* "}" - ("else" "{" Statement* "}")? --if + ElseBlock? --if + + // (not a separate statement, added purely for convenience) + ElseBlock = "else" "{" Statement* "}" StatementRepeat = "repeat" Expression "{" Statement* "}" @@ -213,8 +218,7 @@ FunC { | ExpressionTuple // parse_expr100 - ExpressionPrimary = - | unit + ExpressionPrimary = unit | ExpressionTensor | tupleEmpty | ExpressionTuple @@ -241,15 +245,14 @@ FunC { // // Special types or values - hole = "_" | "var" ~id + hole = ("_" | "var") ~id unit = "(" whiteSpace* ")" // (not a separate type, added purely for convenience) tupleEmpty = "[" whiteSpace* "]" primitive = "int" | "cell" | "slice" | "builder" | "cont" | "tuple" // Operators and delimiters, order matters - operator = - | "!=" + operator = "!=" | "?" | ":" | "%=" | "%" | "&=" | "&" | "*=" | "*" @@ -263,7 +266,7 @@ FunC { | "^>>=" | "^>>" | "^=" | "^/=" | "^/" | "^%=" | "^%" | "^" | "|=" | "|" | "~>>=" | "~>>" | "~/=" | "~/" | "~%" | "~" - delimiter = "->" | "{" | "}" | "?" | ":" + delimiter = "->" | "{" | "}" // Function identifiers functionId = ~("\"" | "{-") ("." | "~")? ~((hole | integerLiteral | delimiter | operator | primitive) ~rawId) rawId @@ -280,7 +283,8 @@ FunC { // Kinds quotedId = "`" (~("`" | "\n") any)+ "`" - operatorId = "_" plainId "_" + operatorId = "^"? "_" operator "_" --common + | "~_" --not plainId = (~(whiteSpace | "(" | ")" | "[" | "]" | "," | "." | ";" | "~") any)+ // Unused identifiers diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 414df7077..eafac1699 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -54,7 +54,7 @@ export class FuncError extends Error { } /** - * FunC parser error, which generally occurs when either the sources didn't match the grammar, or the AST couldn't be constructed + * FunC parse error, which generally occurs when either the sources didn't match the grammar, or the AST couldn't be constructed */ export class FuncParseError extends FuncError { constructor(message: string, loc: FuncSrcInfo) { @@ -62,6 +62,15 @@ export class FuncParseError extends FuncError { } } +/** + * FunC syntax error, which occurs when the AST couldn't be constructed based on the obtained parse results + */ +export class FuncSyntaxError extends FuncError { + constructor(message: string, loc: FuncSrcInfo) { + super(message, loc); + } +} + /** * Constructs a location string based on the `sourceInfo` */ @@ -79,7 +88,7 @@ function locationStr(sourceInfo: FuncSrcInfo): string { } /** - * Throws a FunC parse error of the given `path` file + * Throws a FunC parse error occured in the given `path` file */ export function throwFuncParseError( matchResult: MatchResult, @@ -96,6 +105,19 @@ export function throwFuncParseError( ); } +/** + * Throws a FunC syntax error occcured with the given `source` + */ +export function throwFuncSyntaxError( + message: string, + source: FuncSrcInfo, +): never { + throw new FuncSyntaxError( + `${locationStr(source)}${message}\n${source.interval.getLineAndColumnMessage()}`, + source, + ); +} + /** * Temporarily sets `currentFile` to `path`, calls a callback function, then resets `currentValue` * Returns a value produced by a callback function call @@ -121,14 +143,318 @@ export function createSrcInfo(s: Node) { function unwrapOptNode( optional: IterationNode, f: (n: Node) => T, -): T | null { +): T | undefined { const optNode = optional.children[0] as Node | undefined; - return optNode !== undefined ? f(optNode) : null; + return optNode !== undefined ? f(optNode) : undefined; +} + + +const funcBuiltinOperatorFunctions = [ + "_+_", + "_-_", + "-_", + "_*_", + "_/_", + "_~/_", + "_^/_", + "_%_", + "_~%_", + "_^%_", + "_/%_", + "_<<_", + "_>>_", + "_~>>_", + "_^>>_", + "_&_", + "_|_", + "_^_", + "~_", + "^_+=_", + "^_-=_", + "^_*=_", + "^_/=_", + "^_~/=_", + "^_^/=_", + "^_%=_", + "^_~%=_", + "^_^%=_", + "^_<<=_", + "^_>>=_", + "^_~>>=_", + "^_^>>=_", + "^_&=_", + "^_|=_", + "^_^=_", + "_==_", + "_!=_", + "_<_", + "_>_", + "_<=_", + "_>=_", + "_<=>_", +]; + +const funcBuiltinFunctions = [ + "divmod", + "moddiv", + "muldiv", + "muldivr", + "muldivc", + "muldivmod", + "null?", + "throw", + "throw_if", + "throw_unless", + "throw_arg", + "throw_arg_if", + "throw_arg_unless", + "load_int", + "load_uint", + "preload_int", + "preload_uint", + "store_int", + "store_uint", + "load_bits", + "preload_bits", + "int_at", + "cell_at", + "slice_at", + "tuple_at", + "at", + "touch", + "touch2", + "run_method0", + "run_method1", + "run_method2", + "run_method3", +]; + +const funcBuiltinMethods = [ + "~divmod", + "~moddiv", + "~store_int", + "~store_uint", + "~touch", + "~touch2", + "~dump", + "~stdump", +]; + +const funcBuiltinConstants = ["true", "false", "nil", "Nil"]; + +const funcKeywords = [ + "extern", + "global", + "asm", + "impure", + "inline_ref", + "inline", + "auto_apply", + "method_id", + "operator", + "infixl", + "infixr", + "infix", + "const", +]; + +const funcControlKeywords = [ + "return", + "var", + "repeat", + "do", + "while", + "until", + "try", + "catch", + "ifnot", + "if", + "then", + "elseifnot", + "elseif", + "else", +]; + +const funcTypeKeywords = [ + "int", + "cell", + "slice", + "builder", + "cont", + "tuple", + "type", + "forall", +]; + +const funcDirectives = ["#include", "#pragma"]; + +const funcDelimiters = ["->", "{", "}", ",", ".", ";"]; + +const funcOperators = [ + "!=", + "?", + ":", + "%=", + "%", + "&=", + "&", + "*=", + "*", + "+=", + "+", + "-=", + "-", + "/%", + "/=", + "/", + "<=>", + "<<=", + "<<", + "<=", + "<", + "==", + "=", + ">>=", + ">>", + ">=", + ">", + "^>>=", + "^>>", + "^=", + "^/=", + "^/", + "^%=", + "^%", + "^", + "|=", + "|", + "~>>=", + "~>>", + "~/=", + "~/", + "~%", + "~", +]; + +const funcDecIntRegex = /^\-?[0-9]+$/; + +const funcHexIntRegex = /^\-?0x[0-9a-fA-F]+$/; + +/** + * Checks that the given identifier (including the prefix in case of methodId) + * can be used in declarations/definitions, i.e. it's: + * - NOT a builtin operator function + * - NOT a builtin function + * - NOT a builtin method + * - NOT a builtin constant + * - NOT an underscore + */ +function checkDeclaredId(ident: string, loc: FuncSrcInfo, altPrefix?: string): void | never { + // not an operatorId + if (funcBuiltinOperatorFunctions.includes(ident)) { + throwFuncSyntaxError( + `${altPrefix ?? "Declared identifier"} cannot shadow or override a builtin operator function`, + loc, + ); + } + + if (funcBuiltinFunctions.includes(ident)) { + throwFuncSyntaxError( + `${altPrefix ?? "Declared identifier"} cannot shadow or override a builtin function`, + loc, + ); + } + + if (funcBuiltinMethods.includes(ident)) { + throwFuncSyntaxError( + `${altPrefix ?? "Declared identifier"} cannot shadow or override a builtin method`, + loc, + ); + } + + if (funcBuiltinConstants.includes(ident)) { + throwFuncSyntaxError( + `${altPrefix ?? "Declared identifier"} cannot shadow or override a builtin constant`, + loc, + ); + } + + // not an unusedId + if (ident === "_") { + throwFuncSyntaxError( + `${altPrefix ?? "Declared identifier"} cannot be an underscore`, + loc, + ); + } +} + +/** + * Checks that the given identifier is a valid operatorId, i.e. that it actually exists on the list of builtin operator functions + * Unlike other checking functions it doesn't throw, but returns `true`, if identifier is a valid operatorId, and `false` otherwise + */ +function checkOperatorId(ident: string, loc: FuncSrcInfo): boolean { + if (funcBuiltinOperatorFunctions.includes(ident)) { + return true; + } + return false; +} + +/** + * Checks that the given identifier is a valid plainId, i.e. it's: + * - NOT a keyword + * - NOT a control keyword + * - NOT a type keyword + * - NOT a directive + * - NOT a delimiter + * - NOT an operator (without underscores, like operatorId) + * - NOT a number + */ +function checkPlainId(ident: string, loc: FuncSrcInfo, altPrefix?: string): void | never { + if (funcKeywords.includes(ident)) { + throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a keyword`, loc); + } + + if (funcControlKeywords.includes(ident)) { + throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a control keyword`, loc); + } + + if (funcTypeKeywords.includes(ident)) { + throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a type keyword`, loc); + } + + if (funcDirectives.includes(ident)) { + throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a compiler directive`, loc); + } + + if (funcDelimiters.includes(ident)) { + throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a delimiter`, loc); + } + + if (funcOperators.includes(ident)) { + throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be an operator`, loc); + } + + if (ident.match(funcDecIntRegex) !== null || ident.match(funcHexIntRegex) !== null) { + throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be an integer literal`, loc); + } +} + +/** + * Checks that the given identifier is a valid methodId, i.e. it starts with either . or ~ and has some characters after + */ +function checkMethodId(ident: string, loc: FuncSrcInfo): void | never { + if (!(ident.startsWith(".") || ident.startsWith("~"))) { + throwFuncSyntaxError("Identifier doesn't start with ~ or .", loc); + } + + if (ident.length === 1) { + throwFuncSyntaxError("Method identifier cannot be just ~ or .", loc); + } } // -// FIXME: Those are directly matching contents of the grammar.ohm -// FIXME: Unite with syntax.ts and refactor dependant files +// FIXME: Those are matching contents of the grammar.ohm with some minor optimizations for clarity +// FIXME: Pls, unite with syntax.ts and refactor dependent files // FIXME: Would need help once parser is done on my side :) // @@ -139,7 +465,6 @@ export type FuncAstNode = | FuncAstModuleItem | FuncAstStatement | FuncAstExpression - | FuncAstFunctionId | FuncAstId | FuncAstComment; @@ -156,7 +481,7 @@ export type FuncAstModule = { // /** - * #pragma ... + * #pragma ...; */ export type FuncAstPragma = | FuncAstPragmaLiteral @@ -168,8 +493,7 @@ export type FuncAstPragma = */ export type FuncAstPragmaLiteral = { kind: "pragma_literal"; - literal: string; - // "allow-post-modification" | "compute-asm-ltr"; + literal: "allow-post-modification" | "compute-asm-ltr"; loc: FuncSrcInfo; }; @@ -191,7 +515,7 @@ export type FuncAstPragmaVersionRange = { */ export type FuncAstPragmaVersionString = { kind: "pragma_version_string"; - version: string; + version: FuncAstStringLiteral; loc: FuncSrcInfo; }; @@ -200,7 +524,7 @@ export type FuncAstPragmaVersionString = { */ export type FuncAstInclude = { kind: "include"; - path: string; + path: FuncAstStringLiteral; loc: FuncSrcInfo; }; @@ -210,7 +534,10 @@ export type FuncAstInclude = { export type FuncAstModuleItem = | FuncAstGlobalVariablesDeclaration - | FuncAstConstantsDefinition; + | FuncAstConstantsDefinition + | FuncAstAsmFunctionDefinition + | FuncAstFunctionDeclaration + | FuncAstFunctionDefinition; /** * global ..., ...; @@ -222,12 +549,14 @@ export type FuncAstGlobalVariablesDeclaration = { }; /** - * nonVarType? id + * Note, that the type here cannot be polymorphic, i.e. a type variable + * + * nonVarType? (quotedId | plainId) */ export type FuncAstGlobalVariable = { kind: "global_variable"; - ty: FuncAstTypeUniform | undefined; - name: FuncAstId; + ty: FuncAstType | undefined; + name: FuncAstQuotedId | FuncAstPlainId; loc: FuncSrcInfo; }; @@ -241,16 +570,127 @@ export type FuncAstConstantsDefinition = { }; /** - * (slice | int)? id = Expression + * (slice | int)? (quotedId | plainId) = Expression */ export type FuncAstConstant = { kind: "constant"; ty: "slice" | "int" | undefined; - name: FuncAstId; + name: FuncAstQuotedId | FuncAstPlainId; value: FuncAstExpression; loc: FuncSrcInfo; }; +/** + * Note, that name cannot be an unusedId + * + * Forall? TypeReturn functionId Parameters FunctionAttribute* "asm" AsmArrangement? stringLiteral+; + */ +export type FuncAstAsmFunctionDefinition = { + kind: "asm_function_definition"; + forall: FuncAstForall | undefined; + returnTy: FuncAstType; + name: FuncAstId; + parameters: FuncAstParameter[]; + attributes: FuncAstFunctionAttribute[]; + arrangement: FuncAstAsmArrangement | undefined; + asmStrings: FuncAstStringLiteral[]; + loc: FuncSrcInfo; +}; + +/** + * Notice, that integers must be unsigned and decimal + * Notice, that either arguments, returns or both must be defined, i.e. () is prohibited + * + * (id+) + * or + * (-> integerLiteralDec+) + * or + * (id+ -> integerLiteralDec+) + */ +export type FuncAstAsmArrangement = { + kind: "asm_arrangement_arguments"; + arguments: FuncAstId[] | undefined; + returns: FuncAstIntegerLiteral[] | undefined; + loc: FuncSrcInfo; +}; + +/** + * Note, that name cannot be an unusedId + * + * Forall? TypeReturn functionId Parameters FunctionAttribute*; + */ +export type FuncAstFunctionDeclaration = { + kind: "function_declaration"; + forall: FuncAstForall | undefined; + returnTy: FuncAstType; + name: FuncAstId; + parameters: FuncAstParameter[]; + attributes: FuncAstFunctionAttribute[]; + loc: FuncSrcInfo; +}; + +/** + * Note, that name cannot be an unusedId + * + * Forall? TypeReturn functionId Parameters FunctionAttribute* { ... } + */ +export type FuncAstFunctionDefinition = { + kind: "function_definition"; + forall: FuncAstForall | undefined; + returnTy: FuncAstType; + name: FuncAstId; + parameters: FuncAstParameter[]; + attributes: FuncAstFunctionAttribute[]; + statements: FuncAstStatement[]; + loc: FuncSrcInfo; +}; + +/** + * forall (type? typeName1, type? typeName2, ...) -> + */ +export type FuncAstForall = { + kind: "forall"; + tyVars: FuncAstTypeVar[]; + loc: FuncSrcInfo; +}; + +/** + * Note, that the "type" keyword prior to identifier can only occur in `forall` declarations + * + * "type"? id + */ +export type FuncAstTypeVar = { + kind: "type_var"; + keyword: boolean; + name: FuncAstId; + loc: FuncSrcInfo; +}; + +/** + * Type? Id + */ +export type FuncAstParameter = { + kind: "parameter"; + ty: FuncAstType | undefined; + name: FuncAstId; + loc: FuncSrcInfo; +}; + +/** + * Called "specifiers" in https://docs.ton.org/develop/func/functions#specifiers + * + * impure | inline_ref | inline | method_id ("(" Integer | String ")")? + */ +export type FuncAstFunctionAttribute = + | { kind: "function_attribute_impure"; loc: FuncSrcInfo } + | { kind: "function_attribute_inline_ref"; loc: FuncSrcInfo } + | { kind: "function_attribute_inline"; loc: FuncSrcInfo } + | { + kind: "function_attribute_method_id"; + value: FuncAstIntegerLiteral | FuncAstStringLiteral | undefined; + loc: FuncSrcInfo; + }; + // // Statements // @@ -323,7 +763,7 @@ export type FuncAstStatementConditionIf = { // left branch { ... } consequences: FuncAstStatement[]; // optional right branch { ... } - alternatives: undefined | FuncAstStatement[]; + alternatives: FuncAstStatement[] | undefined; loc: FuncSrcInfo; }; @@ -334,6 +774,7 @@ export type FuncAstStatementConditionIf = { * @field conditionIf Expression * @field consequencesIf Branch after `if`, truthy case (or falsy in case of `ifnot`) * @field positiveElseif If true, then it represents `elseif`. If false, it's an `elseifnot`. + * @field conditionElseif Expression * @field consequencesElseif Branch after `elseif`, truthy case (or falsy in case of `elseifnot`) * @field alternativesElseif Optional third branch (after `else`), falsy case (or truthy in case of `elseifnot`) */ @@ -347,10 +788,12 @@ export type FuncAstStatementConditionElseIf = { consequencesIf: FuncAstStatement[]; // elseif | elseifnot positiveElseif: boolean; + // expression after elseif | elseifnot + conditionElseif: FuncAstExpression; // branch after elseif | elseifnot { ... } consequencesElseif: FuncAstStatement[]; // optional third branch after else { ... } - alternativesElseif: undefined | FuncAstStatement[]; + alternativesElseif: FuncAstStatement[] | undefined; loc: FuncSrcInfo; }; @@ -390,9 +833,9 @@ export type FuncAstStatementWhile = { export type FuncAstStatementTryCatch = { kind: "statement_try_catch"; statementsTry: FuncAstStatement[]; - statementsCatch: FuncAstStatement[]; catchExceptionName: FuncAstId; catchExitCodeName: FuncAstId; + statementsCatch: FuncAstStatement[]; loc: FuncSrcInfo; }; @@ -423,6 +866,10 @@ export type FuncAstExpression = | FuncAstExpressionMulBitwise | FuncAstExpressionUnary | FuncAstExpressionMethodCallChain + // | FuncAstExpressionMethodCall + // expressionparens + // varfunpart + // expressionargument | FuncAstExpressionVarFun | FuncAstExpressionPrimary; @@ -535,13 +982,13 @@ export type FuncAstExpressionMethodCallChain = { */ export type FuncAstExpressionMethodCall = { kind: "expression_method_call"; - name: FuncAstFunctionId; + name: FuncAstMethodId; argument: FuncAstExpressionArgument; loc: FuncSrcInfo; }; export type FuncAstExpressionArgument = - | FuncAstFunctionId + | FuncAstMethodId | FuncAstUnit | FuncAstExpressionTensor | FuncAstExpressionTuple; @@ -556,8 +1003,7 @@ export type FuncAstExpressionParens = FuncAstExpressionFunCall; */ export type FuncAstExpressionVarFun = | FuncAstExpressionVarDecl - | FuncAstExpressionFunCall - | FuncAstExpressionPrimary; + | FuncAstExpressionFunCall; /** * Variable declaration @@ -579,11 +1025,11 @@ export type FuncAstExpressionVarDeclPart = /** * Function call * - * (functionId | functionCallReturningFunction) Argument+ + * (methodId | functionCallReturningFunction) Argument+ */ export type FuncAstExpressionFunCall = { kind: "expression_fun_call"; - object: FuncAstFunctionId | FuncAstExpressionParens; + object: FuncAstMethodId | FuncAstExpressionParens; arguments: FuncAstExpressionArgument[]; loc: FuncSrcInfo; }; @@ -597,7 +1043,6 @@ export type FuncAstExpressionPrimary = | FuncAstExpressionTuple | FuncAstIntegerLiteral | FuncAstStringLiteral - | FuncAstFunctionId | FuncAstId; /** @@ -646,60 +1091,19 @@ export type FuncAstBinaryExpression = export type FuncAstUnaryExpression = FuncAstExpressionUnary; // -// Miscellaneous syntactic rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical +// Types // /** - * forall type? typeName1, type? typeName2, ... -> + * Builtin types, type variables or combinations of, with optional mappings with -> */ -export type FuncAstForall = FuncAstTypeVar[]; - -/** - * "type"? id - */ -export type FuncAstTypeVar = { - kind: "type_var"; - keyword: boolean; - ident: FuncAstId; - loc: FuncSrcInfo; -}; - -/** - * (type id, ...) - */ -export type FuncAstParameters = FuncAstParameter[]; - -/** - * Parameters - */ -export type FuncAstParameter = - | FuncAstParameterRegular - | FuncAstParameterInferredType; - -/** - * type id - */ -export type FuncAstParameterRegular = { - kind: "parameter_regular"; - ty: FuncAstType; - ident: FuncAstId; - loc: FuncSrcInfo; -}; +export type FuncAstType = FuncAstTypeBuiltin | FuncAstTypeVar; -/** - * id - */ -export type FuncAstParameterInferredType = { - kind: "parameter_inferred_type"; - ident: FuncAstId; - loc: FuncSrcInfo; -}; +// TODO: re-org the types /** - * Builtin types or type variables + * Builtin types, with optional mappings with -> */ -export type FuncAstType = FuncAstTypeBuiltin | FuncAstTypeVar; - export type FuncAstTypeBuiltin = { kind: "type_builtin"; value: @@ -713,87 +1117,72 @@ export type FuncAstTypeBuiltin = { | FuncAstTuple | FuncAstHole | FuncAstUnit; - mapsTo: undefined | FuncAstType; + mapsTo: FuncAstType | undefined; + loc: FuncSrcInfo; }; -/** (...) */ -export type FuncAstTensor = FuncAstType[]; - -/** [...] */ -export type FuncAstTuple = FuncAstType[]; - /** - * Non-polymorphic, uniform types + * (..., ...) */ - -export type FuncAstTypeUniform = - | FuncAstTypeUniformMapped - | FuncAstTypeUniformBuiltin; - -export type FuncAstTypeUniformMapped = { - kind: "type_uniform_mapped"; - left: FuncAstTypeBuiltin; - right: FuncAstType; +export type FuncAstTensor = { + kind: "type_tensor"; + types: FuncAstType[]; + loc: FuncSrcInfo; }; -export type FuncAstTypeUniformBuiltin = { - kind: "type_uniform_builtin"; - value: - | "int" - | "cell" - | "slice" - | "builder" - | "cont" - | "tuple" - | FuncAstTensorUniform - | FuncAstTupleUniform - | FuncAstHole - | FuncAstUnit; +/** + * [..., ...] + */ +export type FuncAstTuple = { + kind: "type_tuple"; + types: FuncAstType[]; + loc: FuncSrcInfo; }; -/** (...) */ -export type FuncAstTensorUniform = FuncAstTypeUniform[]; - -/** [...] */ -export type FuncAstTupleUniform = FuncAstTypeUniform[]; - // // Lexical rules, see: https://ohmjs.org/docs/syntax-reference#syntactic-lexical // +/** + * _ | var + */ export type FuncAstHole = { kind: "hole"; value: "_" | "var"; loc: FuncSrcInfo; }; +/** + * () + */ export type FuncAstUnit = { kind: "unit"; value: "()"; loc: FuncSrcInfo; }; - /** - * Identifier kinds, except for function names, which are a superset of those + * Identifier variations */ export type FuncAstId = + | FuncAstMethodId | FuncAstQuotedId | FuncAstOperatorId | FuncAstPlainId | FuncAstUnusedId; /** - * Like identifier, but can start with . or ~ + * Like quotedId, plainId or operatorId, but starts with . or ~ */ -export type FuncAstFunctionId = { - kind: "function_id"; +export type FuncAstMethodId = { + kind: "method_id"; + prefix: "." | "~"; value: string; loc: FuncSrcInfo; }; /** - * `anything, except ` or new line` + * \`anything, except \` or new line\` */ export type FuncAstQuotedId = { kind: "quoted_id"; @@ -866,7 +1255,7 @@ export type FuncAstStringLiteral = export type FuncAstStringLiteralSingleLine = { kind: "string_singleline"; value: string; - ty: undefined | FuncAstStringType; + ty: FuncAstStringType | undefined; loc: FuncSrcInfo; }; @@ -876,7 +1265,7 @@ export type FuncAstStringLiteralSingleLine = { export type FuncAstStringLiteralMultiLine = { kind: "string_multiline"; value: string; - ty: undefined | FuncAstStringType; + ty: FuncAstStringType | undefined; // Perhaps: alignIndent: boolean; // Perhaps: trim: boolean; loc: FuncSrcInfo; @@ -982,7 +1371,7 @@ semantics.addOperation("astOfPragma", { Pragma_literal(_pragmaKwd, literal, _semicolon) { return { kind: "pragma_literal", - literal: literal.sourceString, + literal: literal.sourceString as ("allow-post-modification" | "compute-asm-ltr"), loc: createSrcInfo(this), }; }, @@ -995,9 +1384,26 @@ semantics.addOperation("astOfPragma", { }; }, Pragma_versionString(_pragmaKwd, _literal, value, _semicolon) { + const versionString = value.astOfExpression() as FuncAstStringLiteral; + + if (versionString.ty !== undefined) { + throwFuncSyntaxError( + "Version string cannot have a string type specified", + createSrcInfo(this), + ); + } + + if ( + versionString.value.match( + /^\"{0,3}[0-9]+(?:\.[0-9]+)?(?:\.[0-9]+)?\"{0,3}$/, + ) === null + ) { + throwFuncSyntaxError("Invalid version string", createSrcInfo(this)); + } + return { kind: "pragma_version_string", - version: value.astOfExpression(), + version: versionString, loc: createSrcInfo(this), }; }, @@ -1038,31 +1444,259 @@ semantics.addOperation("astOfModuleItem", { asmStrings, _semicolon, ) { + const prefix = fnCommonPrefix.astOfFunctionCommonPrefix(); return { kind: "asm_function_definition", - // TODO: fnCommonPrefix, optArrangement + forall: prefix.forall, + returnTy: prefix.returnTy, + name: prefix.name, + parameters: prefix.parameters, + attributes: prefix.attributes, + arrangement: unwrapOptNode(optArrangement, t => t.astOfAsmArrangement()), + asmStrings: asmStrings.children.map(x => x.astOfExpression()), + loc: createSrcInfo(this), }; }, - // FunctionDeclaration(arg0, arg1) { - // // TODO: ... - // }, - // FunctionDefinition(arg0, arg1, arg2, arg3) { - // // TODO: ... + FunctionDeclaration(fnCommonPrefix, _semicolon) { + const prefix = fnCommonPrefix.astOfFunctionCommonPrefix(); + return { + kind: "function_declaration", + forall: prefix.forall, + returnTy: prefix.returnTy, + name: prefix.name, + parameters: prefix.parameters, + attributes: prefix.attributes, + loc: createSrcInfo(this), + }; + + }, + FunctionDefinition(fnCommonPrefix, _lbrace, stmts, _rbrace) { + const prefix = fnCommonPrefix.astOfFunctionCommonPrefix(); + return { + kind: "function_definition", + forall: prefix.forall, + returnTy: prefix.returnTy, + name: prefix.name, + parameters: prefix.parameters, + attributes: prefix.attributes, + statements: stmts.children.map(x => x.astOfStatement()), + loc: createSrcInfo(this), + }; + + }, +}); + +// Statements +semantics.addOperation("astOfStatement", { + Statement(stmt) { + return stmt.astOfStatement(); + }, + StatementReturn(_returnKwd, expr, _semicolon) { + return { + kind: "statement_return", + expression: expr.astOfExpression(), + loc: createSrcInfo(this), + } + }, + StatementBlock(_lbrace, statements, _rbrace) { + return { + kind: "statement_block", + statements: statements.children.map((x) => x.astOfStatement()), + loc: createSrcInfo(this), + }; + }, + StatementEmpty(_semicolon) { + return { + kind: "statement_empty", + loc: createSrcInfo(this), + } + }, + StatementCondition(cond) { + return cond.astOfStatement(); + }, + StatementCondition_if(ifOr, cond, _lbrace, stmts, _rbrace, optElse) { + return { + kind: "statement_condition_if", + positive: ifOr.sourceString === "if" ? true : false, + condition: cond.astOfExpression(), + consequences: stmts.children.map(x => x.astOfStatement()), + alternatives: unwrapOptNode(optElse, t => t.astOfElseBlock()), + loc: createSrcInfo(this), + }; + }, + StatementCondition_elseif(ifOr, condIf, _lbrace, stmtsIf, _rbrace, elseifOr, condElseif, _lbrace2, stmtsElseif, _rbrace2, optElse) { + return { + kind: "statement_condition_elseif", + positiveIf: ifOr.sourceString === "if" ? true : false, + conditionIf: condIf.astOfExpression(), + consequencesIf: stmtsIf.children.map(x => x.astOfStatement()), + positiveElseif: elseifOr.sourceString === "elseif" ? true : false, + conditionElseif: condElseif.astOfExpression(), + consequencesElseif: stmtsElseif.children.map(x => x.astOfStatement()), + alternativesElseif: unwrapOptNode(optElse, t => t.astOfElseBlock()), + loc: createSrcInfo(this), + }; + }, + StatementRepeat(_repeatKwd, expr, _lbrace, stmts, _rbrace) { + return { + kind: "statement_repeat", + iterations: expr.astOfExpression(), + statements: stmts.children.map(x => x.astOfStatement()), + loc: createSrcInfo(this), + }; + }, + StatementUntil(_doKwd, _lbrace, stmts, _rbrace, _untilKwd, cond, _semicolon) { + return { + kind: "statement_until", + statements: stmts.children.map(x => x.astOfStatement()), + condition: cond.astOfExpression(), + loc: createSrcInfo(this), + }; + }, + StatementWhile(_whileKwd, cond, _lbrace, stmts, _rbrace) { + return { + kind: "statement_while", + condition: cond.astOfExpression(), + statements: stmts.children.map(x => x.astOfStatement()), + loc: createSrcInfo(this), + }; + }, + StatementTryCatch(_tryKwd, _lbrace, stmtsTry, _rbrace, _catchKwd, _lparen, exceptionName, _comma, exitCodeName, _rparen, _lbrace2, stmtsCatch, _rbrace2) { + return { + kind: "statement_try_catch", + statementsTry: stmtsTry.children.map(x => x.astOfStatement()), + catchExceptionName: exceptionName.astOfExpression(), + catchExitCodeName: exitCodeName.astOfExpression(), + statementsCatch: stmtsCatch.children.map(x => x.astOfStatement()), + loc: createSrcInfo(this), + }; + }, + StatementExpression(expr, _semicolon) { + return { + kind: "statement_expression", + expression: expr.astOfExpression(), + loc: createSrcInfo(this), + }; + }, +}); + +semantics.addOperation("astOfExpression", { +}); + +// Miscellaneous things +// +// A couple of them don't even have their own dedicated TypeScript types, +// and most were added purely for parsing convenience + +// nonVarType? (quotedId | plainId) +semantics.addOperation("astOfGlobalVariable", { + GlobalVariableDeclaration(optGlobTy, globName) { + const name = globName.astOfExpression() as FuncAstId; + + // if a plainId, then check for validity + if (name.kind === "plain_id") { + checkPlainId(name.value, createSrcInfo(this), "Name of the global variable"); + } + + // check that it can be declared (also excludes operatorId and unusedId) + checkDeclaredId(name.value, createSrcInfo(this), "Name of the global variable"); + + // and that it's not a methodId + if (name.kind === "method_id") { + throwFuncSyntaxError( + "Name of the global variable cannot start with ~ or .", + createSrcInfo(this), + ); + } + + // leaving only quotedId or plainId + return { + kind: "global_variable", + ty: unwrapOptNode(optGlobTy, t => t.astOfType()), + name: name as (FuncAstQuotedId | FuncAstPlainId), + loc: createSrcInfo(this), + }; + }, +}); + +// (slice | int)? id = Expression +semantics.addOperation("astOfConstant", { + ConstantDefinition(optConstTy, constName, _eqSign, expr) { + const ty = unwrapOptNode(optConstTy, t => t.sourceString); + const name = constName.astOfExpression() as FuncAstId; + + // if a plainId, then check for validity + if (name.kind === "plain_id") { + checkPlainId(name.value, createSrcInfo(this), "Name of the constant"); + } + + // check that it can be declared (also excludes operatorId and unusedId) + checkDeclaredId(name.value, createSrcInfo(this), "Name of the constant"); + + // and that it's not a methodId + if (name.kind === "method_id") { + throwFuncSyntaxError( + "Name of the constant cannot start with ~ or .", + createSrcInfo(this), + ); + } + + return { + kind: "constant", + ty: ty !== undefined ? ty as ("slice" | "int") : undefined, + name: name as (FuncAstQuotedId | FuncAstPlainId), + value: expr.astOfExpression(), + loc: createSrcInfo(this), + }; + }, +}); + +/** Not for export, purely for internal convenience reasons */ +type FuncFunctionCommonPrefix = { + forall: FuncAstForall | undefined; + returnTy: FuncAstType; + name: FuncAstId; + parameters: FuncAstParameter[]; + attributes: FuncAstFunctionAttribute[]; +}; + +// Common prefix of all function declarations/definitions +semantics.addOperation("astOfFunctionCommonPrefix", { + // FunctionCommonPrefix(optForall, retTy, fnName, fnParams, fnAttributes) { // }, }); -semantics.addOperation("astOfGlobalVariable", { }); +// forall (type? typeName1, type? typeName2, ...) -> +semantics.addOperation("astOfForall", { + Forall(_forallKwd, _space1, typeVars, _space2, _mapsToKwd, _space3) { + return { + kind: "forall", + tyVars: typeVars.children.map(x => x.astOfType()), + loc: createSrcInfo(this), + } + }, +}); + +// All the types, united under FuncAstType +semantics.addOperation("astOfType", { -semantics.addOperation("astOfConstant", { }); +// Not a standalone statement, produces a list of statements instead +semantics.addOperation("astOfElseBlock", { + ElseBlock(_elseKwd, _lbrace, stmts, _rbrace) { + return stmts.children.map(x => x.astOfStatement()); + }, +}); -semantics.addOperation("astOfFunctionCommonPrefix", { }); +// semantics.addOperation("astOfSOMETHING", { }); +// semantics.addOperation("astOfSOMETHING", { }); +// semantics.addOperation("astOfSOMETHING", { }); // // Utility parsing functions // /** If the match wasn't successful, provides error message and interval */ -type GrammarMatch = +export type GrammarMatch = | { ok: false; message: string; interval: RawInterval } | { ok: true; res: MatchResult }; From c64dc476f5207177eac4655fa6c3220b349e265d Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Sat, 10 Aug 2024 19:25:48 +0200 Subject: [PATCH 102/162] feat(func-parser): completed! :rocket: --- src/func/__snapshots__/grammar.spec.ts.snap | 6136 ++++++++++++++++++- src/func/grammar.ohm | 20 +- src/func/grammar.spec.ts | 28 +- src/func/grammar.ts | 1022 ++- 4 files changed, 7046 insertions(+), 160 deletions(-) diff --git a/src/func/__snapshots__/grammar.spec.ts.snap b/src/func/__snapshots__/grammar.spec.ts.snap index dc5705ea1..86b960826 100644 --- a/src/func/__snapshots__/grammar.spec.ts.snap +++ b/src/func/__snapshots__/grammar.spec.ts.snap @@ -1,11 +1,27 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`FunC grammar and parser should NOT parse id-arith-operator 1`] = `"semantics(...).astOfModule is not a function"`; +exports[`FunC grammar and parser should NOT parse id-arith-operator 1`] = ` +"id-arith-operator.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" -exports[`FunC grammar and parser should NOT parse id-assign-operator 1`] = `"semantics(...).astOfModule is not a function"`; +Line 1, col 4: +> 1 | () /(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-assign-operator 1`] = ` +"id-assign-operator.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" + +Line 1, col 4: +> 1 | () ^>>=(); + ^ + 2 | +" +`; exports[`FunC grammar and parser should NOT parse id-bitwise-operator 1`] = ` -"id-bitwise-operator.fc:1:5: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~") or "\`" +"id-bitwise-operator.fc:1:5: Parse error: expected not (a whiteSpace or "(" or ")" or "[" or "]" or "," or "." or ";" or "~"), "~_", "_", or "\`" Line 1, col 5: > 1 | () ~(); @@ -24,13 +40,43 @@ Line 1, col 16: " `; -exports[`FunC grammar and parser should NOT parse id-comparison-operator 1`] = `"semantics(...).astOfModule is not a function"`; +exports[`FunC grammar and parser should NOT parse id-comparison-operator 1`] = ` +"id-comparison-operator.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" + +Line 1, col 4: +> 1 | () <=>(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-control-keyword 1`] = ` +"id-control-keyword.fc:1:1: Name of the function cannot be a control keyword +Line 1, col 1: +> 1 | () elseifnot(); + ^~~~~~~~~~~~~~ + 2 | +" +`; -exports[`FunC grammar and parser should NOT parse id-control-keyword 1`] = `"semantics(...).astOfModule is not a function"`; +exports[`FunC grammar and parser should NOT parse id-delimiter 1`] = ` +"id-delimiter.fc:1:4: Parse error: expected not (a whiteSpace or "(" or ")" or "[" or "]" or "," or "." or ";" or "~"), "~_", "_", "\`", or "->" -exports[`FunC grammar and parser should NOT parse id-delimiter 1`] = `"semantics(...).astOfModule is not a function"`; +Line 1, col 4: +> 1 | () [(); + ^ + 2 | +" +`; -exports[`FunC grammar and parser should NOT parse id-directive 1`] = `"semantics(...).astOfModule is not a function"`; +exports[`FunC grammar and parser should NOT parse id-directive 1`] = ` +"id-directive.fc:1:1: Name of the function cannot be a compiler directive +Line 1, col 1: +> 1 | () #include(); + ^~~~~~~~~~~~~ + 2 | +" +`; exports[`FunC grammar and parser should NOT parse id-dot 1`] = ` "id-dot.fc:1:7: Parse error: expected "(" @@ -42,10 +88,17 @@ Line 1, col 7: " `; -exports[`FunC grammar and parser should NOT parse id-keyword 1`] = `"semantics(...).astOfModule is not a function"`; +exports[`FunC grammar and parser should NOT parse id-keyword 1`] = ` +"id-keyword.fc:1:1: Name of the function cannot be a keyword +Line 1, col 1: +> 1 | () global(); + ^~~~~~~~~~~ + 2 | +" +`; exports[`FunC grammar and parser should NOT parse id-multiline-comments 1`] = ` -"id-multiline-comments.fc:1:11: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~"), "\`", or "->" +"id-multiline-comments.fc:1:11: Parse error: expected not (a whiteSpace or "(" or ")" or "[" or "]" or "," or "." or ";" or "~"), "~_", "_", "\`", or "->" Line 1, col 11: > 1 | () {-aaa-}(); @@ -54,35 +107,82 @@ Line 1, col 11: " `; -exports[`FunC grammar and parser should NOT parse id-number 1`] = `"semantics(...).astOfModule is not a function"`; +exports[`FunC grammar and parser should NOT parse id-number 1`] = ` +"id-number.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" + +Line 1, col 4: +> 1 | () 123(); + ^ + 2 | +" +`; + +exports[`FunC grammar and parser should NOT parse id-number-decimal 1`] = ` +"id-number-decimal.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" + +Line 1, col 4: +> 1 | () 0(); + ^ + 2 | +" +`; -exports[`FunC grammar and parser should NOT parse id-number-decimal 1`] = `"semantics(...).astOfModule is not a function"`; +exports[`FunC grammar and parser should NOT parse id-number-hexadecimal 1`] = ` +"id-number-hexadecimal.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" -exports[`FunC grammar and parser should NOT parse id-number-hexadecimal 1`] = `"semantics(...).astOfModule is not a function"`; +Line 1, col 4: +> 1 | () 0x0(); + ^ + 2 | +" +`; -exports[`FunC grammar and parser should NOT parse id-number-hexadecimal-2 1`] = `"semantics(...).astOfModule is not a function"`; +exports[`FunC grammar and parser should NOT parse id-number-hexadecimal-2 1`] = ` +"id-number-hexadecimal-2.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" + +Line 1, col 4: +> 1 | () 0xDEADBEEF(); + ^ + 2 | +" +`; exports[`FunC grammar and parser should NOT parse id-number-neg-decimal 1`] = ` -"id-number-neg-decimal.fc:2:1: Parse error: expected end of input, "[", "(", "()", "var", "_", "tuple", "cont", "builder", "slice", "cell", "int", "const", or "global" +"id-number-neg-decimal.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" -Line 2, col 1: - 1 | () -1(); -> 2 | native idTest(); - ^ - 3 | +Line 1, col 4: +> 1 | () -1(); + ^ + 2 | native idTest(); +" +`; + +exports[`FunC grammar and parser should NOT parse id-number-neg-hexadecimal 1`] = ` +"id-number-neg-hexadecimal.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" + +Line 1, col 4: +> 1 | () -0x0(); + ^ + 2 | " `; -exports[`FunC grammar and parser should NOT parse id-number-neg-hexadecimal 1`] = `"semantics(...).astOfModule is not a function"`; +exports[`FunC grammar and parser should NOT parse id-only-underscore 1`] = ` +"id-only-underscore.fc:1:4: Parse error: expected not ((a hole or an integerLiteral or a delimiter or an operator or a primitive) not a rawId) or "->" -exports[`FunC grammar and parser should NOT parse id-only-underscore 1`] = `"semantics(...).astOfModule is not a function"`; +Line 1, col 4: +> 1 | () _(); + ^ + 2 | +" +`; exports[`FunC grammar and parser should NOT parse id-parens 1`] = ` -"id-parens.fc:1:14: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~") or "\`" +"id-parens.fc:1:15: Parse error: expected "{", ";", or "asm" -Line 1, col 14: +Line 1, col 15: > 1 | () take(first)Entry(); - ^ + ^ 2 | " `; @@ -118,17 +218,17 @@ Line 1, col 4: `; exports[`FunC grammar and parser should NOT parse id-type-keyword 1`] = ` -"id-type-keyword.fc:1:8: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~") or "\`" +"id-type-keyword.fc:1:6: Parse error: expected "
", "
", "\\r", "\\n", " ", or "\\t" -Line 1, col 8: +Line 1, col 6: > 1 | () ->(); - ^ + ^ 2 | " `; exports[`FunC grammar and parser should NOT parse id-unclosed-parens 1`] = ` -"id-unclosed-parens.fc:1:9: Parse error: expected not (a whiteSpace or "(" or ")" or "[ | ]" or "," or "." or ";" or "~") or "\`" +"id-unclosed-parens.fc:1:9: Parse error: expected ")" Line 1, col 9: > 1 | () aa(bb(); @@ -136,3 +236,5983 @@ Line 1, col 9: 2 | " `; + +exports[`FunC grammar and parser should parse __tact_crc16 1`] = ` +{ + "includes": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "include_stdlib.fc", + }, + }, + ], + "items": [ + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_crc16", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_data", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "s", + "value": "0000", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_data_empty?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_data", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "byte", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mask", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mask", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reg", + }, + "loc": FuncSrcInfo {}, + "op": "<<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "byte", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mask", + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reg", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mask", + }, + "loc": FuncSrcInfo {}, + "op": ">>=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reg", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 65535n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reg", + }, + "loc": FuncSrcInfo {}, + "op": "&=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 65535n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reg", + }, + "loc": FuncSrcInfo {}, + "op": "^=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4129n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reg", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "divmod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse __tact_debug 1`] = ` +{ + "includes": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "include_stdlib.fc", + }, + }, + ], + "items": [ + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STRDUMP", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DROP", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "s0 DUMP", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DROP", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_debug", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "debug_print", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse __tact_load_address 1`] = ` +{ + "includes": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "include_stdlib.fc", + }, + }, + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "__tact_verify_address.fc", + }, + }, + ], + "items": [ + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_load_address", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "raw", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_msg_addr", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "raw", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_verify_address", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse __tact_load_address_opt 1`] = ` +{ + "includes": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "include_stdlib.fc", + }, + }, + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "__tact_verify_address.fc", + }, + }, + ], + "items": [ + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_load_address_opt", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + ], + }, + "statements": [ + { + "alternatives": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "raw", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_msg_addr", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "raw", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_verify_address", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse __tact_load_bool 1`] = ` +{ + "includes": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "include_stdlib.fc", + }, + }, + ], + "items": [ + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "1 LDI", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_load_bool", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse __tact_store_address 1`] = ` +{ + "includes": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "include_stdlib.fc", + }, + }, + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "__tact_verify_address.fc", + }, + }, + ], + "items": [ + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_store_address", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_verify_address", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse __tact_store_address_opt 1`] = ` +{ + "includes": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "include_stdlib.fc", + }, + }, + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "__tact_store_address.fc", + }, + }, + ], + "items": [ + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_store_address_opt", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + "statements": [ + { + "alternatives": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_store_address", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null?", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse __tact_verify_address 1`] = ` +{ + "includes": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "include_stdlib.fc", + }, + }, + ], + "items": [ + { + "constants": [ + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "INVALID_ADDRESS", + }, + "ty": "int", + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 136n, + }, + }, + ], + "kind": "constants_definition", + "loc": FuncSrcInfo {}, + }, + { + "constants": [ + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "MC_NOT_ENABLED", + }, + "ty": "int", + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 137n, + }, + }, + ], + "kind": "constants_definition", + "loc": FuncSrcInfo {}, + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_verify_address", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "INVALID_ADDRESS", + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 267n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "h", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 11n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "MC_NOT_ENABLED", + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "h", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1279n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "INVALID_ADDRESS", + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "h", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1024n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_verify_address_masterchain", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "INVALID_ADDRESS", + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 267n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "h", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 11n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "INVALID_ADDRESS", + }, + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "h", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1024n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "h", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1279n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "address", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse asm-functions 1`] = ` +{ + "includes": [], + "items": [ + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "INC NEGATE", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_then_negate", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "INC", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NEGATE", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_then_negate'", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "INC NEGATE", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_then_negate''", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": " + "Hello" + " " + "World" + $+ $+ $>s + PUSHSLICE +", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hello_world", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "INC", + }, + { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": " + NEGATE +", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_then_negate'''", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STUXQ", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_uint_quiet", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STUXQ", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_uint_quiet'", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STUXQ", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_uint_quiet''", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STUXQ", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_uint_quiet'''", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "UNSINGLE", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unsingle", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse constants 1`] = ` +{ + "includes": [], + "items": [ + { + "constants": [ + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c1", + }, + "ty": undefined, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + }, + ], + "kind": "constants_definition", + "loc": FuncSrcInfo {}, + }, + { + "constants": [ + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c2", + }, + "ty": undefined, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 27n, + }, + }, + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c3", + }, + "ty": undefined, + "value": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c1", + }, + }, + ], + "kind": "constants_definition", + "loc": FuncSrcInfo {}, + }, + { + "constants": [ + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c4", + }, + "ty": "int", + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c5", + }, + "ty": undefined, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c6", + }, + "ty": "slice", + "value": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "s", + "value": "It's Zendaya", + }, + }, + ], + "kind": "constants_definition", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse expressions 1`] = ` +{ + "includes": [], + "items": [], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse functions 1`] = ` +{ + "includes": [], + "items": [ + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "void", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "params", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p1", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p3", + }, + "ty": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p4", + }, + "ty": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + ], + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p5", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + ], + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "poly", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p1", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "poly'", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p1", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p2", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + }, + ], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "attr", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + }, + ], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "attr'", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "attr''", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "body", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "XXX", + }, + }, + ], + }, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "everything", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "XXX", + }, + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "XXX", + }, + }, + "statements": [], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse globals 1`] = ` +{ + "includes": [], + "items": [ + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob1", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob3", + }, + "ty": { + "kind": "type_mapped", + "loc": FuncSrcInfo {}, + "mapsTo": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "value": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob4", + }, + "ty": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_mapped", + "loc": FuncSrcInfo {}, + "mapsTo": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "value": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cont", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + ], + }, + }, + ], + }, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob5", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob6", + }, + "ty": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + ], + }, + }, + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob7", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse identifiers 1`] = ` +{ + "includes": [], + "items": [ + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query'", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query''", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "CHECK", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "_internal_val", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "message_found?", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_pubkeys&signatures", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict::udict_set_builder", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "[semantics wrapper for FunC][semantics wrapper for FunC][semantics wrapper for FunC]", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fatal!", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "123validname", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "2+2=2*2", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "-alsovalidname", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "0xefefefhahaha", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "{hehehe}", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pa{--}in"\`aaa\`"", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "quoted_id", + "loc": FuncSrcInfo {}, + "value": "[semantics wrapper for FunC]I'm a function too[semantics wrapper for FunC]", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "quoted_id", + "loc": FuncSrcInfo {}, + "value": "[semantics wrapper for FunC]any symbols ; ~ () are allowed here...[semantics wrapper for FunC]", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "C4", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "C4g", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "4C", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "_0x0", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "_0", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "0x_", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "0x0_", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "0_", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash#256", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "💀💀💀0xDEADBEEF💀💀💀", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_verify_address", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_pow2", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "randomize_lt", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::asin", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::nrand_fast", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f261_inlined", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f̷̨͈͚́͌̀i̵̩͔̭̐͐̊n̸̟̝̻̩̎̓͋̕e̸̝̙̒̿͒̾̕", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "❤️❤️❤️thanks❤️❤️❤️", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "intslice", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "int2", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "impure_touch", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict::delete_get_min", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "something", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse include_stdlib 1`] = ` +{ + "includes": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "../../../stdlib/stdlib.fc", + }, + }, + ], + "items": [], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse literals-and-comments 1`] = ` +{ + "includes": [], + "items": [ + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "integers", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "strings", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "slice", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "s", + "value": "2A", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "a", + "value": "EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "u", + "value": "int hex", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "h", + "value": "int 32 bits of sha256", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "H", + "value": "int 256 bits of sha256", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "c", + "value": "int crc32", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": " + multi + line + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "s", + "value": "2A", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "a", + "value": "EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "u", + "value": " + ... + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "h", + "value": " + ... + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "H", + "value": " + ... + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "c", + "value": " + ... + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "comments!", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; + +exports[`FunC grammar and parser should parse pragmas 1`] = ` +{ + "includes": [], + "items": [], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [ + { + "kind": "pragma_literal", + "literal": "allow-post-modification", + "loc": FuncSrcInfo {}, + }, + { + "kind": "pragma_literal", + "literal": "compute-asm-ltr", + "loc": FuncSrcInfo {}, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": undefined, + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": undefined, + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": undefined, + "patch": 0n, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "=", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": "=", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": "=", + "patch": 0n, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "^", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "<", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": ">", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "<=", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": ">=", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": undefined, + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": undefined, + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": undefined, + "patch": 0n, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "=", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": "=", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": "=", + "patch": 0n, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "^", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "<", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": ">", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "<=", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": ">=", + "patch": undefined, + }, + }, + { + "kind": "pragma_version_string", + "loc": FuncSrcInfo {}, + "version": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "0.4.4", + }, + }, + ], +} +`; + +exports[`FunC grammar and parser should parse statements 1`] = ` +{ + "includes": [], + "items": [ + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stmt'", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "block_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [ + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "empty_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cond_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "alternatives": undefined, + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequences": [], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequences": [], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": undefined, + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequences": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequences": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequences": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequences": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [], + "consequencesIf": [], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": true, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [], + "consequencesIf": [], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": true, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [], + "consequencesIf": [], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": false, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [], + "consequencesIf": [], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": false, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": true, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": true, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": false, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": false, + }, + { + "alternativesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": true, + }, + { + "alternativesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": false, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "repeat_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "iterations": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [], + }, + { + "iterations": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "until_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [], + }, + { + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [ + { + "iterations": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [], + }, + ], + }, + ], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "while_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [], + }, + { + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [ + { + "iterations": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [], + }, + ], + }, + ], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "try_catch_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "catchExceptionName": { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "catchExitCodeName": { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "kind": "statement_try_catch", + "loc": FuncSrcInfo {}, + "statementsCatch": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [], + }, + ], + "statementsTry": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [], + }, + ], + }, + { + "catchExceptionName": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exception", + }, + "catchExitCodeName": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exit_code", + }, + "kind": "statement_try_catch", + "loc": FuncSrcInfo {}, + "statementsCatch": [], + "statementsTry": [], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expression_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, + "pragmas": [], +} +`; diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 18d96800a..885cd2e26 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -79,8 +79,8 @@ FunC { // Function parameters Parameters = "(" ListOf ")" - Parameter = TypeParameter &#whiteSpace (hole | id) --regular - | (hole | id) --inferredType + Parameter = TypeParameter &#whiteSpace (unusedId | id) --regular + | id --inferredType // Function parameter types TypeParameter = TypeBuiltinParameter (&#whiteSpace "->" &#whiteSpace TypeParameter)? @@ -193,7 +193,7 @@ FunC { | ExpressionMethod // parse_expr80 - ExpressionMethod = ExpressionVarFun (methodId &("(" | "[" | id) ExpressionPrimary)+ --calls + ExpressionMethod = ExpressionVarFun (methodId &("(" | "[" | functionId) ExpressionArgument)+ --calls | ExpressionVarFun // parse_expr90 @@ -202,15 +202,21 @@ FunC { // Variable declarations ExpressionVarDecl = TypeVarDecl ExpressionVarDeclPart + // (not a separate expression, added purely for convenience) ExpressionVarDeclPart = id | unusedId - | ExpressionTensor - | ExpressionTuple + | ExpressionTensorVarDecl + | ExpressionTupleVarDecl + + ExpressionTensorVarDecl = "(" NonemptyListOf ")" + ExpressionTupleVarDecl = "[" NonemptyListOf "]" + // (not a separate expression, added purely for convenience) + IdOrUnusedId = id | unusedId // Function calls - ExpressionFunCall = (functionId | ExpressionParens) ExpressionArgument+ + ExpressionFunCall = &("(" | functionId) ExpressionPrimary ExpressionArgument+ - ExpressionParens = "(" ExpressionFunCall ")" + // (not a separate expression, added purely for convenience) ExpressionArgument = functionId | unit | ExpressionTensor diff --git a/src/func/grammar.spec.ts b/src/func/grammar.spec.ts index 414513e2b..a856655c8 100644 --- a/src/func/grammar.spec.ts +++ b/src/func/grammar.spec.ts @@ -21,21 +21,23 @@ describe("FunC grammar and parser", () => { } // If didn't match the grammar, don't throw any more errors from full parse - if (!matchedAll) { return; } + if (!matchedAll) { + return; + } // Checking that valid FunC files parse - // for (const r of loadCases(__dirname + "/grammar-test/", ext)) { - // it("should parse " + r.name, () => { - // expect(parseFile(r.code, r.name + `.${ext}`)).toMatchSnapshot(); - // }); - // } + for (const r of loadCases(__dirname + "/grammar-test/", ext)) { + it("should parse " + r.name, () => { + expect(parseFile(r.code, r.name + `.${ext}`)).toMatchSnapshot(); + }); + } // Checking that invalid FunC files does NOT parse - // for (const r of loadCases(__dirname + "/grammar-test-failed/", ext)) { - // it("should NOT parse " + r.name, () => { - // expect(() => - // parseFile(r.code, r.name + `.${ext}`) - // ).toThrowErrorMatchingSnapshot(); - // }); - // } + for (const r of loadCases(__dirname + "/grammar-test-failed/", ext)) { + it("should NOT parse " + r.name, () => { + expect(() => + parseFile(r.code, r.name + `.${ext}`) + ).toThrowErrorMatchingSnapshot(); + }); + } }); diff --git a/src/func/grammar.ts b/src/func/grammar.ts index eafac1699..34f191ce8 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -148,7 +148,6 @@ function unwrapOptNode( return optNode !== undefined ? f(optNode) : undefined; } - const funcBuiltinOperatorFunctions = [ "_+_", "_-_", @@ -347,9 +346,9 @@ const funcHexIntRegex = /^\-?0x[0-9a-fA-F]+$/; * - NOT a builtin function * - NOT a builtin method * - NOT a builtin constant - * - NOT an underscore + * - NOT an underscore (unless it's a parameter or variable declaration) */ -function checkDeclaredId(ident: string, loc: FuncSrcInfo, altPrefix?: string): void | never { +function checkDeclaredId(ident: string, loc: FuncSrcInfo, altPrefix?: string, allowUnused?: boolean): void | never { // not an operatorId if (funcBuiltinOperatorFunctions.includes(ident)) { throwFuncSyntaxError( @@ -380,7 +379,7 @@ function checkDeclaredId(ident: string, loc: FuncSrcInfo, altPrefix?: string): v } // not an unusedId - if (ident === "_") { + if (allowUnused !== true && ident === "_") { throwFuncSyntaxError( `${altPrefix ?? "Declared identifier"} cannot be an underscore`, loc, @@ -392,7 +391,7 @@ function checkDeclaredId(ident: string, loc: FuncSrcInfo, altPrefix?: string): v * Checks that the given identifier is a valid operatorId, i.e. that it actually exists on the list of builtin operator functions * Unlike other checking functions it doesn't throw, but returns `true`, if identifier is a valid operatorId, and `false` otherwise */ -function checkOperatorId(ident: string, loc: FuncSrcInfo): boolean { +function checkOperatorId(ident: string): boolean { if (funcBuiltinOperatorFunctions.includes(ident)) { return true; } @@ -589,7 +588,7 @@ export type FuncAstAsmFunctionDefinition = { kind: "asm_function_definition"; forall: FuncAstForall | undefined; returnTy: FuncAstType; - name: FuncAstId; + name: FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId; parameters: FuncAstParameter[]; attributes: FuncAstFunctionAttribute[]; arrangement: FuncAstAsmArrangement | undefined; @@ -608,7 +607,7 @@ export type FuncAstAsmFunctionDefinition = { * (id+ -> integerLiteralDec+) */ export type FuncAstAsmArrangement = { - kind: "asm_arrangement_arguments"; + kind: "asm_arrangement"; arguments: FuncAstId[] | undefined; returns: FuncAstIntegerLiteral[] | undefined; loc: FuncSrcInfo; @@ -623,7 +622,7 @@ export type FuncAstFunctionDeclaration = { kind: "function_declaration"; forall: FuncAstForall | undefined; returnTy: FuncAstType; - name: FuncAstId; + name: FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId; parameters: FuncAstParameter[]; attributes: FuncAstFunctionAttribute[]; loc: FuncSrcInfo; @@ -638,7 +637,7 @@ export type FuncAstFunctionDefinition = { kind: "function_definition"; forall: FuncAstForall | undefined; returnTy: FuncAstType; - name: FuncAstId; + name: FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId; parameters: FuncAstParameter[]; attributes: FuncAstFunctionAttribute[]; statements: FuncAstStatement[]; @@ -667,12 +666,14 @@ export type FuncAstTypeVar = { }; /** - * Type? Id + * Note, that id can be an underscore only if type is defined + * + * Type? id */ export type FuncAstParameter = { kind: "parameter"; ty: FuncAstType | undefined; - name: FuncAstId; + name: FuncAstQuotedId | FuncAstPlainId | FuncAstUnusedId; loc: FuncSrcInfo; }; @@ -682,11 +683,11 @@ export type FuncAstParameter = { * impure | inline_ref | inline | method_id ("(" Integer | String ")")? */ export type FuncAstFunctionAttribute = - | { kind: "function_attribute_impure"; loc: FuncSrcInfo } - | { kind: "function_attribute_inline_ref"; loc: FuncSrcInfo } - | { kind: "function_attribute_inline"; loc: FuncSrcInfo } + | { kind: "impure"; loc: FuncSrcInfo } + | { kind: "inline_ref"; loc: FuncSrcInfo } + | { kind: "inline"; loc: FuncSrcInfo } | { - kind: "function_attribute_method_id"; + kind: "method_id"; value: FuncAstIntegerLiteral | FuncAstStringLiteral | undefined; loc: FuncSrcInfo; }; @@ -865,11 +866,7 @@ export type FuncAstExpression = | FuncAstExpressionAddBitwise | FuncAstExpressionMulBitwise | FuncAstExpressionUnary - | FuncAstExpressionMethodCallChain - // | FuncAstExpressionMethodCall - // expressionparens - // varfunpart - // expressionargument + | FuncAstExpressionMethod | FuncAstExpressionVarFun | FuncAstExpressionPrimary; @@ -879,28 +876,30 @@ export type FuncAstExpression = export type FuncAstExpressionAssign = { kind: "expression_assign"; left: FuncAstExpressionConditional; - op: - | "=" - | "+=" - | "-=" - | "*=" - | "/=" - | "%=" - | "~/=" - | "~%=" - | "^/=" - | "^%=" - | "&=" - | "|=" - | "^=" - | "<<=" - | ">>=" - | "~>>=" - | "^>>="; - right: FuncAstExpressionConditional; + op: FuncOpAssign; + right: FuncAstExpressionAssign; loc: FuncSrcInfo; }; +export type FuncOpAssign = + | "=" + | "+=" + | "-=" + | "*=" + | "/=" + | "%=" + | "~/=" + | "~%=" + | "^/=" + | "^%=" + | "&=" + | "|=" + | "^=" + | "<<=" + | ">>=" + | "~>>=" + | "^>>="; + /** * parse_expr13 */ @@ -918,22 +917,30 @@ export type FuncAstExpressionConditional = { export type FuncAstExpressionCompare = { kind: "expression_compare"; left: FuncAstExpressionBitwiseShift; - op: "==" | "<=>" | "<=" | "<" | ">=" | ">" | "!="; + op: FuncOpCompare; right: FuncAstExpressionBitwiseShift; loc: FuncSrcInfo; }; +export type FuncOpCompare = "==" | "<=>" | "<=" | "<" | ">=" | ">" | "!="; + /** * parse_expr17 */ export type FuncAstExpressionBitwiseShift = { kind: "expression_bitwise_shift"; left: FuncAstExpressionAddBitwise; - op: "<<" | ">>" | "~>>" | "^>>"; - right: FuncAstExpressionAddBitwise; + ops: FuncExpressionBitwiseShiftPart[]; loc: FuncSrcInfo; }; +export type FuncExpressionBitwiseShiftPart = { + op: FuncOpBitwiseShift; + expr: FuncAstExpressionAddBitwise; +}; + +export type FuncOpBitwiseShift = "<<" | ">>" | "~>>" | "^>>"; + /** * parse_expr20 */ @@ -941,63 +948,68 @@ export type FuncAstExpressionAddBitwise = { kind: "expression_add_bitwise"; negateLeft: boolean; left: FuncAstExpressionMulBitwise; - op: "+" | "-" | "|" | "^"; - right: FuncAstExpressionMulBitwise; + ops: FuncExpressionAddBitwisePart[]; loc: FuncSrcInfo; }; +export type FuncExpressionAddBitwisePart = { + op: FuncOpAddBitwise; + expr: FuncAstExpressionMulBitwise; +}; + +export type FuncOpAddBitwise = "+" | "-" | "|" | "^"; + /** * parse_expr30 */ export type FuncAstExpressionMulBitwise = { kind: "expression_mul_bitwise"; left: FuncAstExpressionUnary; - op: "*" | "/%" | "/" | "%" | "~/" | "~%" | "^/" | "^%" | "&"; - right: FuncAstExpressionUnary; + ops: FuncExpressionMulBitwiseOp[]; loc: FuncSrcInfo; }; +export type FuncExpressionMulBitwiseOp = { + op: FuncOpMulBitwise; + expr: FuncAstExpressionUnary; +}; + +export type FuncOpMulBitwise = + | "*" | "/%" | "/" | "%" | "~/" | "~%" | "^/" | "^%" | "&"; + /** * parse_expr75 */ export type FuncAstExpressionUnary = { kind: "expression_unary"; - op: "~"; - operand: FuncAstExpressionMethodCallChain; + op: FuncOpUnary; + operand: FuncAstExpressionMethod; loc: FuncSrcInfo; }; +export type FuncOpUnary = "~"; + /** * parse_expr80 */ -export type FuncAstExpressionMethodCallChain = { - kind: "expression_method_call_chain"; +export type FuncAstExpressionMethod = { + kind: "expression_method"; object: FuncAstExpressionVarFun; - methods: FuncAstExpressionMethodCall[]; + calls: FuncExpressionMethodCall[]; loc: FuncSrcInfo; }; -/** - * methodId ExpressionArgument - */ -export type FuncAstExpressionMethodCall = { - kind: "expression_method_call"; +export type FuncExpressionMethodCall = { name: FuncAstMethodId; - argument: FuncAstExpressionArgument; - loc: FuncSrcInfo; + argument: FuncAstExpressionPrimary; }; -export type FuncAstExpressionArgument = +export type FuncArgument = | FuncAstMethodId | FuncAstUnit | FuncAstExpressionTensor | FuncAstExpressionTuple; -/** - * ( ExpressionFunctionCall ) - */ -export type FuncAstExpressionParens = FuncAstExpressionFunCall; - /** * parse_expr90 */ @@ -1013,24 +1025,45 @@ export type FuncAstExpressionVarFun = export type FuncAstExpressionVarDecl = { kind: "expression_var_decl"; ty: FuncAstType; - names: FuncAstExpressionVarDeclPart; + names: FuncVarDeclPart; loc: FuncSrcInfo; }; -export type FuncAstExpressionVarDeclPart = +/** + * Note, that methodId and operatorId should be prohibited + */ +export type FuncVarDeclPart = | FuncAstId - | FuncAstExpressionTensor - | FuncAstExpressionTuple; + | FuncAstExpressionTensorVarDecl + | FuncAstExpressionTupleVarDecl; + +/** + * ( Id, Id, ... ) + */ +export type FuncAstExpressionTensorVarDecl = { + kind: "expression_tensor_var_decl"; + names: FuncAstId[]; + loc: FuncSrcInfo; +}; + +/** + * [ Id, Id, ... ] + */ +export type FuncAstExpressionTupleVarDecl = { + kind: "expression_tuple_var_decl"; + names: FuncAstId[]; + loc: FuncSrcInfo; +}; /** * Function call * - * (methodId | functionCallReturningFunction) Argument+ + * (functionId | functionCallReturningFunction) Argument+ */ export type FuncAstExpressionFunCall = { kind: "expression_fun_call"; - object: FuncAstMethodId | FuncAstExpressionParens; - arguments: FuncAstExpressionArgument[]; + object: FuncAstExpressionPrimary; + arguments: FuncArgument[]; loc: FuncSrcInfo; }; @@ -1095,36 +1128,48 @@ export type FuncAstUnaryExpression = FuncAstExpressionUnary; // /** - * Builtin types, type variables or combinations of, with optional mappings with -> + * Mapped or unmapped types */ -export type FuncAstType = FuncAstTypeBuiltin | FuncAstTypeVar; +export type FuncAstType = + | FuncAstTypePrimitive + | FuncAstTypeComposite + | FuncAstTypeVar + | FuncAstTypeMapped; -// TODO: re-org the types +/** + * TypeUnmapped -> Type + */ +export type FuncAstTypeMapped = { + kind: "type_mapped"; + value: FuncAstTypePrimitive | FuncAstTypeComposite | FuncAstTypeVar; + mapsTo: FuncAstType; + loc: FuncSrcInfo; +}; /** - * Builtin types, with optional mappings with -> + * "int" | "cell" | "slice" | "builder" | "cont" | "tuple" */ -export type FuncAstTypeBuiltin = { - kind: "type_builtin"; - value: - | "int" - | "cell" - | "slice" - | "builder" - | "cont" - | "tuple" - | FuncAstTensor - | FuncAstTuple - | FuncAstHole - | FuncAstUnit; - mapsTo: FuncAstType | undefined; +export type FuncAstTypePrimitive = { + kind: "type_primitive"; + value: FuncTypePrimitive; loc: FuncSrcInfo; }; +export type FuncTypePrimitive = "int" | "cell" | "slice" | "builder" | "cont" | "tuple"; + +/** + * (..., ...) or [..., ...] or (_ | var) or () + */ +export type FuncAstTypeComposite = + | FuncAstTypeTensor + | FuncAstTypeTuple + | FuncAstHole + | FuncAstUnit; + /** * (..., ...) */ -export type FuncAstTensor = { +export type FuncAstTypeTensor = { kind: "type_tensor"; types: FuncAstType[]; loc: FuncSrcInfo; @@ -1133,7 +1178,7 @@ export type FuncAstTensor = { /** * [..., ...] */ -export type FuncAstTuple = { +export type FuncAstTypeTuple = { kind: "type_tuple"; types: FuncAstType[]; loc: FuncSrcInfo; @@ -1222,7 +1267,7 @@ export type FuncAstUnusedId = { */ export type FuncAstVersionRange = { kind: "version_range"; - op: string | undefined; + op: "=" | "^" | "<=" | ">=" | "<" | ">" | undefined; major: bigint; minor: bigint | undefined; patch: bigint | undefined; @@ -1255,7 +1300,7 @@ export type FuncAstStringLiteral = export type FuncAstStringLiteralSingleLine = { kind: "string_singleline"; value: string; - ty: FuncAstStringType | undefined; + ty: FuncStringType | undefined; loc: FuncSrcInfo; }; @@ -1265,7 +1310,7 @@ export type FuncAstStringLiteralSingleLine = { export type FuncAstStringLiteralMultiLine = { kind: "string_multiline"; value: string; - ty: FuncAstStringType | undefined; + ty: FuncStringType | undefined; // Perhaps: alignIndent: boolean; // Perhaps: trim: boolean; loc: FuncSrcInfo; @@ -1274,9 +1319,9 @@ export type FuncAstStringLiteralMultiLine = { /** * An additional modifier. See: https://docs.ton.org/develop/func/literals_identifiers#string-literals */ -export type FuncAstStringType = "s" | "a" | "u" | "h" | "H" | "c"; +export type FuncStringType = "s" | "a" | "u" | "h" | "H" | "c"; -export type FuncAstWhiteSpace = { +export type FuncWhiteSpace = { kind: "whitespace"; value: `\t` | ` ` | `\n` | `\r` | `\u2028` | `\u2029`; }; @@ -1291,7 +1336,7 @@ export type FuncAstComment = FuncAstCommentSingleLine | FuncAstCommentMultiLine; /** * ;; ... * - * Doesn't include the leading ;; characters TODO: rm + * Doesn't include the leading ;; characters */ export type FuncAstCommentSingleLine = { kind: "comment_singleline"; @@ -1302,7 +1347,7 @@ export type FuncAstCommentSingleLine = { /** * {- ...can be nested... -} * - * Doesn't include the leftmost {- and rightmost -} *ODO: rm + * Doesn't include the leftmost {- and rightmost -} * * @field skipCR If set to true, skips CR before the next line */ @@ -1314,10 +1359,9 @@ export type FuncAstCommentMultiLine = { }; // -// Semantic analysis +// AST generation through syntax analysis // -// TODO: ids for nodes via a function wrapper like in Tact? const semantics = FuncGrammar.createSemantics(); semantics.addOperation("astOfModule", { @@ -1426,14 +1470,14 @@ semantics.addOperation("astOfModuleItem", { GlobalVariablesDeclaration(_globalKwd, globals, _semicolon) { return { kind: "global_variables_declaration", - globals: globals.children.map((x) => x.astOfGlobalVariable()), + globals: globals.asIteration().children.map((x) => x.astOfGlobalVariable()), loc: createSrcInfo(this), }; }, ConstantsDefinition(_constKwd, constants, _semicolon) { return { kind: "constants_definition", - constants: constants.children.map((x) => x.astOfConstant()), + constants: constants.asIteration().children.map((x) => x.astOfConstant()), loc: createSrcInfo(this), }; }, @@ -1580,13 +1624,412 @@ semantics.addOperation("astOfStatement", { }, }); +// Expressions semantics.addOperation("astOfExpression", { + // parse_expr + Expression(expr) { + return expr.astOfExpression(); + }, + + // parse_expr10 + ExpressionAssign(expr) { + return expr.astOfExpression(); + }, + ExpressionAssign_op(exprLeft, _space1, op, _space2, exprRight) { + return { + kind: "expression_assign", + left: exprLeft.astOfExpression(), + op: op.sourceString as FuncOpAssign, + right: exprRight.astOfExpression(), + loc: createSrcInfo(this), + }; + }, + + // parse_expr13 + ExpressionConditional(expr) { + return expr.astOfExpression(); + }, + ExpressionConditional_ternary(exprLeft, _space1, _qmark, _space2, exprMiddle, _space3, _colon, _space4, exprRight) { + return { + kind: "expression_conditional", + condition: exprLeft.astOfExpression(), + consequence: exprMiddle.astOfExpression(), + alternative: exprRight.astOfExpression(), + loc: createSrcInfo(this), + }; + }, + + // parse_expr15 + ExpressionCompare(expr) { + return expr.astOfExpression(); + }, + ExpressionCompare_op(exprLeft, _space1, op, _space2, exprRight) { + return { + kind: "expression_compare", + left: exprLeft.astOfExpression(), + op: op.sourceString as FuncOpCompare, + right: exprRight.astOfExpression(), + loc: createSrcInfo(this), + }; + }, + + // parse_expr17 + ExpressionBitwiseShift(expr) { + return expr.astOfExpression(); + }, + ExpressionBitwiseShift_ops(exprLeft, _space, ops, _spaces, exprs) { + const resolvedOps = ops.children.map(x => x.sourceString as FuncOpBitwiseShift); + const resolvedExprs = exprs.children.map(x => x.astOfExpression() as FuncAstExpressionAddBitwise); + const zipped = resolvedOps.map( + (resOp, i) => { return { op: resOp, expr: resolvedExprs[i]! } } + ); + return { + kind: "expression_bitwise_shift", + left: exprLeft.astOfExpression(), + ops: zipped, + loc: createSrcInfo(this), + }; + }, + + // parse_expr20 + ExpressionAddBitwise(expr) { + return expr.astOfExpression(); + }, + ExpressionAddBitwise_ops(optNegate, _optSpace, exprLeft, _space, ops, _spaces,exprs) { + const negate = unwrapOptNode(optNegate, t => t.sourceString); + const resolvedOps = ops.children.map(x => x.sourceString as FuncOpAddBitwise); + const resolvedExprs = exprs.children.map(x => x.astOfExpression() as FuncAstExpressionMulBitwise); + const zipped = resolvedOps.map( + (resOp, i) => { return { op: resOp, expr: resolvedExprs[i]! } } + ); + return { + kind: "expression_add_bitwise", + negateLeft: negate === undefined ? false : true, + left: exprLeft.astOfExpression(), + ops: zipped, + loc: createSrcInfo(this), + }; + }, + + // parse_expr30 + ExpressionMulBitwise(expr) { + return expr.astOfExpression(); + }, + ExpressionMulBitwise_ops(exprLeft, _space, ops, _spaces, exprs) { + const resolvedOps = ops.children.map(x => x.sourceString as FuncOpMulBitwise); + const resolvedExprs = exprs.children.map(x => x.astOfExpression() as FuncAstExpressionUnary); + const zipped = resolvedOps.map( + (resOp, i) => { return { op: resOp, expr: resolvedExprs[i]! } } + ); + return { + kind: "expression_mul_bitwise", + left: exprLeft.astOfExpression(), + ops: zipped, + loc: createSrcInfo(this), + }; + }, + + // parse_expr75 + ExpressionUnary(expr) { + return expr.astOfExpression(); + }, + ExpressionUnary_bitwiseNot(notOp, _space, operand) { + return { + kind: "expression_unary", + op: notOp.sourceString as "~", + operand: operand.astOfExpression(), + loc: createSrcInfo(this), + } + }, + + // parse_expr80 + ExpressionMethod(expr) { + return expr.astOfExpression(); + }, + ExpressionMethod_calls(exprLeft, methodIds, _lookahead, exprs) { + const resolvedIds = methodIds.children.map(x => x.astOfExpression() as FuncAstMethodId); + const resolvedExprs = exprs.children.map(x => x.astOfExpression() as FuncArgument); + const zipped = resolvedIds.map( + (resId, i) => { return { name: resId, argument: resolvedExprs[i]! } } + ); + return { + kind: "expression_method", + object: exprLeft.astOfExpression(), + calls: zipped, + loc: createSrcInfo(this), + }; + }, + + // parse_expr90, and some inner things + ExpressionVarFun(expr) { + return expr.astOfExpression(); + }, + ExpressionVarDecl(varDeclTy, varNames) { + const names = varNames.astOfVarDeclPart() as FuncVarDeclPart; + const checkVarDeclName = (node: FuncAstId) => { + if (node.kind === "unused_id" || node.kind === "quoted_id") { + return; + } + if (node.kind === "method_id") { + throwFuncSyntaxError( + "Name of the variable cannot start with . or ~", + createSrcInfo(this) + ); + } + if (node.kind === "plain_id") { + checkPlainId(node.value, createSrcInfo(this), "Name of the variable"); + } + checkDeclaredId(node.value, createSrcInfo(this), "Name of the variable"); + }; + + if (names.kind === "expression_tensor_var_decl" + || names.kind === "expression_tuple_var_decl") { + for (let i = 0; i < names.names.length; i += 1) { + checkVarDeclName(names.names[i]!); + } + } else { + checkVarDeclName(names); + } + + return { + kind: "expression_var_decl", + ty: varDeclTy.astOfType(), + names: names, + loc: createSrcInfo(this), + }; + }, + ExpressionVarDeclPart(expr) { + return expr.astOfExpression(); + }, + ExpressionFunCall(_lookahead, expr, args) { + return { + kind: "expression_fun_call", + object: expr.astOfExpression(), + arguments: args.children.map(x => x.astOfExpression()), + loc: createSrcInfo(this), + }; + }, + ExpressionArgument(expr) { + return expr.astOfExpression(); + }, + + // parse_expr100, and some inner things + ExpressionPrimary(expr) { + return expr.astOfExpression(); + }, + unit(_lparen, _space, _rparen) { + return { + kind: "unit", + value: "()", + loc: createSrcInfo(this), + }; + }, + ExpressionTensor(_lparen, exprs, _rparen) { + return { + kind: "expression_tensor", + expressions: exprs.asIteration().children.map(x => x.astOfExpression()), + loc: createSrcInfo(this), + }; + }, + tupleEmpty(_lparen, _spaces, _rparen) { + return { + kind: "expression_tuple", + expressions: [], + loc: createSrcInfo(this), + } + }, + ExpressionTuple(_lparen, exprs, _rparen) { + return { + kind: "expression_tuple", + expressions: exprs.asIteration().children.map(x => x.astOfExpression()), + loc: createSrcInfo(this), + }; + }, + integerLiteral(optNegate, numLit) { + const negate = unwrapOptNode(optNegate, t => t.sourceString); + const value = (negate === undefined ? 1n : -1n) * BigInt(numLit.sourceString); + + return { + kind: "integer_literal", + value: value, + loc: createSrcInfo(this), + }; + }, + integerLiteralNonNegative(nonNegNumLit) { + return { + kind: "integer_literal", + value: BigInt(nonNegNumLit.sourceString), + loc: createSrcInfo(this), + }; + }, + integerLiteralDec(nonNegNumLit) { + return { + kind: "integer_literal", + value: BigInt(nonNegNumLit.sourceString), + loc: createSrcInfo(this), + }; + }, + integerLiteralHex(hexPrefix, nonNegNumLit) { + return { + kind: "integer_literal", + value: BigInt(hexPrefix.sourceString + nonNegNumLit.sourceString), + loc: createSrcInfo(this), + }; + }, + stringLiteral(strLit) { + return strLit.astOfExpression(); + }, + stringLiteral_singleLine(_lquote, contents, _rquote, optTy) { + return { + kind: "string_singleline", + value: contents.sourceString, + ty: unwrapOptNode(optTy, t => t.sourceString) as (FuncStringType | undefined), + loc: createSrcInfo(this), + } + }, + stringLiteral_multiLine(_lquote, contents, _rquote, optTy) { + return { + kind: "string_multiline", + value: contents.sourceString, + ty: unwrapOptNode(optTy, t => t.sourceString) as (FuncStringType | undefined), + loc: createSrcInfo(this), + } + }, + functionId(optPrefix, rawId) { + const prefix = unwrapOptNode(optPrefix, t => t.sourceString); + + if (prefix === undefined) { + return rawId.astOfExpression(); + } + + return { + kind: "method_id", + prefix: prefix as ("." | "~"), + value: (rawId.astOfExpression() as FuncAstId).value, + loc: createSrcInfo(this), + }; + }, + methodId(prefix, rawId) { + return { + kind: "method_id", + prefix: prefix.sourceString as ("." | "~"), + value: (rawId.astOfExpression() as FuncAstId).value, + loc: createSrcInfo(this), + } + }, + id(rawId) { + return rawId.astOfExpression(); + }, + rawId(someId) { + return someId.astOfExpression(); + }, + quotedId(ltick, idContents, rtick) { + return { + kind: "quoted_id", + value: [ltick, idContents.sourceString, rtick].join(""), + loc: createSrcInfo(this), + } + }, + operatorId(opId) { + return opId.astOfExpression(); + }, + operatorId_common(optCaret, underscore1, op, underscore2) { + const value = [ + unwrapOptNode(optCaret, t => t.sourceString) ?? "", + underscore1, op, underscore2, + ].join(""); + + return { + kind: checkOperatorId(value) + ? "operator_id" + : "plain_id", + value: value, + loc: createSrcInfo(this), + }; + }, + operatorId_not(notOp) { + return { + kind: "operator_id", + value: notOp.sourceString, + loc: createSrcInfo(this), + }; + }, + plainId(idContents) { + const value = idContents.sourceString; + if (value === "_") { + return { + kind: "unused_id", + value: "_", + loc: createSrcInfo(this), + }; + } + return { + kind: "plain_id", + value: value, + loc: createSrcInfo(this), + } + }, + unusedId(underscore) { + return { + kind: "unused_id", + value: underscore.sourceString as "_", + loc: createSrcInfo(this), + } + }, +}); + +// Some parts of expressions which do not produce FuncAstExpression node +semantics.addOperation("astOfVarDeclPart", { + id(node) { + return node.astOfExpression(); + }, + unusedId(node) { + return node.astOfExpression(); + }, + ExpressionTensorVarDecl(_lparen, ids, _rparen) { + return { + kind: "expression_tensor_var_decl", + names: ids.asIteration().children.map(x => x.astOfIdOrUnusedId()), + loc: createSrcInfo(this), + }; + }, + ExpressionTupleVarDecl(_lbrack, ids, _rbrack) { + return { + kind: "expression_tuple_var_decl", + names: ids.asIteration().children.map(x => x.astOfIdOrUnusedId()), + loc: createSrcInfo(this), + }; + }, +}); +semantics.addOperation("astOfIdOrUnusedId", { + IdOrUnusedId(node) { + return node.astOfExpression(); + }, }); -// Miscellaneous things +// Miscellaneous utility nodes, gathered together for convenience // // A couple of them don't even have their own dedicated TypeScript types, -// and most were added purely for parsing convenience +// and most were introduced mostly for parsing convenience + +// op? decNum (. decNum)? (. decNum)? +semantics.addOperation("astOfVersionRange", { + versionRange(optOp, majorVers, _optDot, optMinorVers, _optDot2, optPatchVers) { + const op = unwrapOptNode(optOp, t => t.sourceString) as ("=" | "^" | "<=" | ">=" | "<" | ">" | undefined); + const major = majorVers.astOfExpression() as FuncAstIntegerLiteral; + const minor = unwrapOptNode(optMinorVers, t => t.astOfExpression()) as (FuncAstIntegerLiteral | undefined); + const patch = unwrapOptNode(optPatchVers, t => t.astOfExpression()) as (FuncAstIntegerLiteral | undefined); + + return { + kind: "version_range", + op: op, + major: major.value, + minor: minor?.value, + patch: patch?.value, + loc: createSrcInfo(this), + } + }, +}); // nonVarType? (quotedId | plainId) semantics.addOperation("astOfGlobalVariable", { @@ -1655,15 +2098,32 @@ semantics.addOperation("astOfConstant", { type FuncFunctionCommonPrefix = { forall: FuncAstForall | undefined; returnTy: FuncAstType; - name: FuncAstId; + name: FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId; parameters: FuncAstParameter[]; attributes: FuncAstFunctionAttribute[]; }; // Common prefix of all function declarations/definitions semantics.addOperation("astOfFunctionCommonPrefix", { - // FunctionCommonPrefix(optForall, retTy, fnName, fnParams, fnAttributes) { - // }, + FunctionCommonPrefix(optForall, retTy, fnName, fnParams, fnAttributes) { + const name = fnName.astOfExpression() as FuncAstId; + + // if a plainId, then check for validity + if (name.kind === "plain_id") { + checkPlainId(name.value, createSrcInfo(this), "Name of the function"); + } + + // check that it can be declared (also excludes operatorId and unusedId) + checkDeclaredId(name.value, createSrcInfo(this), "Name of the function"); + + return { + forall: unwrapOptNode(optForall, t => t.astOfForall()), + returnTy: retTy.astOfType(), + name: name as (FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId), + parameters: fnParams.astOfParameters(), + attributes: fnAttributes.children.map(x => x.astOfFunctionAttribute()), + }; + }, }); // forall (type? typeName1, type? typeName2, ...) -> @@ -1671,14 +2131,356 @@ semantics.addOperation("astOfForall", { Forall(_forallKwd, _space1, typeVars, _space2, _mapsToKwd, _space3) { return { kind: "forall", - tyVars: typeVars.children.map(x => x.astOfType()), + tyVars: typeVars.asIteration().children.map(x => x.astOfType()), loc: createSrcInfo(this), } }, }); +// (Type? Id, ...) +semantics.addOperation("astOfParameters", { + Parameters(_lparen, params, _rparen) { + return params.asIteration().children.map(x => x.astOfParameter()); + }, +}); + +// Type? Id +semantics.addOperation("astOfParameter", { + Parameter(param) { + return param.astOfParameter(); + }, + Parameter_regular(paramTy, _space, unusedIdOrId) { + const name = unusedIdOrId.astOfExpression() as FuncAstId; + + // if a plainId, then check for validity + if (name.kind === "plain_id") { + checkPlainId(name.value, createSrcInfo(this), "Name of the parameter"); + } + + // check that it can be declared (also excludes operatorId, but not unusedId) + checkDeclaredId(name.value, createSrcInfo(this), "Name of the parameter", true); + + // and that it's not a methodId + if (name.kind === "method_id") { + throwFuncSyntaxError( + "Name of the parameter cannot start with ~ or .", + createSrcInfo(this), + ); + } + + return { + kind: "parameter", + ty: paramTy.astOfType(), + name: name as (FuncAstQuotedId | FuncAstPlainId | FuncAstUnusedId), + loc: createSrcInfo(this), + }; + }, + Parameter_inferredType(paramName) { + const name = paramName.astOfExpression() as FuncAstId; + + // if a plainId, then check for validity + if (name.kind === "plain_id") { + checkPlainId(name.value, createSrcInfo(this), "Name of the parameter"); + } + + // check that it can be declared (also excludes operatorId and unusedId) + checkDeclaredId(name.value, createSrcInfo(this), "Name of the parameter"); + + // and that it's not a methodId + if (name.kind === "method_id") { + throwFuncSyntaxError( + "Name of the parameter cannot start with ~ or .", + createSrcInfo(this), + ); + } + + return { + kind: "parameter", + ty: undefined, + name: name as (FuncAstQuotedId | FuncAstPlainId), + loc: createSrcInfo(this), + }; + }, +}); + +// (id+) or (-> integerLiteralDec+) or (id+ -> integerLiteralDec+) +semantics.addOperation("astOfAsmArrangement", { + AsmArrangement(asmArrangement) { + return asmArrangement.astOfAsmArrangement(); + }, + AsmArrangement_arguments(_lparen, args, _rparen) { + return { + kind: "asm_arrangement", + arguments: args.children.map(x => x.astOfExpression()), + returns: undefined, + loc: createSrcInfo(this), + }; + }, + AsmArrangement_returns(_lparen, _mapsTo, _space, rets, _rparen) { + return { + kind: "asm_arrangement", + arguments: undefined, + returns: rets.children.map(x => x.astOfExpression()), + loc: createSrcInfo(this), + }; + }, + AsmArrangement_argumentsToReturns(_lparen, args, _space, _mapsTo, _space1, rets, _rparen) { + return { + kind: "asm_arrangement", + arguments: args.children.map(x => x.astOfExpression()), + returns: rets.children.map(x => x.astOfExpression()), + loc: createSrcInfo(this), + }; + }, +}); + +// impure | inline_ref | inline | method_id ("(" Integer | String ")")? +semantics.addOperation("astOfFunctionAttribute", { + FunctionAttribute(attr) { + if (attr.isTerminal()) { + if (attr.sourceString === "method_id") { + return { + kind: "method_id", + value: undefined, + loc: createSrcInfo(this), + } + } + return { + kind: attr.sourceString as ("impure" | "inline_ref" | "inline"), + loc: createSrcInfo(this), + }; + } + + return { + kind: "method_id", + value: attr.astOfMethodIdValue(), + loc: createSrcInfo(this), + }; + }, +}); + +// method_id "(" Integer | String ")" +semantics.addOperation("astOfMethodIdValue", { + MethodIdValue(mtd) { + return mtd.astOfMethodIdValue(); + }, + MethodIdValue_int(_methodIdKwd, _lparen, intLit, _rparen) { + return intLit.astOfExpression() as FuncAstIntegerLiteral; + }, + MethodIdValue_string(_methodIdKwd, _lparen, strLit, _rparen) { + return strLit.astOfExpression() as FuncAstStringLiteral; + }, +}); + // All the types, united under FuncAstType semantics.addOperation("astOfType", { + id(rawId) { + return { + kind: "type_var", + keyword: false, + name: rawId.astOfExpression(), + loc: createSrcInfo(this), + }; + }, + unit(_lparen, _space, _rparen) { + return { + kind: "unit", + value: "()", + loc: createSrcInfo(this), + }; + }, + tupleEmpty(_lparen, _spaces, _rparen) { + return { + kind: "type_tuple", + types: [], + loc: createSrcInfo(this), + } + }, + TypeGlob(globBiTy, _optMapsTo, optGlobTy) { + const mapsTo = unwrapOptNode(optGlobTy, t => t.astOfType()); + if (mapsTo !== undefined) { + return { + kind: "type_mapped", + value: globBiTy.astOfType(), + mapsTo: mapsTo, + loc: createSrcInfo(this), + }; + } + return globBiTy.astOfType(); + }, + TypeBuiltinGlob(globBiTy) { + return globBiTy.astOfType(); + }, + TypeBuiltinGlob_simple(globBiTy) { + const ty = globBiTy.sourceString; + if (ty === "_") { + return { + kind: "hole", + value: "_", + loc: createSrcInfo(this), + }; + } + return { + kind: "type_primitive", + value: ty as FuncTypePrimitive, + loc: createSrcInfo(this), + }; + }, + TensorGlob(_lparen, globTys, _rparen) { + return { + kind: "type_tensor", + types: globTys.asIteration().children.map(x => x.astOfType()), + loc: createSrcInfo(this), + }; + }, + TupleGlob(_lbrack, globTys, _rbrack) { + return { + kind: "type_tuple", + types: globTys.asIteration().children.map(x => x.astOfType()), + loc: createSrcInfo(this), + }; + }, + TypeVar(optTypeKwd, _space, typeVar) { + const typeKwd = unwrapOptNode(optTypeKwd, t => t.sourceString); + return { + kind: "type_var", + keyword: typeKwd !== undefined ? true : false, + name: typeVar.astOfExpression(), + loc: createSrcInfo(this), + }; + }, + TypeReturn(retBiTy, _space1, _optMapsTo, _space2, optRetTy) { + const mapsTo = unwrapOptNode(optRetTy, t => t.astOfType()); + if (mapsTo !== undefined) { + return { + kind: "type_mapped", + value: retBiTy.astOfType(), + mapsTo: mapsTo, + loc: createSrcInfo(this), + }; + } + return retBiTy.astOfType(); + }, + TypeBuiltinReturn(retBiTy) { + if (retBiTy.isTerminal()) { + const ty = retBiTy.sourceString; + if (ty === "_") { + return { + kind: "hole", + value: "_", + loc: createSrcInfo(this), + }; + } + return { + kind: "type_primitive", + value: ty as FuncTypePrimitive, + loc: createSrcInfo(this), + }; + } + return retBiTy.astOfType(); + }, + TensorReturn(_lparen, retTys, _rparen) { + return { + kind: "type_tensor", + types: retTys.asIteration().children.map(x => x.astOfType()), + loc: createSrcInfo(this), + }; + }, + TupleReturn(_lparen, retTys, _rparen) { + return { + kind: "type_tuple", + types: retTys.asIteration().children.map(x => x.astOfType()), + loc: createSrcInfo(this), + }; + }, + TypeParameter(paramBiTy, _space1, _optMapsTo, _space2, optRetTy) { + const mapsTo = unwrapOptNode(optRetTy, t => t.astOfType()); + if (mapsTo !== undefined) { + return { + kind: "type_mapped", + value: paramBiTy.astOfType(), + mapsTo: mapsTo, + loc: createSrcInfo(this), + }; + } + return paramBiTy.astOfType(); + }, + TypeBuiltinParameter(paramBiTy) { + if (paramBiTy.isTerminal()) { + const ty = paramBiTy.sourceString; + if (ty === "_") { + return { + kind: "hole", + value: "_", + loc: createSrcInfo(this), + }; + } + return { + kind: "type_primitive", + value: ty as FuncTypePrimitive, + loc: createSrcInfo(this), + }; + } + return paramBiTy.astOfType(); + }, + TensorParameter(_lparen, retTys, _rparen) { + return { + kind: "type_tensor", + types: retTys.asIteration().children.map(x => x.astOfType()), + loc: createSrcInfo(this), + }; + }, + TupleParameter(_lparen, retTys, _rparen) { + return { + kind: "type_tuple", + types: retTys.asIteration().children.map(x => x.astOfType()), + loc: createSrcInfo(this), + }; + }, + TypeVarDecl(varDeclBiTy, _space1, _optMapsTo, _space2, optRetTy) { + const mapsTo = unwrapOptNode(optRetTy, t => t.astOfType()); + if (mapsTo !== undefined) { + return { + kind: "type_mapped", + value: varDeclBiTy.astOfType(), + mapsTo: mapsTo, + loc: createSrcInfo(this), + }; + } + return varDeclBiTy.astOfType(); + }, + TypeBuiltinVarDecl(varDeclBiTy) { + return varDeclBiTy.astOfType(); + }, + TypeBuiltinVarDecl_simple(varDeclBiTy) { + if (!varDeclBiTy.isTerminal()) { + return { + kind: "hole", + value: varDeclBiTy.sourceString as "_" | "var", + loc: createSrcInfo(this), + }; + } + return { + kind: "type_primitive", + value: varDeclBiTy.sourceString as FuncTypePrimitive, + loc: createSrcInfo(this), + }; + }, + TensorVarDecl(_lparen, varDeclTys, _rparen) { + return { + kind: "type_tensor", + types: varDeclTys.asIteration().children.map(x => x.astOfType()), + loc: createSrcInfo(this), + }; + }, + TupleVarDecl(_lparen, varDeclTys, _rparen) { + return { + kind: "type_tuple", + types: varDeclTys.asIteration().children.map(x => x.astOfType()), + loc: createSrcInfo(this), + }; + }, +}); // Not a standalone statement, produces a list of statements instead semantics.addOperation("astOfElseBlock", { @@ -1687,10 +2489,6 @@ semantics.addOperation("astOfElseBlock", { }, }); -// semantics.addOperation("astOfSOMETHING", { }); -// semantics.addOperation("astOfSOMETHING", { }); -// semantics.addOperation("astOfSOMETHING", { }); - // // Utility parsing functions // From 93acaef2d9930837a164a512eed5ab4d56989830 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:01:17 +0200 Subject: [PATCH 103/162] fix(func-parser): bug squashed and lots of tests added --- src/func/__snapshots__/grammar.spec.ts.snap | 126870 ++++++++++++++- src/func/grammar-test/dns-auto-code.fc | 536 + src/func/grammar-test/dns-manual-code.fc | 361 + src/func/grammar-test/elector-code.fc | 1187 + src/func/grammar-test/highload-wallet-code.fc | 47 + .../grammar-test/highload-wallet-v2-code.fc | 87 + src/func/grammar-test/mathlib.fc | 939 + src/func/grammar-test/payment-channel-code.fc | 357 + src/func/grammar-test/pow-testgiver-code.fc | 158 + .../grammar-test/restricted-wallet-code.fc | 73 + .../grammar-test/restricted-wallet2-code.fc | 88 + .../grammar-test/restricted-wallet3-code.fc | 103 + src/func/grammar-test/simple-wallet-code.fc | 25 + .../grammar-test/simple-wallet-ext-code.fc | 68 + src/func/grammar-test/stdlib.fc | 639 + src/func/grammar-test/wallet-code.fc | 37 + src/func/grammar-test/wallet3-code.fc | 41 + src/func/grammar.ohm | 46 +- src/func/grammar.ts | 143 +- 19 files changed, 129577 insertions(+), 2228 deletions(-) create mode 100644 src/func/grammar-test/dns-auto-code.fc create mode 100644 src/func/grammar-test/dns-manual-code.fc create mode 100644 src/func/grammar-test/elector-code.fc create mode 100644 src/func/grammar-test/highload-wallet-code.fc create mode 100644 src/func/grammar-test/highload-wallet-v2-code.fc create mode 100644 src/func/grammar-test/mathlib.fc create mode 100644 src/func/grammar-test/payment-channel-code.fc create mode 100644 src/func/grammar-test/pow-testgiver-code.fc create mode 100644 src/func/grammar-test/restricted-wallet-code.fc create mode 100644 src/func/grammar-test/restricted-wallet2-code.fc create mode 100644 src/func/grammar-test/restricted-wallet3-code.fc create mode 100644 src/func/grammar-test/simple-wallet-code.fc create mode 100644 src/func/grammar-test/simple-wallet-ext-code.fc create mode 100644 src/func/grammar-test/stdlib.fc create mode 100644 src/func/grammar-test/wallet-code.fc create mode 100644 src/func/grammar-test/wallet3-code.fc diff --git a/src/func/__snapshots__/grammar.spec.ts.snap b/src/func/__snapshots__/grammar.spec.ts.snap index 86b960826..5db776434 100644 --- a/src/func/__snapshots__/grammar.spec.ts.snap +++ b/src/func/__snapshots__/grammar.spec.ts.snap @@ -239,7 +239,7 @@ Line 1, col 9: exports[`FunC grammar and parser should parse __tact_crc16 1`] = ` { - "includes": [ + "items": [ { "kind": "include", "loc": FuncSrcInfo {}, @@ -250,8 +250,6 @@ exports[`FunC grammar and parser should parse __tact_crc16 1`] = ` "value": "include_stdlib.fc", }, }, - ], - "items": [ { "attributes": [ { @@ -882,13 +880,12 @@ exports[`FunC grammar and parser should parse __tact_crc16 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; exports[`FunC grammar and parser should parse __tact_debug 1`] = ` { - "includes": [ + "items": [ { "kind": "include", "loc": FuncSrcInfo {}, @@ -899,8 +896,6 @@ exports[`FunC grammar and parser should parse __tact_debug 1`] = ` "value": "include_stdlib.fc", }, }, - ], - "items": [ { "arrangement": undefined, "asmStrings": [ @@ -1002,13 +997,12 @@ exports[`FunC grammar and parser should parse __tact_debug 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; exports[`FunC grammar and parser should parse __tact_load_address 1`] = ` { - "includes": [ + "items": [ { "kind": "include", "loc": FuncSrcInfo {}, @@ -1029,8 +1023,6 @@ exports[`FunC grammar and parser should parse __tact_load_address 1`] = ` "value": "__tact_verify_address.fc", }, }, - ], - "items": [ { "attributes": [ { @@ -1166,13 +1158,12 @@ exports[`FunC grammar and parser should parse __tact_load_address 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; exports[`FunC grammar and parser should parse __tact_load_address_opt 1`] = ` { - "includes": [ + "items": [ { "kind": "include", "loc": FuncSrcInfo {}, @@ -1193,8 +1184,6 @@ exports[`FunC grammar and parser should parse __tact_load_address_opt 1`] = ` "value": "__tact_verify_address.fc", }, }, - ], - "items": [ { "attributes": [ { @@ -1446,13 +1435,12 @@ exports[`FunC grammar and parser should parse __tact_load_address_opt 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; exports[`FunC grammar and parser should parse __tact_load_bool 1`] = ` { - "includes": [ + "items": [ { "kind": "include", "loc": FuncSrcInfo {}, @@ -1463,8 +1451,6 @@ exports[`FunC grammar and parser should parse __tact_load_bool 1`] = ` "value": "include_stdlib.fc", }, }, - ], - "items": [ { "arrangement": { "arguments": undefined, @@ -1536,13 +1522,12 @@ exports[`FunC grammar and parser should parse __tact_load_bool 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; exports[`FunC grammar and parser should parse __tact_store_address 1`] = ` { - "includes": [ + "items": [ { "kind": "include", "loc": FuncSrcInfo {}, @@ -1563,8 +1548,6 @@ exports[`FunC grammar and parser should parse __tact_store_address 1`] = ` "value": "__tact_verify_address.fc", }, }, - ], - "items": [ { "attributes": [ { @@ -1670,13 +1653,12 @@ exports[`FunC grammar and parser should parse __tact_store_address 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; exports[`FunC grammar and parser should parse __tact_store_address_opt 1`] = ` { - "includes": [ + "items": [ { "kind": "include", "loc": FuncSrcInfo {}, @@ -1697,8 +1679,6 @@ exports[`FunC grammar and parser should parse __tact_store_address_opt 1`] = ` "value": "__tact_store_address.fc", }, }, - ], - "items": [ { "attributes": [ { @@ -1879,13 +1859,12 @@ exports[`FunC grammar and parser should parse __tact_store_address_opt 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; exports[`FunC grammar and parser should parse __tact_verify_address 1`] = ` { - "includes": [ + "items": [ { "kind": "include", "loc": FuncSrcInfo {}, @@ -1896,8 +1875,6 @@ exports[`FunC grammar and parser should parse __tact_verify_address 1`] = ` "value": "include_stdlib.fc", }, }, - ], - "items": [ { "constants": [ { @@ -2417,13 +2394,11 @@ exports[`FunC grammar and parser should parse __tact_verify_address 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; exports[`FunC grammar and parser should parse asm-functions 1`] = ` { - "includes": [], "items": [ { "arrangement": undefined, @@ -3166,13 +3141,11 @@ exports[`FunC grammar and parser should parse asm-functions 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; exports[`FunC grammar and parser should parse constants 1`] = ` { - "includes": [], "items": [ { "constants": [ @@ -3286,165 +3259,51 @@ exports[`FunC grammar and parser should parse constants 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], -} -`; - -exports[`FunC grammar and parser should parse expressions 1`] = ` -{ - "includes": [], - "items": [], - "kind": "module", - "loc": FuncSrcInfo {}, - "pragmas": [], } `; -exports[`FunC grammar and parser should parse functions 1`] = ` +exports[`FunC grammar and parser should parse dns-auto-code 1`] = ` { - "includes": [], "items": [ { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "void", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "params", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p1", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { + "arrangement": { + "arguments": [ + { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "p2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", + "value": "index", }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { + { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "p3", - }, - "ty": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", + "value": "dict", }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { + { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "p4", - }, - "ty": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - ], + "value": "key_len", }, - }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ { - "kind": "parameter", + "kind": "string_singleline", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p5", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - ], - }, + "ty": undefined, + "value": "DICTUGETOPTREF", }, ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "function_declaration", + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "poly", + "value": "udict_get_ref_", }, "parameters": [ { @@ -3453,79 +3312,26 @@ exports[`FunC grammar and parser should parse functions 1`] = ` "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "p1", + "value": "dict", }, "ty": { - "keyword": false, - "kind": "type_var", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, + "value": "cell", }, }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "poly'", - }, - "parameters": [ { "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "p1", + "value": "key_len", }, "ty": { - "keyword": false, - "kind": "type_var", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, + "value": "int", }, }, { @@ -3534,618 +3340,1023 @@ exports[`FunC grammar and parser should parse functions 1`] = ` "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "p2", + "value": "index", }, "ty": { - "keyword": false, - "kind": "type_var", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, + "value": "int", }, }, ], "returnTy": { - "kind": "type_tensor", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], + "value": "cell", }, }, { "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, { "kind": "inline_ref", "loc": FuncSrcInfo {}, }, - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - }, - ], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "attr", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - }, - ], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "attr'", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, ], "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "attr''", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": undefined, "kind": "function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "body", + "value": "load_data", }, "parameters": [], "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": { - "kind": "forall", + "kind": "type_tensor", "loc": FuncSrcInfo {}, - "tyVars": [ + "types": [ { - "keyword": false, - "kind": "type_var", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "XXX", - }, + "value": "cell", }, - ], - }, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "everything", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "x", + "value": "cell", }, - "ty": { - "keyword": false, - "kind": "type_var", + { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "XXX", - }, + "value": "cell", }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "XXX", - }, - }, - "statements": [], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, - "pragmas": [], -} -`; - -exports[`FunC grammar and parser should parse globals 1`] = ` -{ - "includes": [], - "items": [ - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + { + "kind": "type_tuple", "loc": FuncSrcInfo {}, - "value": "glob1", + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "glob2", + "value": "int", }, - "ty": { + { "kind": "type_primitive", "loc": FuncSrcInfo {}, "value": "int", }, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ + ], + }, + "statements": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "glob3", - }, - "ty": { - "kind": "type_mapped", - "loc": FuncSrcInfo {}, - "mapsTo": { - "kind": "type_primitive", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", "loc": FuncSrcInfo {}, - "value": "int", + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, }, - "value": { - "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": "int", + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, }, }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "glob4", - }, - "ty": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ + "expression": { + "expressions": [ { - "kind": "type_mapped", + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "mapsTo": { - "kind": "type_primitive", + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "int", + "value": "cs", }, - "value": { - "kind": "type_tensor", + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "int", + "value": "cs", }, - { - "kind": "type_tensor", + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cont", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], + "value": "cs", }, - ], + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", }, }, ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, }, { - "globals": [ + "attributes": [ { - "kind": "global_variable", + "kind": "inline_ref", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_prices", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "glob5", + "value": "int", }, - "ty": { + { "kind": "type_primitive", "loc": FuncSrcInfo {}, "value": "int", }, - }, - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "glob6", + "value": "int", }, - "ty": { - "kind": "type_tensor", + { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "builder", + "value": "cs", }, - { + "ty": { "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "tuple", + "value": "slice", }, - ], - }, - }, - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + }, "loc": FuncSrcInfo {}, - "value": "glob7", + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, }, - "ty": undefined, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, - "pragmas": [], -} -`; - -exports[`FunC grammar and parser should parse identifiers 1`] = ` -{ - "includes": [], - "items": [ - { - "globals": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", "loc": FuncSrcInfo {}, - "value": "query'", }, - "ty": undefined, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", "loc": FuncSrcInfo {}, - "value": "query''", }, - "ty": undefined, + "kind": "statement_return", + "loc": FuncSrcInfo {}, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, }, { - "globals": [ + "attributes": [ { - "kind": "global_variable", + "kind": "impure", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "CHECK", - }, - "ty": undefined, }, ], - "kind": "global_variables_declaration", + "forall": undefined, + "kind": "function_definition", "loc": FuncSrcInfo {}, - }, - { - "globals": [ + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + "parameters": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "_internal_val", + "value": "ctl", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "message_found?", + "value": "dd", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "get_pubkeys&signatures", + "value": "gc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "dict::udict_set_builder", + "value": "prices", }, "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "[semantics wrapper for FunC][semantics wrapper for FunC][semantics wrapper for FunC]", + "value": "nhk", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "__", + "value": "lhk", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "ty": undefined, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ { - "kind": "global_variable", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tuple_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sp", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dd", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sp", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": "fatal!", + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, }, - "ty": undefined, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, }, { "globals": [ @@ -4155,616 +4366,867 @@ exports[`FunC grammar and parser should parse identifiers 1`] = ` "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "123validname", + "value": "query_info", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", }, - "ty": undefined, }, ], "kind": "global_variables_declaration", "loc": FuncSrcInfo {}, }, { - "globals": [ + "attributes": [ { - "kind": "global_variable", + "kind": "impure", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "2+2=2*2", - }, - "ty": undefined, }, ], - "kind": "global_variables_declaration", + "forall": undefined, + "kind": "function_definition", "loc": FuncSrcInfo {}, - }, - { - "globals": [ + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message", + }, + "parameters": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "-alsovalidname", + "value": "addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "0xefefefhahaha", + "value": "tag", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "{hehehe}", + "value": "query_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "pa{--}in"\`aaa\`"", + "value": "body", }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "quoted_id", + "ty": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "[semantics wrapper for FunC]I'm a function too[semantics wrapper for FunC]", + "value": "int", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { - "kind": "quoted_id", + "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "[semantics wrapper for FunC]any symbols ; ~ () are allowed here...[semantics wrapper for FunC]", + "value": "grams", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "C4", + "value": "mode", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "ty": undefined, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, "loc": FuncSrcInfo {}, - "value": "C4g", + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 24n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tag", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, }, - "ty": undefined, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "body", + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", "loc": FuncSrcInfo {}, - "value": "4C", }, - "ty": undefined, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "body", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": "_0x0", + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, }, - "ty": undefined, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, }, { - "globals": [ + "attributes": [ { - "kind": "global_variable", + "kind": "impure", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "_0", - }, - "ty": undefined, }, ], - "kind": "global_variables_declaration", + "forall": undefined, + "kind": "function_definition", "loc": FuncSrcInfo {}, - }, - { - "globals": [ + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + "parameters": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "0x_", + "value": "error_code", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "ty": undefined, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ { - "kind": "global_variable", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_info", + }, + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "error_code", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": "0x0_", + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message", + }, }, - "ty": undefined, + "kind": "statement_return", + "loc": FuncSrcInfo {}, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, }, { - "globals": [ + "attributes": [ { - "kind": "global_variable", + "kind": "impure", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "0_", - }, - "ty": undefined, }, ], - "kind": "global_variables_declaration", + "forall": undefined, + "kind": "function_definition", "loc": FuncSrcInfo {}, - }, - { - "globals": [ + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_ok", + }, + "parameters": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "hash#256", + "value": "price", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "ty": undefined, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": "💀💀💀0xDEADBEEF💀💀💀", + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "raw_reserve", + }, }, - "ty": undefined, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, "loc": FuncSrcInfo {}, - "value": "__tact_verify_address", + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_info", + }, }, - "ty": undefined, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4016791929n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": "__tact_pow2", + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message", + }, }, - "ty": undefined, + "kind": "statement_return", + "loc": FuncSrcInfo {}, }, ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, }, { - "globals": [ + "attributes": [ { - "kind": "global_variable", + "kind": "impure", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "randomize_lt", - }, - "ty": undefined, }, ], - "kind": "global_variables_declaration", + "forall": undefined, + "kind": "function_definition", "loc": FuncSrcInfo {}, - }, - { - "globals": [ + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "housekeeping", + }, + "parameters": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "fixed248::asin", + "value": "ctl", }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "ty": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "fixed248::nrand_fast", + "value": "cell", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "atan_f261_inlined", + "value": "dd", }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", + "ty": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "f̷̨͈͚́͌̀i̵̩͔̭̐͐̊n̸̟̝̻̩̎̓͋̕e̸̝̙̒̿͒̾̕", + "value": "cell", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "❤️❤️❤️thanks❤️❤️❤️", + "value": "gc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", }, - "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "intslice", + "value": "prices", }, "ty": undefined, }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ { - "kind": "global_variable", + "kind": "parameter", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "int2", + "value": "nhk", }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "impure_touch", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict::delete_get_min", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "something", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, - "pragmas": [], -} -`; - -exports[`FunC grammar and parser should parse include_stdlib 1`] = ` -{ - "includes": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "../../../stdlib/stdlib.fc", - }, - }, - ], - "items": [], - "kind": "module", - "loc": FuncSrcInfo {}, - "pragmas": [], -} -`; - -exports[`FunC grammar and parser should parse literals-and-comments 1`] = ` -{ - "includes": [], - "items": [ - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "integers", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "integer_literal", + "ty": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": 42n, + "value": "int", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - "kind": "statement_expression", + "kind": "parameter", "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "integer_literal", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": 42n, + "value": "lhk", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "integer_literal", + "ty": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": -42n, + "value": "int", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, { - "expression": { - "kind": "integer_literal", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": -42n, + "value": "max_steps", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "integer_literal", + "ty": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": -42n, + "value": "int", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "strings", - }, - "parameters": [], "returnTy": { "kind": "unit", "loc": FuncSrcInfo {}, @@ -4773,549 +5235,121313 @@ exports[`FunC grammar and parser should parse literals-and-comments 1`] = ` "statements": [ { "expression": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "slice", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_singleline", + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, "loc": FuncSrcInfo {}, - "ty": "s", - "value": "2A", + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, }, "kind": "statement_expression", "loc": FuncSrcInfo {}, }, { - "expression": { - "kind": "string_singleline", + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 60n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max", + }, + }, + }, + ], + "kind": "expression_tensor", "loc": FuncSrcInfo {}, - "ty": "a", - "value": "EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dd", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mkey", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_min?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_steps", + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mkey", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mkey", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "%", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dd", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_delete?", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dd", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_delete?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mkey", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_min?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "alternative": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4294967295n, + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + "consequence": { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mkey", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": ">>", + }, + ], + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_steps", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dd", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "calcprice_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 100n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_data_size", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_bits", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_owner", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_info", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "strict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "strict", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4000281702n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_info", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "strict", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4000263474n, + }, + "op": "&", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ERR_BAD2", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3798033458n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sown", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_info", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sown", + }, + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "+", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ERR_BAD2", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sown", + }, + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 40915n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ERR_BAD2", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_wc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sown", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sown", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_wc", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_addr", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4000282478n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "perform_ctl_op", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4000282478n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1130909810n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_ok", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_info", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1128555884n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "housekeeping", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4000605549n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4016791929n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1415670629n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4016791929n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4294967295n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg_cell", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_msg_addr", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "parse_std_addr", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_info", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 31n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 24n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 67n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "perform_ctl_op", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1919248228n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1886547820n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1970300004n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1735354211n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4294967295n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_steps", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_steps", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "housekeeping", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4016791929n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain_cell", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_maybe_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fail", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_bits_refs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fail", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bytes", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fail", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bytes", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bytes", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "*", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fail", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fail", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_last", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fail", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4000275504n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_info", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": "^>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "skip_last_bits", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "string_hash", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cown", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_ref?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_info", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cown", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4017511472n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "owner_info", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_owner", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "dict_empty?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "oinfo", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_ref?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "oinfo", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 31n, + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "+", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 31n, + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 19n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 40915n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "minok", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_min?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "maxok", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_max?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 31n, + }, + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "minok", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "maxok", + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tuple_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3545187910n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "calcprice_internal", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3883023472n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "req_expires_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + "op": "+", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4083511919n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gckeyO", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gckeyN", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gckeyO", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_delete?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gckeyO", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gckeyN", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "housekeeping", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_ok", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3781980773n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_error", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expires_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expires_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gckey", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expires_at", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "op": "|", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gckey", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expires_at", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "housekeeping", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_ok", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qt", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domdata", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "housekeeping", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_ok", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dd", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nhk", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lhk", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ctl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dd", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "gc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prices", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4294967295n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dnsdictlookup", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nowtime", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain_last_byte", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_last", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain_last_byte", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain_first_byte", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain_first_byte", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail_bits", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "skip_last_bits", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "string_hash", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "-", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nowtime", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail_bits", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail_bits", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "skip_last_bits", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail_bits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dnsresolve", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "category", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exact?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dnsdictlookup", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exact?", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exact?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "category", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "H", + "value": "dns_next_resolver", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx_bits", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_found", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_ref_", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "category", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx_bits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "category", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx_bits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "getexpirationx", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nowtime", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nowtime", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dnsdictlookup", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exp", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "getexpiration", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "getexpirationx", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "getstdperiod", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_prices", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stdper", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "getppr", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_prices", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "getppc", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_prices", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "getppb", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_prices", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "calcprice", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_prices", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "calcprice_internal", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "calcregprice", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_prices", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppr", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "domain", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ppb", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "calcprice_internal", + }, + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse dns-manual-code 1`] = ` +{ + "items": [ + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUGETOPTREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_ref_", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfxdict_set_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "pfxdict_set?", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_maybe_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfxdict_get_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "succ", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "pfxdict_get?", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "alternative": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "succ", + }, + "consequence": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_maybe_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "succ", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "contract_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "contract_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg_cell", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1666n, + }, + }, + ], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "after_code_upgrade", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_code", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cont", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "process_op", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 10n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_code", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_code", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_code", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_code", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_c3", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "bless", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_code", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_c3", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_code", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "after_code_upgrade", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 45n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 20n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "is_name_ref", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "*", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name_len", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "is_name_ref", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 38n, + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name_last_byte", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_last", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 40n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name_last_byte", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cname", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cname", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": "^>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cname", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 20n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "succ", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "pfxdict_get_ref", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1023n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "succ", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_empty?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 11n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_maybe_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_get_ref", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_value", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "pfxdict_set_ref", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1023n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 12n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_delete?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "pfxdict_set_ref", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1023n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 21n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_cat_table", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_maybe_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "pfxdict_set_ref", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1023n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_cat_table", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 22n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "pfxdict_delete?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1023n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 31n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_tree_root", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_maybe_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_tree_root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 44n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "process_ops", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stop", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stop", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "process_op", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_data_empty?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stop", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "contract_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "shash", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_contract", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bound", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bound", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "contract_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_contract", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "shash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "process_ops", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 51n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bound", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "queries", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries'", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_delete_get_min", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bound", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries'", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "contract_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1666n, + }, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "after_code_upgrade", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ops", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_code", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cont", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_contract_id", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_public_key", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dnsresolve", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subdomain", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "category", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subdomain", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name_last_byte", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_last", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subdomain", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name_last_byte", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subdomain", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subdomain", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name_first_byte", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subdomain", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "name_first_byte", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subdomain", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cname", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subdomain", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cname", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cname", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cname", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfxname", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subdomain", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "succ", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "pfxdict_get_ref", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1023n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfxname", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "root", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "succ", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "^", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "zeros", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_empty?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "category", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "H", + "value": "dns_next_resolver", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx_bits", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_bits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_found", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_ref_", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "category", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx_bits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "category", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfx_bits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cat_table", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse elector-code 1`] = ` +{ + "items": [ + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_elect", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "es", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "es", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "es", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "es", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "es", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "es", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "es", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "es", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "es", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_elect", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_past_election", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_past_election", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_complaint_status", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 45n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_complaint_status", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 45n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_complaint", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 188n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "-", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_complaint", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "description", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "created_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "severity", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine_part", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 188n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "-", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "description", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "created_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "severity", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine_part", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_complaint_prices", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "info", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "info", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 26n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_complaint_prices", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "info", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 13n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "alternative": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "parse_complaint_prices", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "info", + }, + }, + "condition": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "info", + }, + }, + "consequence": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 36n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_validator_conf", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 15n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_current_vset", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_parse", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 40n, + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 18n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_weight", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_weight", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_validator_descr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_weight", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_current_vset", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_weight", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_validator_descr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 41n, + }, + { + "kind": "expression_compare", + "left": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 83n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 41n, + }, + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2390828938n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ans_tag", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "body", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 24n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ans_tag", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "body", + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "body", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stake", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reason", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4000269644n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reason", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_confirmation", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "comment", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4084484172n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "comment", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1000000000n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_validator_set_to_config", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 50431n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 17n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1314280276n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "credit_to", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "process_new_stake", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_std_addr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_at", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1699500148n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_data_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 65536n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_elect", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1000000000n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 12n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_at", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mem", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mem", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mem", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mem", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 5n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 44n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_confirmation", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_without_bonuses", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "freeze_dict", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stakes", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recovered", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_next?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "freeze_dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "banned", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "credit_to", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "banned", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recovered", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 59n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stakes", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recovered", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_with_bonuses", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "freeze_dict", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stakes", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_bonuses", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recovered", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "returned_bonuses", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_next?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "freeze_dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "banned", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonus", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stakes", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldiv", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ed_bonuses", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonus", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "credit_to", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonus", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "banned", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recovered", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 59n, + }, + { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stakes", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "returned_bonuses", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_bonuses", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recovered", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_bonuses", + }, + "op": "+", + }, + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "returned_bonuses", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stakes_sum", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_next?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_all", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_id", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_delete_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fdict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stakes", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_past_election", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unused_prizes", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "alternative": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "unfreeze_without_bonuses", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fdict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stakes", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequence": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "unfreeze_with_bonuses", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fdict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stakes", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unused_prizes", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_set_confirmed", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_std_addr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_addr", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_addr", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + { + "expr": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_elect", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unused_prizes", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_all", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unused_prizes", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "process_simple_transfer", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_std_addr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_past_election", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_past_election", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recover_stake", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_std_addr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4294967294n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_delete_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4294967294n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 24n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4184830756n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1666n, + }, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "after_code_upgrade", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1313042276n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3460525924n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "upgrade_code", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c_addr", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c_addr", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_addr", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c_addr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_std_addr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_addr", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "code", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "code", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_code", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_empty?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "bless", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "code", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_c3", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "after_code_upgrade", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "register_complaint", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_std_addr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_wc", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_depth", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -3n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -2n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_in", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_in", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -4n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "description", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "created_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "severity", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine_part", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_complaint", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward_addr", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "created_at", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "deposit", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bit_price", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cell_price", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_complaint_prices", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4096n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_compute_data_size", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pps", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1024n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bit_price", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cell_price", + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pps", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_in", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "deposit", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -5n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "description", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "created_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "severity", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine_part", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_complaint", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_past_election", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -6n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine_part", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldiv", + }, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_stake", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -7n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -8n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cstatus", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_complaint_status", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cpl_id", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "cell_hash", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_add_builder?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cpl_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cstatus", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -9n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_past_election", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "punish", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "description", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "created_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "severity", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine_part", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_complaint", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "banned", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "suggested_fine_part", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldiv", + }, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "banned", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": ">>", + }, + ], + }, + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "*", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "credit_to", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reward", + }, + "op": "-", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "register_vote", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "chash", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cstatus", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "chash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_vset", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_weight", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_current_vset", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_vset_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "cell_hash", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_vset", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cstatus", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_complaint_status", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_old?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_id", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_vset_id", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_old?", + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_old?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_id", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_vset_id", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_weight", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldiv", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_wr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_wr", + }, + "loc": FuncSrcInfo {}, + "op": "^=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "chash", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_complaint_status", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_wr", + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "proceed_register_vote", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "chash", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -2n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_past_election", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accepted_complaint", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "status", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "chash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "register_vote", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "status", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "status", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accepted_complaint", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine_unalloc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine_collected", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accepted_complaint", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "punish", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine_unalloc", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fine_collected", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_past_election", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "status", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg_cell", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_msg_addr", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_empty?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "process_simple_transfer", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "process_simple_transfer", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1316189259n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "process_new_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1197831204n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recover_stake", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1313042276n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "upgrade_code", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "alternative": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4294967295n, + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + "consequence": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3460525924n, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cfg_ok", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4000730955n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cfg_ok", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4000730991n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cfg_ok", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_set_confirmed", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1382499184n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "register_complaint", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ans_tag", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "price", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "raw_reserve", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ans_tag", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ans_tag", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4066861904n, + }, + "op": "+", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1450460016n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_body", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sign_tag", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "chash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 37n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sign_tag", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1450459984n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vdescr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_weight", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_validator_descr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val_pubkey", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vdescr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_validator_descr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_body", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val_pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_data_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "chash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idx", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "proceed_register_vote", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3597947456n, + }, + "op": "+", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 31n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4294967295n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_message_back", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "postpone_elections", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_total_stake", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m_stake", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "h", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "uncons", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "at", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "h", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "at", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "h", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_f", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m_stake", + }, + "op": "*", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "try_elect", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_stake", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_total_stake", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_stake_factor", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "calls": [ + { + "argument": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "config_param", + }, + }, + { + "argument": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + }, + ], + "kind": "expression_method", + "loc": FuncSrcInfo {}, + "object": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_validators", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_validators", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_validators", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_validators", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sdict", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_next?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "time", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "time", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "dict_set_builder", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "+", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_stake_factor", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sdict", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_validators", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_validators", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_dict", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_dict", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nil", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "dict::delete_get_min", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sdict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_f", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_f", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cons", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_validators", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l1", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l1", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l1", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cdr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "best_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "list_next", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "at", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l1", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_total_stake", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "best_stake", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "best_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "best_stake", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_total_stake", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_dict", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_dict", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l1", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l1", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l1", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cdr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m_stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l1", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "at", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "car", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_weight", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tuple_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_f", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "list_next", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 61n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true_stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_f", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m_stake", + }, + "op": "*", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true_stake", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true_stake", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 60n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "best_stake", + }, + "op": "/", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true_stake", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_weight", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vinfo", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "alternative": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 83n, + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + "consequence": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 115n, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2390828938n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vinfo", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vinfo", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pubkey", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true_stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "credit_to", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "src_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 49n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "best_stake", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_weight", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tot_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "conduct_elections", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_elect", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "postpone_elections", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 17n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_total_stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_stake_factor", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_total_stake", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "postpone_elections", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "postpone_elections", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vdict", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_weight", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stakes", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cnt", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_stake_factor", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "try_elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cnt", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cnt", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "postpone_elections", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_for", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_begin_before", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_end_before", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_validator_conf", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_end_before", + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 60n, + }, + "op": "-", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "main_validators", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 18n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_for", + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cnt", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cnt", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "main_validators", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_weight", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vdict", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_addr", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_validator_set_to_config", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_for", + }, + "op": "+", + }, + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + "op": "+", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "cell_hash", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stakes", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_past_election", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_active_vset_id", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_hash", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "cell_hash", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_hash", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_time", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs0", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 57n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_time", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_time", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs0", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_next?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tm", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_hash", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tm", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "alternative": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "condition": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + }, + "consequence": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_hash", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cell_hash_eq?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expected_vset_hash", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "alternative": { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cell_hash", + }, + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expected_vset_hash", + }, + }, + "condition": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset", + }, + }, + "consequence": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_set_installed", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_elect", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "cell_hash_eq?", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 36n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "cell_hash_eq?", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_active_vset_id", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_unfreeze", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_next?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unused_prizes", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_all", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unused_prizes", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "announce_new_elections", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "next_vset", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 36n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "next_vset", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elector_addr", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "my_wc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "my_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "parse_std_addr", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "my_address", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "my_wc", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "my_addr", + }, + "loc": FuncSrcInfo {}, + "op": "!=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elector_addr", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_vset", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_vset", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_for", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_begin_before", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_end_before", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_validator_conf", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_valid_until", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_vset", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t0", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_valid_until", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_begin_before", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t0", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t0", + }, + "op": "-", + }, + ], + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 60n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t0", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 17n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_begin_before", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_end_before", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_dict", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "false", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "run_ticktock", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "is_tock", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "announce_new_elections", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "conduct_elections", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_set_installed", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_active_vset_id", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_unfreeze", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_election_id", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "alternative": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + "condition": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + "consequence": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "participates_in", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_elect", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mem", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "validator_pubkey", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "alternative": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + "consequence": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mem", + }, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "participant_list", + }, + "parameters": [], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nil", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_elect", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nil", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_prev?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cons", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "participant_list_extended", + }, + "parameters": [], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "null?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nil", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_elect", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nil", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_prev?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "members", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "time", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "adnl_addr", + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cons", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect_close", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "failed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "finished", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_returned_stake", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "wallet_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "wallet_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "alternative": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "consequence": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "val", + }, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_election_ids", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_prev?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cons", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_prev?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_past_election", + }, + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cons", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections_list", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_prev?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_past_election", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cons", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complete_unpack_complaint", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_complaint_status", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters_list", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voter_id", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voter_id", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_prev?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voter_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters_list", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voter_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters_list", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cons", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "expressions": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_complaint", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint", + }, + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "voters_list", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "weight_remaining", + }, + ], + "kind": "expression_tuple", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_past_complaints", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elect", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "credits", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "grams", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "active_hash", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "past_elections", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unfreeze_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stake_held", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vset_hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "frozen_dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "total_stake", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bonuses", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_past_election", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "show_complaint", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "chash", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_past_complaints", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "chash", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "alternative": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + "consequence": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complete_unpack_complaint", + }, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list_complaints", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "election_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_past_complaints", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get_prev?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaints", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "id", + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complete_unpack_complaint", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pair", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cons", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "complaint_storage_price", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_in", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "deposit", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bit_price", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cell_price", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_complaint_prices", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pps", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1024n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bit_price", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "refs", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cell_price", + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pps", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_in", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "deposit", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "paid", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse expressions 1`] = ` +{ + "items": [], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse functions 1`] = ` +{ + "items": [ + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "void", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "params", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p1", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p3", + }, + "ty": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p4", + }, + "ty": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + ], + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p5", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + ], + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "poly", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p1", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "poly'", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p1", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p2", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + }, + ], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "attr", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + }, + ], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "attr'", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "attr''", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "body", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "XXX", + }, + }, + ], + }, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "everything", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "XXX", + }, + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "XXX", + }, + }, + "statements": [], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse globals 1`] = ` +{ + "items": [ + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob1", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob3", + }, + "ty": { + "kind": "type_mapped", + "loc": FuncSrcInfo {}, + "mapsTo": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "value": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob4", + }, + "ty": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_mapped", + "loc": FuncSrcInfo {}, + "mapsTo": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "value": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cont", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + ], + }, + }, + ], + }, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob5", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob6", + }, + "ty": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + ], + }, + }, + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "glob7", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse highload-wallet-code 1`] = ` +{ + "items": [ + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "idict_get_next?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_public_key", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse highload-wallet-v2-code 1`] = ` +{ + "items": [ + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bound", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bound", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "idict_get_next?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bound", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "queries", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries'", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_delete_get_min", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bound", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries'", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "i", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "processed?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "udict_get?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "old_queries", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "alternative": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query_id", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_cleaned", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + "consequence": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_public_key", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse identifiers 1`] = ` +{ + "items": [ + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query'", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "query''", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "CHECK", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "_internal_val", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "message_found?", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_pubkeys&signatures", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict::udict_set_builder", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "[semantics wrapper for FunC][semantics wrapper for FunC][semantics wrapper for FunC]", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fatal!", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "123validname", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "2+2=2*2", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "-alsovalidname", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "0xefefefhahaha", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "{hehehe}", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pa{--}in"\`aaa\`"", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "quoted_id", + "loc": FuncSrcInfo {}, + "value": "[semantics wrapper for FunC]I'm a function too[semantics wrapper for FunC]", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "quoted_id", + "loc": FuncSrcInfo {}, + "value": "[semantics wrapper for FunC]any symbols ; ~ () are allowed here...[semantics wrapper for FunC]", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "C4", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "C4g", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "4C", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "_0x0", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "_0", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "0x_", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "0x0_", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "0_", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash#256", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "💀💀💀0xDEADBEEF💀💀💀", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_verify_address", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "__tact_pow2", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "randomize_lt", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::asin", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::nrand_fast", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f261_inlined", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "f̷̨͈͚́͌̀i̵̩͔̭̐͐̊n̸̟̝̻̩̎̓͋̕e̸̝̙̒̿͒̾̕", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "❤️❤️❤️thanks❤️❤️❤️", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "intslice", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "globals": [ + { + "kind": "global_variable", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "int2", + }, + "ty": undefined, + }, + ], + "kind": "global_variables_declaration", + "loc": FuncSrcInfo {}, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "impure_touch", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict::delete_get_min", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_declaration", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "something", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse include_stdlib 1`] = ` +{ + "items": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "../../../stdlib/stdlib.fc", + }, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse literals-and-comments 1`] = ` +{ + "items": [ + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "integers", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "strings", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "slice", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "s", + "value": "2A", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "a", + "value": "EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "u", + "value": "int hex", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "h", + "value": "int 32 bits of sha256", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": "H", + "value": "int 256 bits of sha256", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { "kind": "string_singleline", "loc": FuncSrcInfo {}, - "ty": "u", - "value": "int hex", + "ty": "c", + "value": "int crc32", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": " + multi + line + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "s", + "value": "2A", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "a", + "value": "EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "u", + "value": " + ... + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "h", + "value": " + ... + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "H", + "value": " + ... + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "string_multiline", + "loc": FuncSrcInfo {}, + "ty": "c", + "value": " + ... + ", + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "comments!", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse mathlib 1`] = ` +{ + "items": [ + { + "kind": "include", + "loc": FuncSrcInfo {}, + "path": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "stdlib.fc", + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 4n, + "op": ">=", + "patch": 2n, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SGN", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sgn", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "UBITSIZE", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_floor_p1", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "MULRSHIFTR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "256 MULRSHIFTR#", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "256 MULRSHIFT#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshift256mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "256 MULRSHIFTR#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "255 MULRSHIFTR#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr255mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "248 MULRSHIFTR#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr248mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "5 MULRSHIFTR#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr5mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "6 MULRSHIFTR#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr6mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "7 MULRSHIFTR#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr7mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "256 LSHIFT#DIVR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "256 LSHIFT#DIVMODR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divmodr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "255 LSHIFT#DIVMODR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift255divmodr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "2 LSHIFT#DIVMODR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift2divmodr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "7 LSHIFT#DIVMODR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift7divmodr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "LSHIFTDIVMODR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshiftdivmodr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "256 RSHIFTR#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rshiftr256mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "248 RSHIFTR#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rshiftr248mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "4 RSHIFTR#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rshiftr4mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "3 RSHIFT#MOD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rshift3mod", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SUBR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sub_rev", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PUSHNAN", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nan", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "ISNAN", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "is_nan", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "geom_mean", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_floor_p1", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_floor_p1", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "alternative": { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "<<", + }, + ], + }, + "condition": { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + }, + "consequence": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "op": "+", + }, + ], + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivc", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sqrt", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "geom_mean", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::sqrt", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "geom_mean", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed255::sqrt", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "geom_mean", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::sqr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed255::sqr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "constants": [ + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::One", + }, + "ty": "int", + "value": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + ], + "kind": "constants_definition", + "loc": FuncSrcInfo {}, + }, + { + "constants": [ + { + "kind": "constant", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed255::One", + }, + "ty": "int", + "value": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + ], + "kind": "constants_definition", + "loc": FuncSrcInfo {}, + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_xconst_f256", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 80260960185991308862233904206310070533990667611589946606122867505419956976172n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -32272921378999278490133606779486332143n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_xconst_f254", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 90942894222941581070058735694432465663348344332098107489693037779484723616546n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 108051869516004014909778934258921521947n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Atan1_16_f260", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 115641670674223639132965820642403718536242645001775371762318060545014644837101n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Atan1_8_f259", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 115194597005316551477397594802136977648153890007566736408151129975021336532841n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Atan1_32_f261", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 115754418570128574501879331591757054405465733718902755858991306434399246026247n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_const_f256", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_xconst_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::log2_const", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_const_f256", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "~>>", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_const_f254", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_xconst_f254", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::Pi_const", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_const_f254", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + "op": "~>>", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tanh_f258", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_bitwise_shift", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 5n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 250n, + }, + "op": "<<", + }, + ], + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Two", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 251n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Two", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 239n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 254n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 243n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expm1_f257", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Two", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 251n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 39n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 250n, + }, + "op": "<<", + }, + ], + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 17n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Two", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 239n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 254n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 243n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "~/", + }, + ], + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "~/", + }, + ], + }, + "op": "-", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::exp", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l2c", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l2d", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_xconst_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l2c", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshiftdivmodr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l2d", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 127n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expm1_f257", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::exp2", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rshiftr248mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_const_f256", + }, + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 247n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expm1_f257", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_f260_inlined", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Two", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 251n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 250n, + }, + "op": "<<", + }, + ], + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 14n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Two", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 236n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 254n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 240n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 10n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_f260", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_f260_inlined", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_f258_inlined", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Two", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 251n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 41n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 250n, + }, + "op": "<<", + }, + ], + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 18n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Two", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 240n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 254n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 244n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 5n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_f258", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_f258_inlined", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sincosm1_f259_inlined", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_f260_inlined", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tt", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tt", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tt", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "~/", + }, + ], + }, + "op": "-", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tt", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tt", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tt", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "~/", + }, + ], + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sincosm1_f259", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sincosm1_f259_inlined", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sincosn_f256", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xe", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x1", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "abs", + }, + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Atan1_8_f259", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift2divmodr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x1", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xe", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sincosm1_f259", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 63n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "op": "*", + }, + ], + }, + "op": "-", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 63n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 65n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "op": "*", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "br", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divmodr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "br", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "br", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ar", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divmodr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ar", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ar", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sgn", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "br", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "*", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ar", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "~/", + }, + ], + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sincosm1_f256", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sincosm1_f259_inlined", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r", + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_aux_f256", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_f258_inlined", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tt", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tt", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tt", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::sincos", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pic", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pid", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_xconst_f254", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pic", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift7divmodr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pid", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 127n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sincosm1_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + "loc": FuncSrcInfo {}, + "op": "~>>=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::sin", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::sincos", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "si", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::cos", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::sincos", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "co", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::tan", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pic", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pid", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_xconst_f254", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pic", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift7divmodr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pid", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 127n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_aux_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::cot", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pic", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pid", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_xconst_f254", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pic", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift7divmodr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pid", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 127n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tan_aux_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atanh_f258", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 254n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + { + "expressions": [ + { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n1", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n1", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "/", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "~/", + }, + ], + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "~/", + }, + ], + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atanh_f261_inlined", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 254n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 242n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + { + "expressions": [ + { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n1", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n1", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4096n, + }, + "op": "~/", + }, + ], + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4096n, + }, + "op": "~/", + }, + ], + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atanh_f261", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atanh_f261_inlined", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log_aux_f257", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_floor_p1", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "<<=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 249n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 90n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": ">>=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "2x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "op": "*", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + }, + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 36n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atanh_f258", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow33", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": "*=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow33b", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mh", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ml", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "m", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 5n, + }, + "op": "/%", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ml", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": "*=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "iterations": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mh", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": "*=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + "op": "*", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + "op": "*", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + "op": "*", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + "op": "*", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log_auxx_f260", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_floor_p1", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "<<=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2873n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 244n, + }, + "op": "<<", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x1", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_bitwise_shift", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": ">>", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x1", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 65n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x1", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 11n, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow33b", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": "<<=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 51n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 5n, + }, + "op": "*", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 18n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atanh_f261", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log_aux_f256", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log_auxx_f260", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "yh", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "yl", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rshiftr4mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "yh", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "expression_bitwise_shift", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "yl", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -3769n, + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 13n, + }, + "op": "~>>", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Log33_32", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3563114646320977386603103333812068872452913448227778071188132859183498739150n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "yh", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Log33_32", + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_aux_f256", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log_auxx_f260", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_const_f256", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "~>>", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Log33_32", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 5140487830366106860412008603913034462883915832139695448455767612111363481357n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Log33_32", + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::log", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log_aux_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "-", + }, + ], + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_const_f256", + }, + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::log2", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_aux_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::pow", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bad", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_compare", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bad", + }, + "op": ">>", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_aux_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q1", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r1", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr248mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q2", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r2", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "l", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshift256mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r2", + }, + "loc": FuncSrcInfo {}, + "op": ">>=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 247n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q3", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r3", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q2", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rshiftr248mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ll", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r1", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r3", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rshiftr248mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ll", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ll", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r2", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q1", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q3", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sq", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sq", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sq", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ll", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "log2_const_f256", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expm1_f257", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sq", + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f259", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 254n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 246n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + { + "expressions": [ + { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n1", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n1", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "~/", + }, + ], + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "~/", + }, + ], + }, + "op": "-", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f261_inlined", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 254n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 242n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + { + "expressions": [ + { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n1", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "-", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "One", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n1", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x2", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4096n, + }, + "op": "~/", + }, + ], + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4096n, + }, + "op": "~/", + }, + ], + }, + "op": "-", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f261", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "n", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f261_inlined", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_aux_prereduce", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xu", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "abs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tc", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7214596n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t1", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xu", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tc", + }, + "op": "-", + }, + ], + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 88n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xu", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tc", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 48n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t1", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3073n, + }, + "op": "*", + }, + ], + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 59n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t1", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t1", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 13n, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pa", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pb", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33226912n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 5232641n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qh", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ql", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 5n, + }, + "op": "/%", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 5n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 51n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "*", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "<<", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ql", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "op": "*", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sub_rev", + }, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "iterations": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qh", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pa", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pb", + }, + "op": "*", + }, + ], + }, + "op": "-", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pb", + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pa", + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sgn", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xs", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + "op": "*", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xs", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "op": "*", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_aux_f256", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 232n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_aux_prereduce", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ul", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ul", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 250n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 18n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f261_inlined", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_auxx_f256", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 232n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_aux_prereduce", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ul", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ul", + }, + "loc": FuncSrcInfo {}, + "op": "/=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vl", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vl", + }, + "loc": FuncSrcInfo {}, + "op": "/=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift255divmodr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "yl", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ul", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r", + }, + "op": "+", + }, + ], + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "vl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "yl", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 249n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 18n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f261_inlined", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f255", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "*=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_aux_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_h", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_l", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_xconst_f254", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qh", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ql", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Atan1_32_f261", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr6mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qh", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_h", + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ql", + }, + "op": "+", + }, + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_l", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 122n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "~/", + }, + ], + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f256_small", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_aux_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qh", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ql", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Atan1_32_f261", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr5mod", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "qh", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ql", + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "~/", + }, + ], + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "asin_f255", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed255::One", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed255::sqr", + }, + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sgn", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_const_f254", + }, + }, + "op": "*", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed255::sqrt", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f256_small", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "acos_f255", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_const_f254", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi", + }, + "loc": FuncSrcInfo {}, + "op": "/=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed255::One", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed255::sqr", + }, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed255::sqrt", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_f256_small", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": "~/", + }, + ], + }, + "op": "+", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::asin", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "asin_f255", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "op": "~>>", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::acos", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "acos_f255", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + "op": "~>>", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::atan", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 249n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "<<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sgn", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_aux_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "~/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_const_f254", + }, + }, + "op": "*", + }, + ], + }, + "op": "+", + }, + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Atan1_32_f261", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "~/", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::acot", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 249n, + }, + "op": "~>>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "<<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sgn", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 248n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "lshift256divr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "atan_aux_f256", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Pi_const_f254", + }, + }, + "op": "*", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "~/", + }, + ], + }, + "op": "-", + }, + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "q", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Atan1_32_f261", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "~/", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nrand_f252", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r0", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nan", + }, + }, + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 29483n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 236n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -3167n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 239n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 12845n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16693n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9043n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "kind": "expression_unary", + "loc": FuncSrcInfo {}, + "op": "~", + "operand": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "is_nan", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "random", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "random", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "-", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7027n, + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "va", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "abs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u1", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v1", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "op": "-", + }, + ], + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "va", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "op": "-", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Q", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u1", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u1", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 252n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v1", + }, + { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v1", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u1", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "-", + }, + ], + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 252n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Qd", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Q", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 237n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "r0", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Qd", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9125n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9043n, + }, + "op": "-", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "va", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + "op": "/", + }, + ], + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "v", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 252n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Qd", + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xx", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mulrshiftr256", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "~/", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ex", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xx", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::exp", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "*", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "u", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ex", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nan", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nrand_fast_f252", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "touch", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 253n, + }, + "op": "<<", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "iterations": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 12n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "random", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "/", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::random", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "random", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": ">>", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::nrand", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nrand_f252", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "~>>", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fixed248::nrand_fast", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "nrand_fast_f252", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "~>>", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse payment-channel-code 1`] = ` +{ + "items": [ + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "31 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:wrong_a_signature", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "32 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:wrong_b_signature", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "33 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:msg_value_too_small", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "34 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:replay_protection", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "35 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:no_timeout", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "36 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:expected_init", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "37 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:expected_close", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "37 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:expected_payout", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "38 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:no_promise_signature", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "39 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:wrong_channel_id", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "40 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:unknown_op", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "41 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:not_enough_fee", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "0x912838d1 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op:pchan_cmd", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "0x27317822 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:init", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "0xf28ae183 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:close", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "0x43278a28 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:timeout", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "0x37fe7810 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:payout", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "0 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state:init", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "1 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state:close", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "2 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state:payout", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "1000000000 PUSHINT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_fee", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_data", + }, + "parameters": [], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_data", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_config", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "res", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unwrap_signatures", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_sig", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_sig", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b?", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_sig", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_sig", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_hash", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:wrong_a_signature", + }, + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_sig", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:wrong_b_signature", + }, + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_sig", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a?", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_state_init", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_state_init", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state:init", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_B", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_state_close", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_state_close", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state:close", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_payout", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:payout", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "do_payout", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "diff", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "diff", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "diff", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "loc": FuncSrcInfo {}, + "negateLeft": true, + "ops": [], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "diff", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "diff", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "diff", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "diff", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_payout", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_payout", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state:payout", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "with_init", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "init_timeout", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A_extra", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_state_init", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "init_timeout", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:timeout", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:no_timeout", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "do_payout", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:expected_init", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:init", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "upd_min_A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "upd_min_B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "got_channel_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:wrong_channel_id", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "got_channel_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:msg_value_too_small", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_A", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_B", + }, + "op": "+", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:replay_protection", + }, + }, + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_A", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "inc_B", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + "loc": FuncSrcInfo {}, + "op": "|=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "upd_min_A", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "upd_min_A", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + "loc": FuncSrcInfo {}, + "op": "|=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_B", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "upd_min_B", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_B", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "upd_min_B", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "loc": FuncSrcInfo {}, + "op": "-=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A_extra", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_B", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "do_payout", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_state_close", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_state_init", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "with_close", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_timeout", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_state_close", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_timeout", + }, + "op": "+", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:timeout", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:no_timeout", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "do_payout", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:expected_close", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:close", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:replay_protection", + }, + }, + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + "loc": FuncSrcInfo {}, + "op": "|=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + "loc": FuncSrcInfo {}, + "op": "|=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "extra_A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "extra_B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "has_sig", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:no_promise_signature", + }, + }, + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "extra_A", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "extra_B", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "has_sig", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sig", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_hash", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:wrong_a_signature", + }, + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sig", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "extra_A", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:wrong_b_signature", + }, + }, + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "sig", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "extra_B", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "got_channel_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_promise_A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_promise_B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:wrong_channel_id", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "got_channel_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_promise_A", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "extra_A", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_promise_A", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_promise_A", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_promise_B", + }, + "loc": FuncSrcInfo {}, + "op": "+=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "extra_B", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_promise_B", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "update_promise_B", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "do_payout", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_A?", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signed_B?", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "promise_B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_state_close", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "with_payout", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:expected_payout", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg:payout", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:not_enough_fee", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1000000000n, + }, + "op": "+", + }, + ], + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "pair_first", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_balance", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "B", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_payout", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "A", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_payout", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_any", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_empty?", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "err:unknown_op", + }, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op:pchan_cmd", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpack_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "init_timeout", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "close_timeout", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A_extra", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "unpack_config", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "unwrap_signatures", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state_type", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state_type", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state:init", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "init_timeout", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_A_extra", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "with_init", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state_type", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state:close", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_A?", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_signed_B?", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "close_timeout", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "with_close", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state_type", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state:payout", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "channel_id", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "with_payout", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "state", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pack_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg_cell", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_any", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_any", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse pow-testgiver-code 1`] = ` +{ + "items": [ + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "UFITSX", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ufits", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bits", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_proof_of_work", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno_sw", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 24n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "whom", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdata1", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rseed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdata2", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_int", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "op": "-", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 10n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ufits", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 25n, + }, + { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rseed", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seed", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdata1", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdata2", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "randomize_lt", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdata1", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "randomize", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_success", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xdata", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xdata", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "target_delta", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_cpl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_cpl", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "delta", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_success", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "delta", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "factor", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "delta", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "target_delta", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "factor", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "factor", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 7n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 125n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max", + }, + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 125n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "factor", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_cpl", + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max", + }, + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_cpl", + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno_sw", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "random", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": ">>", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xdata", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "commit", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 6n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 132n, + }, + "op": "|", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 9n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_int", + }, + { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + "op": ">>", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "whom", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_grams", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rescale_complexity", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "time", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 28n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "time", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "skipped_data", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_success", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xdata", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 64n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 29n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expire", + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_success", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xdata", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "target_delta", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "delta", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "time", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_success", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 30n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "delta", + }, + "loc": FuncSrcInfo {}, + "op": ">=", + "right": { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "target_delta", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 16n, + }, + "op": "*", + }, + ], + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min_cpl", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_cpl", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "factor", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "delta", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "target_delta", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_complexity", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_cpl", + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_complexity", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "<<", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldiv", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "alternative": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "factor", + }, + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "muldivr", + }, + }, + "condition": { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_factor", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "factor", + }, + }, + "consequence": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_complexity", + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_success", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "time", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "target_delta", + }, + "op": "-", + }, + ], + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "skipped_data", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_success", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xdata", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "update_params", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pref", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pref", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reset_cpl", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "last_success", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reset_cpl", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seed", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "randomize", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "reset_cpl", + }, + "op": "<<", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seed", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "kind": "expression_bitwise_shift", + "left": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "random", + }, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + "op": ">>", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seed", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_parse", + }, + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1298755173n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_proof_of_work", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "op", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1381196652n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rescale_complexity", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "kind": "expression_add_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "|", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ref", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": [ + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "update_params", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ref", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "loc": FuncSrcInfo {}, + "op": "<", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 255n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ref", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_slice", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_pow_params", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xdata", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 128n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "xdata", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seed", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pow_complexity", + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_public_key", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse pragmas 1`] = ` +{ + "items": [ + { + "kind": "pragma_literal", + "literal": "allow-post-modification", + "loc": FuncSrcInfo {}, + }, + { + "kind": "pragma_literal", + "literal": "compute-asm-ltr", + "loc": FuncSrcInfo {}, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": undefined, + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": undefined, + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": undefined, + "patch": 0n, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "=", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": "=", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": "=", + "patch": 0n, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "^", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "<", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": ">", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "<=", + "patch": undefined, + }, + }, + { + "allow": true, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": ">=", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": undefined, + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": undefined, + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": undefined, + "patch": 0n, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "=", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": "=", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": 0n, + "op": "=", + "patch": 0n, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "^", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "<", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": ">", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": "<=", + "patch": undefined, + }, + }, + { + "allow": false, + "kind": "pragma_version_range", + "loc": FuncSrcInfo {}, + "range": { + "kind": "version_range", + "loc": FuncSrcInfo {}, + "major": 0n, + "minor": undefined, + "op": ">=", + "patch": undefined, + }, + }, + { + "kind": "pragma_version_string", + "loc": FuncSrcInfo {}, + "version": { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "0.4.4", + }, + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse restricted-wallet-code 1`] = ` +{ + "items": [ + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "inline", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "restricted?", + }, + "parameters": [], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -13n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "alternative": { + "kind": "expression_compare", + "left": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_parse", + }, + }, + "loc": FuncSrcInfo {}, + "op": ">", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + "condition": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null?", + }, + }, + "consequence": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_destination", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": undefined, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dest", + }, + "ty": undefined, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 4n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "expression_mul_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "flags", + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + "op": "&", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s_addr", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "d_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_msg_addr", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_msg_addr", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dest_wc", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dest_addr", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "d_addr", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_std_addr", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_mul_bitwise", + "left": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dest_wc", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "ops": [ + { + "expr": { + "expressions": [ + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dest_addr", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dest", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "op": "&", + }, + ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "restrict", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "restricted?", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elector", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "true", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "restrict", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "elector", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_destination", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ok", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_public_key", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "alternative": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "pair_first", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_balance", + }, + }, + "condition": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "restricted?", + }, + }, + "consequence": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse restricted-wallet2-code 1`] = ` +{ + "items": [ + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seconds_passed", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -13n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "alternative": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_parse", + }, + }, + "condition": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null?", + }, + }, + "consequence": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "alternative": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + "consequence": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + "op": "-", + }, + ], + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ts", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seconds_passed", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "idict_get_preveq?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ts", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "raw_reserve", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_public_key", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_balance_at", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ts", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seconds_passed", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "pair_first", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_balance", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "idict_get_preveq?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ts", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + }, + "op": "-", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance_at", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_balance_at", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_balance_at", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse restricted-wallet3-code 1`] = ` +{ + "items": [ + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seconds_passed", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "statements": [ + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -13n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "config_param", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "alternative": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_parse", + }, + }, + "condition": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null?", + }, + }, + "consequence": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "alternative": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": -1n, + }, + "condition": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + "consequence": { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + "op": "-", + }, + ], + }, + "kind": "expression_conditional", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 36n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ts", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seconds_passed", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "idict_get_preveq?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ts", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "raw_reserve", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_dict", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "wallet_id", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_public_key", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "inline_ref", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_balance_at", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "skip_bits", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + "op": "+", + }, + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + "op": "+", + }, + ], + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_dict", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ts", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "start_at", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seconds_passed", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "pair_first", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_balance", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "idict_get_preveq?", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ts", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "rdict", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "found", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_grams", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + }, + "op": "-", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance_at", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "utime", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_balance_at", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "balance", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_balance_at", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse simple-wallet-code 1`] = ` +{ + "items": [ + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs2", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_parse", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs2", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs2", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs2", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse simple-wallet-ext-code 1`] = ` +{ + "items": [ + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "create_state", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_state", + }, + "parameters": [], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs2", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_parse", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs2", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs2", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "save_state", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "create_state", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_internal", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "do_verify_message", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "expressions": [ + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_state", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "do_verify_message", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "alternatives": undefined, + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "consequences": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "save_state", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_public_key", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_state", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "create_init_state", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "create_state", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prepare_send_message_with_seqno", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_ref", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prepare_send_message", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + "statements": [ + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "prepare_send_message_with_seqno", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "verify_message", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_state", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "do_verify_message", + }, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse statements 1`] = ` +{ + "items": [ + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "return_stmt'", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + "statements": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "block_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [ + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "empty_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cond_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "alternatives": undefined, + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequences": [], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequences": [], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": undefined, + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequences": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": undefined, + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequences": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternatives": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequences": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": true, + }, + { + "alternatives": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequences": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_if", + "loc": FuncSrcInfo {}, + "positive": false, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [], + "consequencesIf": [], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": true, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [], + "consequencesIf": [], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": true, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [], + "consequencesIf": [], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": false, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [], + "consequencesIf": [], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": false, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": true, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": true, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": false, + }, + { + "alternativesElseif": undefined, + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": false, + }, + { + "alternativesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": true, + "positiveIf": true, + }, + { + "alternativesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "conditionElseif": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "conditionIf": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "consequencesElseif": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "consequencesIf": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "statement_condition_elseif", + "loc": FuncSrcInfo {}, + "positiveElseif": false, + "positiveIf": false, + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "repeat_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "iterations": { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [], + }, + { + "iterations": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "until_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [], + }, + { + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_until", + "loc": FuncSrcInfo {}, + "statements": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [ + { + "iterations": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [], + }, + ], + }, + ], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "while_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [], + }, + { + "condition": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [ + { + "iterations": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "kind": "statement_repeat", + "loc": FuncSrcInfo {}, + "statements": [], + }, + ], + }, + ], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "try_catch_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "catchExceptionName": { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "catchExitCodeName": { + "kind": "unused_id", + "loc": FuncSrcInfo {}, + "value": "_", + }, + "kind": "statement_try_catch", + "loc": FuncSrcInfo {}, + "statementsCatch": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [], + }, + ], + "statementsTry": [ + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_empty", + "loc": FuncSrcInfo {}, + }, + { + "kind": "statement_block", + "loc": FuncSrcInfo {}, + "statements": [], + }, + ], + }, + { + "catchExceptionName": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exception", + }, + "catchExitCodeName": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "exit_code", + }, + "kind": "statement_try_catch", + "loc": FuncSrcInfo {}, + "statementsCatch": [], + "statementsTry": [], + }, + ], + }, + { + "attributes": [], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "expression_stmt", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [ + { + "expression": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 42n, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse stdlib 1`] = ` +{ + "items": [ + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CONS", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cons", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "head", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tail", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "UNCONS", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "uncons", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "UNCONS", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list_next", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CAR", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "car", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CDR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cdr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "list", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NIL", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "empty_tuple", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "TPUSH", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tpush", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "TPUSH", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "tpush", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SINGLE", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "single", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + ], + "returnTy": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "UNSINGLE", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unsingle", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PAIR", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pair", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + }, + ], + "returnTy": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "UNPAIR", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "unpair", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "TRIPLE", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "triple", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + }, + ], + "returnTy": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "UNTRIPLE", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "untriple", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "4 TUPLE", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "W", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "tuple4", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "z", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "w", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "W", + }, + }, + }, + ], + "returnTy": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "W", + }, + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "4 UNTUPLE", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "W", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "untuple4", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "W", + }, + }, + ], + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "W", + }, + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "FIRST", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "first", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SECOND", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "second", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "THIRD", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "third", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "3 INDEX", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "fourth", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "t", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "FIRST", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pair_first", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SECOND", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pair_second", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + ], + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "FIRST", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "triple_first", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SECOND", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "triple_second", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "THIRD", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "triple_third", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "p", + }, + "ty": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Y", + }, + }, + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + ], + }, + }, + ], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "Z", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PUSHNULL", + }, + ], + "attributes": [], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "null", + }, + "parameters": [], + "returnTy": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NOP", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": { + "kind": "forall", + "loc": FuncSrcInfo {}, + "tyVars": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + ], + }, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "impure_touch", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "keyword": false, + "kind": "type_var", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "X", + }, + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NOW", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "MYADDR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "my_address", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "BALANCE", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_balance", + }, + "parameters": [], + "returnTy": { + "kind": "type_tuple", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "LTIME", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cur_lt", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "BLOCKLT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "block_lt", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "HASHCU", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cell_hash", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "HASHSU", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SHA256U", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "string_hash", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CHKSIGNU", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "hash", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CHKSIGNS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_data_signature", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "data", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CDATASIZE", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_data_size", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_cells", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDATASIZE", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_compute_data_size", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_cells", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "compute_data_size?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_cells", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_compute_data_size?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max_cells", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DUMPSTK", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dump_stack", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "c4 PUSH", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "c4 POP", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "c3 PUSH", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_c3", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cont", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "c3 POP", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_c3", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cont", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "BLESS", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "bless", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cont", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "ACCEPT", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SETGASLIMIT", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_gas_limit", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "limit", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "COMMIT", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "commit", + }, + "parameters": [], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "BUYGAS", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "buy_gas", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "MIN", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "min", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "MAX", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "max", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "MINMAX", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "minmax", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "y", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "ABS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "abs", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CTOS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_parse", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "ENDS", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "end_parse", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "LDREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PLDREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "preload_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "LDGRAMS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_grams", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "LDGRAMS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_coins", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDSKIPFIRST", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "skip_bits", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDSKIPFIRST", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "skip_bits", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDCUTFIRST", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "first_bits", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDSKIPLAST", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "skip_last_bits", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDSKIPLAST", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "skip_last_bits", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDCUTLAST", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_last", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "LDDICT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_dict", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PLDDICT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "preload_dict", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SKIPDICT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "skip_dict", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "LDOPTREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_maybe_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PLDOPTREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "preload_maybe_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CDEPTH", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cell_depth", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SREFS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_refs", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SBITS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_bits", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SBITREFS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_bits_refs", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SEMPTY", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_empty?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDEMPTY", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_data_empty?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SREMPTY", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_refs_empty?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDEPTH", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_depth", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "BREFS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "builder_refs", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "BBITS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "builder_bits", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "BDEPTH", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "builder_depth", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NEWC", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "ENDC", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "end_cell", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STSLICER", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_slice", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STGRAMS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_grams", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STGRAMS", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_coins", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STDICT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_dict", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STOPTREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "store_maybe_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "LDMSGADDR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "load_msg_addr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PARSEMSGADDR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_addr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "tuple", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "REWRITESTDADDR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_std_addr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "REWRITEVARADDR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "parse_var_addr", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "s", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTISETREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_set_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTISETREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "idict_set_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUSETREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_set_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUSETREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIGETOPTREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIGETREF", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_ref?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUGETREF", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_ref?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTISETGETOPTREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_set_get_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUSETGETOPTREF", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_set_get_ref", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIDEL", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_delete?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUDEL", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_delete?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIGET", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUGET", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIDELGET", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_delete_get?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUDELGET", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_delete_get?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIDELGET", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "idict_delete_get?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUDELGET", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_delete_get?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUSET", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_set", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUSET", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTISET", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_set", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTISET", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "idict_set", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTSET", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict_set", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTSET", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "dict_set", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUADD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_add?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUREPLACE", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_replace?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIADD", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_add?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIREPLACE", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_replace?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUSETB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_set_builder", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUSETB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict_set_builder", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTISETB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_set_builder", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTISETB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "idict_set_builder", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTSETB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict_set_builder", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTSETB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "dict_set_builder", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUADDB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_add_builder?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUREPLACEB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_replace_builder?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIADDB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_add_builder?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIREPLACEB", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_replace_builder?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "index", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUREMMIN", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_delete_get_min", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUREMMIN", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict::delete_get_min", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIREMMIN", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_delete_get_min", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIREMMIN", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "idict::delete_get_min", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTREMMIN", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict_delete_get_min", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTREMMIN", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "dict::delete_get_min", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUREMMAX", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_delete_get_max", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUREMMAX", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "udict::delete_get_max", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIREMMAX", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_delete_get_max", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIREMMAX", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "idict::delete_get_max", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTREMMAX", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict_delete_get_max", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 3n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTREMMAX", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "dict::delete_get_max", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUMIN", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_min?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUMAX", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_max?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUMINREF", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_min_ref?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUMAXREF", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_max_ref?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIMIN", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_min?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIMAX", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_max?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIMINREF", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_min_ref?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": undefined, + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIMAXREF", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_max_ref?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUGETNEXT", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_next?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUGETNEXTEQ", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_nexteq?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUGETPREV", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_prev?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTUGETPREVEQ", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "udict_get_preveq?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIGETNEXT", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_next?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIGETNEXTEQ", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_nexteq?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIGETPREV", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_prev?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 0n, + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 2n, + }, + ], + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTIGETPREVEQ", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "idict_get_preveq?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pivot", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NEWDICT", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_dict", + }, + "parameters": [], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "DICTEMPTY", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict_empty?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PFXDICTGETQ", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "NULLSWAPIFNOT2", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfxdict_get?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, { - "expression": { - "kind": "string_singleline", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "ty": "h", - "value": "int 32 bits of sha256", + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, { - "expression": { - "kind": "string_singleline", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "ty": "H", - "value": "int 256 bits of sha256", + "value": "key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, - { - "expression": { - "kind": "string_singleline", + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "ty": "c", - "value": "int crc32", + "value": "slice", }, - "kind": "statement_expression", + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "value", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PFXDICTSET", }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfxdict_set?", + }, + "parameters": [ { - "expression": { - "kind": "string_multiline", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "ty": undefined, - "value": " - multi - line - ", + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, { - "expression": { - "kind": "string_multiline", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "ty": "s", - "value": "2A", + "value": "key_len", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, { - "expression": { - "kind": "string_multiline", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "ty": "a", - "value": "EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT", + "value": "key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, { - "expression": { - "kind": "string_multiline", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "ty": "u", - "value": " - ... - ", + "value": "value", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, - { - "expression": { - "kind": "string_multiline", + ], + "returnTy": { + "kind": "type_tensor", + "loc": FuncSrcInfo {}, + "types": [ + { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "ty": "h", - "value": " - ... - ", + "value": "cell", }, - "kind": "statement_expression", + { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + ], + }, + }, + { + "arrangement": { + "arguments": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "dict", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key_len", + }, + ], + "kind": "asm_arrangement", + "loc": FuncSrcInfo {}, + "returns": undefined, + }, + "asmStrings": [ + { + "kind": "string_singleline", "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "PFXDICTDEL", }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "pfxdict_delete?", + }, + "parameters": [ { - "expression": { - "kind": "string_multiline", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "ty": "H", - "value": " - ... - ", + "value": "dict", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, }, { - "expression": { - "kind": "string_multiline", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "ty": "c", - "value": " - ... - ", + "value": "key_len", }, - "kind": "statement_expression", + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "key", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, }, ], - }, - { - "attributes": [], - "forall": { - "kind": "forall", + "returnTy": { + "kind": "type_tensor", "loc": FuncSrcInfo {}, - "tyVars": [ + "types": [ { - "keyword": false, - "kind": "type_var", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, + "value": "cell", }, { - "keyword": false, - "kind": "type_var", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, + "value": "int", }, ], }, - "kind": "function_definition", + }, + { + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "CONFIGOPTPARAM", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "comments!", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", + "value": "config_param", }, - "statements": [ + "parameters": [ { - "expression": { - "kind": "unit", + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "()", + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, }, ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, - "pragmas": [], -} -`; - -exports[`FunC grammar and parser should parse pragmas 1`] = ` -{ - "includes": [], - "items": [], - "kind": "module", - "loc": FuncSrcInfo {}, - "pragmas": [ - { - "kind": "pragma_literal", - "literal": "allow-post-modification", - "loc": FuncSrcInfo {}, - }, - { - "kind": "pragma_literal", - "literal": "compute-asm-ltr", - "loc": FuncSrcInfo {}, + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, }, { - "allow": true, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "ISNULL", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": undefined, - "patch": undefined, + "value": "cell_null?", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "c", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", }, }, { - "allow": true, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "RAWRESERVE", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": undefined, - "patch": undefined, + "value": "raw_reserve", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", }, }, { - "allow": true, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "RAWRESERVEX", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "raw_reserve_extra", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "amount", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "extra_amount", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": undefined, - "patch": 0n, + "value": "()", }, }, { - "allow": true, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SENDRAWMSG", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "=", - "patch": undefined, + "value": "send_raw_message", }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": "=", - "patch": undefined, + "value": "()", }, }, { - "allow": true, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SETCODE", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": "=", - "patch": 0n, + "value": "set_code", }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "new_code", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "cell", + }, + }, + ], + "returnTy": { + "kind": "unit", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "^", - "patch": undefined, + "value": "()", }, }, { - "allow": true, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "RANDU256", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "<", - "patch": undefined, + "value": "random", }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "parameters": [], + "returnTy": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": ">", - "patch": undefined, + "value": "int", }, }, { - "allow": true, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "RAND", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "<=", - "patch": undefined, + "value": "rand", }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "range", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": ">=", - "patch": undefined, + "value": "int", }, }, { - "allow": false, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "RANDSEED", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": undefined, - "patch": undefined, + "value": "get_seed", }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "parameters": [], + "returnTy": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": undefined, - "patch": undefined, + "value": "int", }, }, { - "allow": false, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SETRAND", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": undefined, - "patch": 0n, + "value": "set_seed", }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": undefined, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "=", - "patch": undefined, + "value": "()", }, }, { - "allow": false, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "ADDRAND", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": "=", - "patch": undefined, + "value": "randomize", }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "x", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "int", + }, + }, + ], + "returnTy": { + "kind": "unit", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": "=", - "patch": 0n, + "value": "()", }, }, { - "allow": false, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "LTIME", + }, + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "ADDRAND", + }, + ], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "^", - "patch": undefined, + "value": "randomize_lt", }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "parameters": [], + "returnTy": { + "kind": "unit", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "<", - "patch": undefined, + "value": "()", }, }, { - "allow": false, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "SDEQ", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": ">", - "patch": undefined, + "value": "equal_slice_bits", }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "a", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "b", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "<=", - "patch": undefined, + "value": "int", }, }, { - "allow": false, - "kind": "pragma_version_range", + "arrangement": undefined, + "asmStrings": [ + { + "kind": "string_singleline", + "loc": FuncSrcInfo {}, + "ty": undefined, + "value": "STBR", + }, + ], + "attributes": [], + "forall": undefined, + "kind": "asm_function_definition", "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", + "name": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": ">=", - "patch": undefined, + "value": "store_builder", }, - }, - { - "kind": "pragma_version_string", - "loc": FuncSrcInfo {}, - "version": { - "kind": "string_singleline", + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "to", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "from", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "builder", + }, + }, + ], + "returnTy": { + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "0.4.4", + "value": "builder", }, }, ], + "kind": "module", + "loc": FuncSrcInfo {}, } `; -exports[`FunC grammar and parser should parse statements 1`] = ` +exports[`FunC grammar and parser should parse wallet-code 1`] = ` { - "includes": [], "items": [ { - "attributes": [], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], "forall": undefined, "kind": "function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "return_stmt", + "value": "recv_internal", }, - "parameters": [], + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], + "returnTy": { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + "statements": [], + }, + { + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], + "forall": undefined, + "kind": "function_definition", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "recv_external", + }, + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], "returnTy": { "kind": "unit", "loc": FuncSrcInfo {}, @@ -5324,24 +126550,848 @@ exports[`FunC grammar and parser should parse statements 1`] = ` "statements": [ { "expression": { - "kind": "unit", + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_if", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": "()", + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, }, - "kind": "statement_return", + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "accept_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ + { + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + ], + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "set_data", + }, + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, }, ], }, { - "attributes": [], + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], "forall": undefined, "kind": "function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "return_stmt'", + "value": "seqno", }, "parameters": [], "returnTy": { @@ -5352,9 +127402,48 @@ exports[`FunC grammar and parser should parse statements 1`] = ` "statements": [ { "expression": { - "kind": "integer_literal", + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 42n, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, }, "kind": "statement_return", "loc": FuncSrcInfo {}, @@ -5362,95 +127451,222 @@ exports[`FunC grammar and parser should parse statements 1`] = ` ], }, { - "attributes": [], + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], "forall": undefined, "kind": "function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "block_stmt", + "value": "get_public_key", }, "parameters": [], "returnTy": { - "kind": "unit", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "()", + "value": "int", }, "statements": [ { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [ - { - "kind": "statement_block", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", "loc": FuncSrcInfo {}, - "statements": [ + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", "loc": FuncSrcInfo {}, + "value": "()", }, ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + "kind": "statement_expression", + "loc": FuncSrcInfo {}, + }, + { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", }, - ], + }, + "kind": "statement_return", + "loc": FuncSrcInfo {}, }, ], }, + ], + "kind": "module", + "loc": FuncSrcInfo {}, +} +`; + +exports[`FunC grammar and parser should parse wallet3-code 1`] = ` +{ + "items": [ { - "attributes": [], + "attributes": [ + { + "kind": "impure", + "loc": FuncSrcInfo {}, + }, + ], "forall": undefined, "kind": "function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "empty_stmt", + "value": "recv_internal", }, - "parameters": [], + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], "returnTy": { "kind": "unit", "loc": FuncSrcInfo {}, "value": "()", }, - "statements": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, + "statements": [], + }, + { + "attributes": [ { - "kind": "statement_empty", + "kind": "impure", "loc": FuncSrcInfo {}, }, ], - }, - { - "attributes": [], "forall": undefined, "kind": "function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "cond_stmt", + "value": "recv_external", }, - "parameters": [], + "parameters": [ + { + "kind": "parameter", + "loc": FuncSrcInfo {}, + "name": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + "ty": { + "kind": "type_primitive", + "loc": FuncSrcInfo {}, + "value": "slice", + }, + }, + ], "returnTy": { "kind": "unit", "loc": FuncSrcInfo {}, @@ -5458,754 +127674,1145 @@ exports[`FunC grammar and parser should parse statements 1`] = ` }, "statements": [ { - "alternatives": undefined, - "condition": { - "kind": "integer_literal", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, "loc": FuncSrcInfo {}, - "value": 1n, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_bits", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 512n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + }, }, - "consequences": [], - "kind": "statement_condition_if", + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positive": true, }, { - "alternatives": undefined, - "condition": { - "kind": "integer_literal", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, "loc": FuncSrcInfo {}, - "value": 0n, + "op": "=", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, }, - "consequences": [], - "kind": "statement_condition_if", + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positive": false, }, { - "alternatives": undefined, - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequences": [ - { - "kind": "statement_empty", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, }, - { - "kind": "statement_empty", + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", "loc": FuncSrcInfo {}, }, - ], - "kind": "statement_condition_if", + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positive": true, }, { - "alternatives": undefined, - "condition": { - "kind": "integer_literal", + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "valid_until", + }, + "loc": FuncSrcInfo {}, + "op": "<=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "now", + }, + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequences": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, + "value": "throw_if", }, - ], - "kind": "statement_condition_if", + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positive": false, }, { - "alternatives": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, }, - ], - "condition": { - "kind": "integer_literal", "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequences": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "op": "=", + "right": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, }, - ], - "kind": "statement_condition_if", + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positive": true, }, { - "alternatives": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", "loc": FuncSrcInfo {}, + "names": { + "kind": "expression_tensor_var_decl", + "loc": FuncSrcInfo {}, + "names": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, }, - ], - "condition": { - "kind": "integer_literal", "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequences": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "op": "=", + "right": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, + }, + ], + "kind": "expression_tensor", "loc": FuncSrcInfo {}, }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequencesElseif": [], - "consequencesIf": [], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": true, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, }, - "consequencesElseif": [], - "consequencesIf": [], - "kind": "statement_condition_elseif", + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": true, }, { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 1n, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "ds", + }, }, - "consequencesElseif": [], - "consequencesIf": [], - "kind": "statement_condition_elseif", + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": false, }, { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 33n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "msg_seqno", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 1n, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "throw_unless", + }, }, - "consequencesElseif": [], - "consequencesIf": [], - "kind": "statement_condition_elseif", + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": false, }, { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 34n, + }, + { + "kind": "expression_compare", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "subwallet_id", + }, + "loc": FuncSrcInfo {}, + "op": "==", + "right": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, + "value": "throw_unless", }, - ], - "kind": "statement_condition_elseif", + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": true, }, { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", + "expression": { + "arguments": [ + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 35n, + }, + { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "in_msg", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "slice_hash", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "signature", + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "check_signature", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, + "value": "throw_unless", }, - ], - "kind": "statement_condition_elseif", + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": true, }, { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", + "expression": { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, + "value": "accept_message", }, - ], - "kind": "statement_condition_elseif", + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": false, }, { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "touch", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, + "value": "cs", }, - ], - "kind": "statement_condition_elseif", + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": false, }, { - "alternativesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", + "condition": { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "slice_refs", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + ], + "kind": "expression_tensor", "loc": FuncSrcInfo {}, - "value": 0n, }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ + "kind": "statement_while", + "loc": FuncSrcInfo {}, + "statements": [ { - "kind": "statement_empty", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", + "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, + }, + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 8n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, }, { - "kind": "statement_empty", + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_ref", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + }, + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "mode", + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "send_raw_message", + }, + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, }, ], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": true, }, { - "alternativesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", + "expression": { + "arguments": [ + { + "expressions": [ + { + "arguments": [ + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "expression_add_bitwise", + "left": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_seqno", + }, + "loc": FuncSrcInfo {}, + "negateLeft": false, + "ops": [ + { + "expr": { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 1n, + }, + "op": "+", + }, + ], + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "stored_subwallet", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "store_uint", + }, + { + "expressions": [ + { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "public_key", + }, + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "end_cell", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "begin_cell", + }, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, + "value": "set_data", }, - ], - "kind": "statement_condition_elseif", + }, + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": false, }, ], }, { - "attributes": [], + "attributes": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "value": undefined, + }, + ], "forall": undefined, "kind": "function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "repeat_stmt", + "value": "seqno", }, "parameters": [], "returnTy": { - "kind": "unit", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "()", + "value": "int", }, "statements": [ { - "iterations": { - "expressions": [ + "expression": { + "arguments": [ { - "kind": "integer_literal", + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 32n, + }, + ], + "kind": "expression_tensor", "loc": FuncSrcInfo {}, - "value": 1n, }, ], - "kind": "expression_tensor", + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, }, - "kind": "statement_repeat", + "kind": "statement_return", "loc": FuncSrcInfo {}, - "statements": [], }, + ], + }, + { + "attributes": [ { - "iterations": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "kind": "statement_repeat", + "kind": "method_id", "loc": FuncSrcInfo {}, - "statements": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], + "value": undefined, }, ], - }, - { - "attributes": [], "forall": undefined, "kind": "function_definition", "loc": FuncSrcInfo {}, "name": { "kind": "plain_id", "loc": FuncSrcInfo {}, - "value": "until_stmt", + "value": "get_public_key", }, "parameters": [], "returnTy": { - "kind": "unit", + "kind": "type_primitive", "loc": FuncSrcInfo {}, - "value": "()", + "value": "int", }, "statements": [ { - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [], - }, - { - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", + "expression": { + "kind": "expression_assign", + "left": { + "kind": "expression_var_decl", "loc": FuncSrcInfo {}, + "names": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, + "ty": { + "kind": "hole", + "loc": FuncSrcInfo {}, + "value": "var", + }, }, - { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [ + "loc": FuncSrcInfo {}, + "op": "=", + "right": { + "arguments": [ { - "iterations": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "kind": "statement_repeat", + "kind": "unit", "loc": FuncSrcInfo {}, - "statements": [], + "value": "()", + }, + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "begin_parse", + }, + { + "kind": "unit", + "loc": FuncSrcInfo {}, + "value": "()", }, ], + "kind": "expression_fun_call", + "loc": FuncSrcInfo {}, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "get_data", + }, }, - ], - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "while_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, }, - "kind": "statement_while", + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "statements": [], }, { - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [ - { - "iterations": { + "expression": { + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": "~", + "value": "load_uint", + }, + { + "expressions": [ + { "kind": "integer_literal", "loc": FuncSrcInfo {}, - "value": 1n, + "value": 64n, }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [], - }, - ], - }, - ], - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "try_catch_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "catchExceptionName": { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "catchExitCodeName": { - "kind": "unused_id", + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": "_", - }, - "kind": "statement_try_catch", - "loc": FuncSrcInfo {}, - "statementsCatch": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [], - }, - ], - "statementsTry": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_block", + "object": { + "kind": "plain_id", "loc": FuncSrcInfo {}, - "statements": [], + "value": "cs", }, - ], - }, - { - "catchExceptionName": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exception", - }, - "catchExitCodeName": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exit_code", }, - "kind": "statement_try_catch", + "kind": "statement_expression", "loc": FuncSrcInfo {}, - "statementsCatch": [], - "statementsTry": [], }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expression_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ { "expression": { - "kind": "integer_literal", + "arguments": [ + { + "kind": "method_id", + "loc": FuncSrcInfo {}, + "prefix": ".", + "value": "preload_uint", + }, + { + "expressions": [ + { + "kind": "integer_literal", + "loc": FuncSrcInfo {}, + "value": 256n, + }, + ], + "kind": "expression_tensor", + "loc": FuncSrcInfo {}, + }, + ], + "kind": "expression_fun_call", "loc": FuncSrcInfo {}, - "value": 42n, + "object": { + "kind": "plain_id", + "loc": FuncSrcInfo {}, + "value": "cs", + }, }, - "kind": "statement_expression", + "kind": "statement_return", "loc": FuncSrcInfo {}, }, ], @@ -6213,6 +128820,5 @@ exports[`FunC grammar and parser should parse statements 1`] = ` ], "kind": "module", "loc": FuncSrcInfo {}, - "pragmas": [], } `; diff --git a/src/func/grammar-test/dns-auto-code.fc b/src/func/grammar-test/dns-auto-code.fc new file mode 100644 index 000000000..949f15716 --- /dev/null +++ b/src/func/grammar-test/dns-auto-code.fc @@ -0,0 +1,536 @@ +{- + Adapted from original version written by: + /------------------------------------------------------------------------\ + | Created for: Telegram (Open Network) Blockchain Contest | + | Task 2: DNS Resolver (Automatically registering) | + >------------------------------------------------------------------------< + | Author: Oleksandr Murzin (tg: @skydev / em: alexhacker64@gmail.com) | + | October 2019 | + \------------------------------------------------------------------------/ + Updated to actual DNS standard version by starlightduck in 2022 +-} + +;;===========================================================================;; +;; Custom ASM instructions ;; +;;===========================================================================;; + +cell udict_get_ref_(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETOPTREF"; + +;;===========================================================================;; +;; Utility functions ;; +;;===========================================================================;; + +{- + Data structure: + Root cell: [OptRef<1b+1r?>:HashmapUInt<32b>,CatTable>:domains] + [OptRef<1b+1r?>:Hashmap(Time|Hash128)->Slice(DomName)>:gc] + [UInt<32b>:stdperiod] [Gram:PPReg] [Gram:PPCell] [Gram:PPBit] + [UInt<32b>:lasthousekeeping] + := HashmapE 256 (~~16~~) ^DNSRecord + + STORED DOMAIN NAME SLICE FORMAT: (#ZeroChars<7b>) (Domain name value) + #Zeros allows to simultaneously store, for example, com\0 and com\0google\0 + That will be stored as \1com\0 and \2com\0google\0 (pfx tree has restricitons) + This will allow to resolve more specific requests to subdomains, and resort + to parent domain next resolver lookup if subdomain is not found + com\0goo\0 lookup will, for example look up \2com\0goo\0 and then + \1com\0goo\0 which will return \1com\0 (as per pfx tree) with -1 cat +-} + +(cell, cell, cell, [int, int, int, int], int, int) load_data() inline_ref { + slice cs = get_data().begin_parse(); + return ( + cs~load_ref(), ;; control data + cs~load_dict(), ;; pfx tree: domains data and exp + cs~load_dict(), ;; gc auxillary with expiration and 128-bit hash slice + [ cs~load_uint(30), ;; length of this period of time in seconds + cs~load_grams(), ;; standard payment for registering a new subdomain + cs~load_grams(), ;; price paid for each cell (PPC) + cs~load_grams() ], ;; and bit (PPB) + cs~load_uint(32), ;; next housekeeping to be done at + cs~load_uint(32) ;; last housekeeping done at + ); +} + +(int, int, int, int) load_prices() inline_ref { + slice cs = get_data().begin_parse(); + (cs~load_ref(), cs~load_dict(), cs~load_dict()); + return (cs~load_uint(30), cs~load_grams(), cs~load_grams(), cs~load_grams()); +} + +() store_data(cell ctl, cell dd, cell gc, prices, int nhk, int lhk) impure { + var [sp, ppr, ppc, ppb] = prices; + set_data(begin_cell() + .store_ref(ctl) ;; control data + .store_dict(dd) ;; domains data and exp + .store_dict(gc) ;; keyed expiration time and 128-bit hash slice + .store_uint(sp, 30) ;; standard period + .store_grams(ppr) ;; price per registration + .store_grams(ppc) ;; price per cell + .store_grams(ppb) ;; price per bit + .store_uint(nhk, 32) ;; next housekeeping + .store_uint(lhk, 32) ;; last housekeeping + .end_cell()); +} + +global var query_info; + +() send_message(slice addr, int tag, int query_id, + int body, int grams, int mode) impure { + ;; int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + ;; src:MsgAddress -> 011000 0x18 + var msg = begin_cell() + .store_uint (0x18, 6) + .store_slice(addr) + .store_grams(grams) + .store_uint (0, 1 + 4 + 4 + 64 + 32 + 1 + 1) + .store_uint (tag, 32) + .store_uint (query_id, 64); + if (body >= 0) { + msg~store_uint(body, 32); + } + send_raw_message(msg.end_cell(), mode); +} + +() send_error(int error_code) impure { + var (addr, query_id, op) = query_info; + return send_message(addr, error_code, query_id, op, 0, 64); +} + +() send_ok(int price) impure { + raw_reserve(price, 4); + var (addr, query_id, op) = query_info; + return send_message(addr, 0xef6b6179, query_id, op, 0, 128); +} + +() housekeeping(cell ctl, cell dd, cell gc, prices, int nhk, int lhk, int max_steps) impure { + int n = now(); + if (n < max(nhk, lhk + 60)) { ;; housekeeping cooldown: 1 minute + ;; if housekeeping was done recently, or if next housekeeping is in the future, just save + return store_data(ctl, dd, gc, prices, nhk, lhk); + } + ;; need to do some housekeeping - maybe remove entry with + ;; least expiration but only if it is already expired + ;; no iterating and deleting all to not put too much gas gc + ;; burden on any random specific user request + ;; over time it will do the garbage collection required + (int mkey, _, int found?) = gc.udict_get_min?(256); + while (found? & max_steps) { ;; no short circuit optimization, two nested ifs + nhk = (mkey >> (256 - 32)); + if (nhk < n) { + int key = mkey % (1 << (256 - 32)); + (slice val, found?) = dd.udict_get?(256 - 32, key); + if (found?) { + int exp = val.preload_uint(32); + if (exp <= n) { + dd~udict_delete?(256 - 32, key); + } + } + gc~udict_delete?(256, mkey); + (mkey, _, found?) = gc.udict_get_min?(256); + nhk = (found? ? mkey >> (256 - 32) : 0xffffffff); + max_steps -= 1; + } else { + found? = false; + } + } + store_data(ctl, dd, gc, prices, nhk, n); +} + +int calcprice_internal(slice domain, cell data, ppc, ppb) inline_ref { ;; only for internal calcs + var (_, bits, refs) = compute_data_size(data, 100); ;; 100 cells max + bits += slice_bits(domain) * 2 + (128 + 32 + 32); + return ppc * (refs + 2) + ppb * bits; +} + +int check_owner(cell cat_table, cell owner_info, int src_wc, int src_addr, int strict) inline_ref { + if (strict & cat_table.null?()) { ;; domain not found: return notf | 2^31 + return 0xee6f7466; + } + if (owner_info.null?()) { ;; no owner on this domain: no-2 (in strict mode), ok else + return strict & 0xee6f2d32; + } + var ERR_BAD2 = 0xe2616432; + slice sown = owner_info.begin_parse(); + if (sown.slice_bits() < 16 + 3 + 8 + 256) { ;; bad owner record: bad2 + return ERR_BAD2; + } + if (sown~load_uint(16 + 3) != 0x9fd3 * 8 + 4) { + return ERR_BAD2; + } + (int owner_wc, int owner_addr) = (sown~load_int(8), sown.preload_uint(256)); + if ((owner_wc != src_wc) | (owner_addr != src_addr)) { ;; not owner: nown + return 0xee6f776e; + } + return 0; ;; ok +} + +;;===========================================================================;; +;; Internal message handler (Code 0) ;; +;;===========================================================================;; + +{- + Internal message cell structure: + 8 4 2 1 + int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + src:MsgAddressInt dest:MsgAddressInt + value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams + created_lt:uint64 created_at:uint32 + Internal message data structure: + [UInt<32b>:op] [UInt<64b>:query_id] [Ref<1r>:domain] + (if not prolong: [Ref<1r>:value->CatTable]) + +-} + +;; Control operations: permitted only to the owner of this smartcontract +() perform_ctl_op(int op, int src_wc, int src_addr, slice in_msg) impure inline_ref { + var (ctl, domdata, gc, prices, nhk, lhk) = load_data(); + var cs = ctl.begin_parse(); + if ((cs~load_int(8) != src_wc) | (cs~load_uint(256) != src_addr)) { + return send_error(0xee6f776e); + } + if (op == 0x43685072) { ;; ChPr = Change Prices + var (stdper, ppr, ppc, ppb) = (in_msg~load_uint(32), in_msg~load_grams(), in_msg~load_grams(), in_msg~load_grams()); + in_msg.end_parse(); + ;; NB: stdper == 0 -> disable new actions + store_data(ctl, domdata, gc, [stdper, ppr, ppc, ppb], nhk, lhk); + return send_ok(0); + } + var (addr, query_id, op) = query_info; + if (op == 0x4344656c) { ;; CDel = destroy smart contract + ifnot (domdata.null?()) { + ;; domain dictionary not empty, force gc + housekeeping(ctl, domdata, gc, prices, nhk, 1, -1); + } + (ctl, domdata, gc, prices, nhk, lhk) = load_data(); + ifnot (domdata.null?()) { + ;; domain dictionary still not empty, error + return send_error(0xee74656d); + } + return send_message(addr, 0xef6b6179, query_id, op, 0, 128 + 32); + } + if (op == 0x54616b65) { ;; Take = take grams from the contract + var amount = in_msg~load_grams(); + return send_message(addr, 0xef6b6179, query_id, op, amount, 64); + } + return send_error(0xffffffff); +} + +;; Must send at least GR$1 more for possible gas fees! +() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { + ;; this time very interested in internal messages + if (in_msg.slice_bits() < 32) { + return (); ;; simple transfer or short + } + slice cs = in_msg_cell.begin_parse(); + int flags = cs~load_uint(4); + if (flags & 1) { + return (); ;; bounced messages + } + slice s_addr = cs~load_msg_addr(); + (int src_wc, int src_addr) = s_addr.parse_std_addr(); + int op = in_msg~load_uint(32); + ifnot (op) { + return (); ;; simple transfer with comment + } + int query_id = 0; + if (in_msg.slice_bits() >= 64) { + query_id = in_msg~load_uint(64); + } + + query_info = (s_addr, query_id, op); + + if (op & (1 << 31)) { + return (); ;; an answer to our query + } + if ((op >> 24) == 0x43) { + ;; Control operations + return perform_ctl_op(op, src_wc, src_addr, in_msg); + } + + int qt = (op == 0x72656764) * 1 + (op == 0x70726f6c) * 2 + (op == 0x75706464) * 4 + (op == 0x676f6763) * 8; + ifnot (qt) { ;; unknown query, return error + return send_error(0xffffffff); + } + qt = - qt; + + (cell ctl, cell domdata, cell gc, [int, int, int, int] prices, int nhk, int lhk) = load_data(); + + if (qt == 8) { ;; 0x676f6763 -> GO, GC! go!!! + ;; Manual garbage collection iteration + int max_steps = in_msg~load_int(32); ;; -1 = infty + housekeeping(ctl, domdata, gc, prices, nhk, 1, max_steps); ;; forced + return send_error(0xef6b6179); + } + + slice domain = null(); + cell domain_cell = in_msg~load_maybe_ref(); + int fail = 0; + if (domain_cell.null?()) { + int bytes = in_msg~load_uint(6); + fail = (bytes == 0); + domain = in_msg~load_bits(bytes * 8); + } else { + domain = domain_cell.begin_parse(); + var (bits, refs) = slice_bits_refs(domain); + fail = (refs | ((bits - 8) & (7 - 128))); + } + + ifnot (fail) { + ;; domain must end with \0! no\0 error + fail = domain.slice_last(8).preload_uint(8); + } + if (fail) { + return send_error(0xee6f5c30); + } + + int n = now(); + cell cat_table = cell owner_info = null(); + int key = int exp = int zeros = 0; + slice tail = domain; + repeat (tail.slice_bits() ^>> 3) { + cat_table = null(); + int z = (tail~load_uint(8) == 0); + zeros -= z; + if (z) { + key = (string_hash(domain.skip_last_bits(tail.slice_bits())) >> 32); + var (val, found?) = domdata.udict_get?(256 - 32, key); + if (found?) { + exp = val~load_uint(32); + if (exp >= n) { ;; entry not expired + cell cat_table = val~load_ref(); + val.end_parse(); + ;; update: category length now u256 instead of i16, owner index is now 0 instead of -2 + var (cown, ok) = cat_table.udict_get_ref?(256, 0); + if (ok) { + owner_info = cown; + } + } + } + } + } + + if (zeros > 4) { ;; too much zero chars (overflow): ov\0 + return send_error(0xef765c30); + } + + ;; ########################################################################## + + int err = check_owner(cat_table, owner_info, src_wc, src_addr, qt != 1); + if (err) { + return send_error(err); + } + + ;; ########################################################################## + + ;; load desired data (reuse old for a "prolong" operation) + cell data = null(); + + if (qt != 2) { ;; not a "prolong", load data dictionary + data = in_msg~load_ref(); + ;; basic integrity check of (client-provided) dictionary + ifnot (data.dict_empty?()) { ;; 1000 gas! + ;; update: category length now u256 instead of i16, owner index is now 0 instead of -2 + var (oinfo, ok) = data.udict_get_ref?(256, 0); + if (ok) { + var cs = oinfo.begin_parse(); + throw_unless(31, cs.slice_bits() >= 16 + 3 + 8 + 256); + throw_unless(31, cs.preload_uint(19) == 0x9fd3 * 8 + 4); + } + (_, _, int minok) = data.udict_get_min?(256); ;; update: category length now u256 instead of i16 + (_, _, int maxok) = data.udict_get_max?(256); ;; update: category length now u256 instead of i16 + throw_unless(31, minok & maxok); + } + } else { + data = cat_table; + } + + ;; load prices + var [stdper, ppr, ppc, ppb] = prices; + ifnot (stdper) { ;; smart contract disabled by owner, no new actions + return send_error(0xd34f4646); + } + + ;; compute action price + int price = calcprice_internal(domain, data, ppc, ppb) + (ppr & (qt != 4)); + if (msg_value - (1 << 30) < price) { ;; gr prol | prolong domain + if (exp > n + stdper) { ;; does not expire soon, cannot prolong + return send_error(0xf365726f); + } + domdata~udict_set_builder(256 - 32, key, begin_cell().store_uint(exp + stdper, 32).store_ref(data)); + + int gckeyO = (exp << (256 - 32)) + key; + int gckeyN = gckeyO + (stdper << (256 - 32)); + gc~udict_delete?(256, gckeyO); ;; delete old gc entry, add new + gc~udict_set_builder(256, gckeyN, begin_cell()); + + housekeeping(ctl, domdata, gc, prices, nhk, lhk, 1); + return send_ok(price); + } + + ;; ########################################################################## + if (qt == 1) { ;; 0x72656764 -> regd | register domain + ifnot (cat_table.null?()) { ;; domain already exists: return alre | 2^31 + return send_error(0xe16c7265); + } + int expires_at = n + stdper; + domdata~udict_set_builder(256 - 32, key, begin_cell().store_uint(expires_at, 32).store_ref(data)); + + int gckey = (expires_at << (256 - 32)) | key; + gc~udict_set_builder(256, gckey, begin_cell()); + + housekeeping(ctl, domdata, gc, prices, min(nhk, expires_at), lhk, 1); + return send_ok(price); + } + + ;; ########################################################################## + if (qt == 4) { ;; 0x75706464 -> updd | update domain (data) + domdata~udict_set_builder(256 - 32, key, begin_cell().store_uint(exp, 32).store_ref(data)); + housekeeping(ctl, domdata, gc, prices, nhk, lhk, 1); + return send_ok(price); + } + ;; ########################################################################## + + return (); ;; should NEVER reach this part of code! +} + +;;===========================================================================;; +;; External message handler (Code -1) ;; +;;===========================================================================;; + +() recv_external(slice in_msg) impure { + ;; only for initialization + (cell ctl, cell dd, cell gc, var prices, int nhk, int lhk) = load_data(); + ifnot (lhk) { + accept_message(); + return store_data(ctl, dd, gc, prices, 0xffffffff, now()); + } +} + +;;===========================================================================;; +;; Getter methods ;; +;;===========================================================================;; + +(int, cell, int, slice) dnsdictlookup(slice domain, int nowtime) inline_ref { + (int bits, int refs) = domain.slice_bits_refs(); + throw_if(30, refs | (bits & 7)); ;; malformed input (~ 8n-bit) + ifnot (bits) { + ;; return (0, null(), 0, null()); ;; zero-length input + throw(30); ;; update: throw exception for empty input + } + + int domain_last_byte = domain.slice_last(8).preload_uint(8); + if (domain_last_byte) { + domain = begin_cell().store_slice(domain) ;; append zero byte + .store_uint(0, 8).end_cell().begin_parse(); + bits += 8; + } + if (bits == 8) { + return (0, null(), 8, null()); ;; zero-length input, but with zero byte + ;; update: return 8 as resolved, but with no data + } + int domain_first_byte = domain.preload_uint(8); + if (domain_first_byte == 0) { + ;; update: remove prefix \0 + domain~load_uint(8); + bits -= 8; + } + var ds = get_data().begin_parse(); + (_, cell root) = (ds~load_ref(), ds~load_dict()); + + slice val = null(); + int tail_bits = -1; + slice tail = domain; + + repeat (bits >> 3) { + if (tail~load_uint(8) == 0) { + var key = (string_hash(domain.skip_last_bits(tail.slice_bits())) >> 32); + var (v, found?) = root.udict_get?(256 - 32, key); + if (found?) { + if (v.preload_uint(32) >= nowtime) { ;; entry not expired + val = v; + tail_bits = tail.slice_bits(); + } + } + } + } + + if (val.null?()) { + return (0, null(), 0, null()); ;; failed to find entry in subdomain dictionary + } + + return (val~load_uint(32), val~load_ref(), tail_bits == 0, domain.skip_last_bits(tail_bits)); +} + +;;8m dns-record-value +(int, cell) dnsresolve(slice domain, int category) method_id { + (int exp, cell cat_table, int exact?, slice pfx) = dnsdictlookup(domain, now()); + ifnot (exp) { + return (exact?, null()); ;; update: reuse exact? to return 8 for \0 + } + ifnot (exact?) { ;; incomplete subdomain found, must return next resolver (-1) + category = "dns_next_resolver"H; ;; 0x19f02441ee588fdb26ee24b2568dd035c3c9206e11ab979be62e55558a1d17ff + ;; update: next resolver is now sha256("dns_next_resolver") instead of -1 + } + + int pfx_bits = pfx.slice_bits(); + + ;; pfx.slice_bits() will contain 8m, where m is number of bytes in subdomain + ;; COUNTING the zero byte (if structurally correct: no multiple-ZB keys) + ;; which corresponds to 8m, m=one plus the number of bytes in the subdomain found) + ifnot (category) { + return (pfx_bits, cat_table); ;; return cell with entire dictionary for 0 + } else { + cell cat_found = cat_table.udict_get_ref_(256, category); ;; update: category length now u256 instead of i16 + return (pfx_bits, cat_found); + } +} + +;; getexpiration needs to know the current time to skip any possible expired +;; subdomains in the chain. it will return 0 if not found or expired. +int getexpirationx(slice domain, int nowtime) inline method_id { + (int exp, _, _, _) = dnsdictlookup(domain, nowtime); + return exp; +} + +int getexpiration(slice domain) method_id { + return getexpirationx(domain, now()); +} + +int getstdperiod() method_id { + (int stdper, _, _, _) = load_prices(); + return stdper; +} + +int getppr() method_id { + (_, int ppr, _, _) = load_prices(); + return ppr; +} + +int getppc() method_id { + (_, _, int ppc, _) = load_prices(); + return ppc; +} + +int getppb() method_id { + ( _, _, _, int ppb) = load_prices(); + return ppb; +} + +int calcprice(slice domain, cell val) method_id { ;; only for external gets (not efficient) + (_, _, int ppc, int ppb) = load_prices(); + return calcprice_internal(domain, val, ppc, ppb); +} + +int calcregprice(slice domain, cell val) method_id { ;; only for external gets (not efficient) + (_, int ppr, int ppc, int ppb) = load_prices(); + return ppr + calcprice_internal(domain, val, ppc, ppb); +} diff --git a/src/func/grammar-test/dns-manual-code.fc b/src/func/grammar-test/dns-manual-code.fc new file mode 100644 index 000000000..555e5952d --- /dev/null +++ b/src/func/grammar-test/dns-manual-code.fc @@ -0,0 +1,361 @@ +{- + Originally created by: + /------------------------------------------------------------------------\ + | Created for: Telegram (Open Network) Blockchain Contest | + | Task 3: DNS Resolver (Manually controlled) | + >------------------------------------------------------------------------< + | Author: Oleksandr Murzin (tg: @skydev / em: alexhacker64@gmail.com) | + | October 2019 | + \------------------------------------------------------------------------/ + Updated to actual DNS standard version by starlightduck in 2022 +-} + +;;===========================================================================;; +;; Custom ASM instructions ;; +;;===========================================================================;; + +cell udict_get_ref_(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETOPTREF"; + +(cell, ()) pfxdict_set_ref(cell dict, int key_len, slice key, cell value) { + throw_unless(33, dict~pfxdict_set?(key_len, key, begin_cell().store_maybe_ref(value).end_cell().begin_parse())); + return (dict, ()); +} + +(slice, cell, slice, int) pfxdict_get_ref(cell dict, int key_len, slice key) inline_ref { + (slice pfx, slice val, slice tail, int succ) = dict.pfxdict_get?(key_len, key); + cell res = succ ? val~load_maybe_ref() : null(); + return (pfx, res, tail, succ); +} + +;;===========================================================================;; +;; Utility functions ;; +;;===========================================================================;; + +(int, int, int, cell, cell) load_data() inline_ref { + slice cs = get_data().begin_parse(); + var res = (cs~load_uint(32), cs~load_uint(64), cs~load_uint(256), cs~load_dict(), cs~load_dict()); + cs.end_parse(); + return res; +} + +() store_data(int contract_id, int last_cleaned, int public_key, cell root, old_queries) impure { + set_data(begin_cell() + .store_uint(contract_id, 32) + .store_uint(last_cleaned, 64) + .store_uint(public_key, 256) + .store_dict(root) + .store_dict(old_queries) + .end_cell()); +} + +;;===========================================================================;; +;; Internal message handler (Code 0) ;; +;;===========================================================================;; + +() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { + ;; not interested at all +} + +;;===========================================================================;; +;; External message handler (Code -1) ;; +;;===========================================================================;; + +{- + External message structure: + [Bytes<512b>:signature] [UInt<32b>:seqno] [UInt<6b>:operation] + [Either b0: inline name (<= 58-x Bytes) or b1: reference-stored name) + x depends on operation + Use of 6-bit op instead of 32-bit allows to save 4 bytes for inline name + Inline [Name] structure: [UInt<6b>:length] [Bytes:data] + Operations (continuation of message): + 00 Contract initialization message (only if seqno = 0) (x=-) + 11 VSet: set specified value to specified subdomain->category (x=2) + [UInt<256b>:category] [Name:subdomain] [Cell<1r>:value] + 12 VDel: delete specified subdomain->category (x=2) + [UInt<256b>:category] [Name:subdomain] + 21 DSet: replace entire category dictionary of domain with provided (x=0) + [Name:subdomain] [Cell<1r>:new_cat_table] + 22 DDel: delete entire category dictionary of specified domain (x=0) + [Name:subdomain] + 31 TSet: replace ENTIRE DOMAIN TABLE with the provided tree root cell (x=-) + [Cell<1r>:new_domains_table] + 32 TDel: nullify ENTIRE DOMAIN TABLE (x=-) + 51 OSet: replace owner public key with a new one (x=-) + [UInt<256b>:new_public_key] +-} + +() after_code_upgrade(cell root, slice ops, cont old_code) impure method_id(1666); + +(cell, slice) process_op(cell root, slice ops) inline_ref { + int op = ops~load_uint(6); + if (op < 10) { + ifnot (op) { + ;; 00 Noop: No operation + return (root, ops); + } + if (op == 1) { + ;; 01 SMsg: Send Message + var mode = ops~load_uint(8); + send_raw_message(ops~load_ref(), mode); + return (root, ops); + } + if (op == 9) { + ;; 09 CodeUpgrade + var new_code = ops~load_ref(); + set_code(new_code); + var old_code = get_c3(); + set_c3(new_code.begin_parse().bless()); + after_code_upgrade(root, ops, old_code); + throw(0); + return (root, ops); + } + throw(45); + return (root, ops); + } + int cat = 0; + if (op < 20) { + ;; for operations with codes 10..19 category is required + cat = ops~load_uint(256); ;; update: category length now u256 instead of i16 + } + slice name = null(); ;; any slice value + cell cat_table = null(); + if (op < 30) { + ;; for operations with codes 10..29 name is required + int is_name_ref = (ops~load_uint(1) == 1); + if (is_name_ref) { + ;; name is stored in separate referenced cell + name = ops~load_ref().begin_parse(); + } else { + ;; name is stored inline + int name_len = ops~load_uint(6) * 8; + name = ops~load_bits(name_len); + } + ;; at least one character not counting \0 + throw_unless(38, name.slice_bits() >= 16); + ;; name shall end with \0 + int name_last_byte = name.slice_last(8).preload_uint(8); + throw_if(40, name_last_byte); + ;; count zero separators + int zeros = 0; + slice cname = name; + repeat (cname.slice_bits() ^>> 3) { + int c = cname~load_uint(8); + zeros -= (c == 0); + } + ;; throw_unless(39, zeros == 1); + name = begin_cell().store_uint(zeros, 7).store_slice(name).end_cell().begin_parse(); + } + ;; operation with codes 10..19 manipulate category dict + ;; lets try to find it and store into a variable + ;; operations with codes 20..29 replace / delete dict, no need + if (op < 20) { + ;; lets resolve the name here so as not to duplicate the code + (slice pfx, cell val, slice tail, int succ) = + root.pfxdict_get_ref(1023, name); + if (succ) { + ;; must match EXACTLY to prevent accident changes + throw_unless(35, tail.slice_empty?()); + cat_table = val; + } + ;; otherwise cat_table is null which is reasonable for actions + } + ;; 11 VSet: set specified value to specified subdomain->category + if (op == 11) { + cell new_value = ops~load_maybe_ref(); + cat_table~udict_set_get_ref(256, cat, new_value); ;; update: category length now u256 instead of i16 + root~pfxdict_set_ref(1023, name, cat_table); + return (root, ops); + } + ;; 12 VDel: delete specified subdomain->category value + if (op == 12) { + if (cat_table~udict_delete?(256, cat)) { ;; update: category length now u256 instead of i16 + root~pfxdict_set_ref(1023, name, cat_table); + } + return (root, ops); + } + ;; 21 DSet: replace entire category dictionary of domain with provided + if (op == 21) { + cell new_cat_table = ops~load_maybe_ref(); + root~pfxdict_set_ref(1023, name, new_cat_table); + return (root, ops); + } + ;; 22 DDel: delete entire category dictionary of specified domain + if (op == 22) { + root~pfxdict_delete?(1023, name); + return (root, ops); + } + ;; 31 TSet: replace ENTIRE DOMAIN TABLE with the provided tree root cell + if (op == 31) { + cell new_tree_root = ops~load_maybe_ref(); + ;; no sanity checks cause they would cost immense gas + return (new_tree_root, ops); + } + ;; 32 TDel: nullify ENTIRE DOMAIN TABLE + if (op == 32) { + return (null(), ops); + } + throw(44); ;; invalid operation + return (null(), ops); +} + +cell process_ops(cell root, slice ops) inline_ref { + var stop = false; + root~touch(); + ops~touch(); + do { + (root, ops) = process_op(root, ops); + if (ops.slice_data_empty?()) { + if (ops.slice_refs()) { + ops = ops~load_ref().begin_parse(); + } else { + stop = true; + } + } + } until (stop); + return root; +} + +() recv_external(slice in_msg) impure { + ;; Load data + (int contract_id, int last_cleaned, int public_key, cell root, cell old_queries) = load_data(); + + ;; validate signature and seqno + slice signature = in_msg~load_bits(512); + int shash = slice_hash(in_msg); + var (query_contract, query_id) = (in_msg~load_uint(32), in_msg~load_uint(64)); + var bound = (now() << 32); + throw_if(35, query_id < bound); + (_, var found?) = old_queries.udict_get?(64, query_id); + throw_if(32, found?); + throw_unless(34, contract_id == query_contract); + throw_unless(35, check_signature(shash, signature, public_key)); + accept_message(); ;; message is signed by owner, sanity not guaranteed yet + + int op = in_msg.preload_uint(6); + if (op == 51) { + in_msg~skip_bits(6); + public_key = in_msg~load_uint(256); + } else { + root = process_ops(root, in_msg); + } + + bound -= (64 << 32); ;; clean up records expired more than 64 seconds ago + old_queries~udict_set_builder(64, query_id, begin_cell()); + var queries = old_queries; + do { + var (old_queries', i, _, f) = old_queries.udict_delete_get_min(64); + f~touch(); + if (f) { + f = (i < bound); + } + if (f) { + old_queries = old_queries'; + last_cleaned = i; + } + } until (~ f); + + store_data(contract_id, last_cleaned, public_key, root, old_queries); +} + +() after_code_upgrade(cell root, slice ops, cont old_code) impure method_id(1666) { +} + +{- + Data structure: + Root cell: [UInt<32b>:seqno] [UInt<256b>:owner_public_key] + [OptRef<1b+1r?>:HashmapCatTable>:domains] + := HashmapE 256 (~~16~~) ^DNSRecord + + STORED DOMAIN NAME SLICE FORMAT: (#ZeroChars<7b>) (Domain name value) + #Zeros allows to simultaneously store, for example, com\0 and com\0google\0 + That will be stored as \1com\0 and \2com\0google\0 (pfx tree has restricitons) + This will allow to resolve more specific requests to subdomains, and resort + to parent domain next resolver lookup if subdomain is not found + com\0goo\0 lookup will, for example look up \2com\0goo\0 and then + \1com\0goo\0 which will return \1com\0 (as per pfx tree) with -1 cat +-} + +;;===========================================================================;; +;; Getter methods ;; +;;===========================================================================;; + +;; Retrieve contract id (in case several contracts are managed with the same private key) +int get_contract_id() method_id { + return get_data().begin_parse().preload_uint(32); +} + +int get_public_key() method_id { + var cs = get_data().begin_parse(); + cs~load_uint(32 + 64); + return cs.preload_uint(256); +} + +;;8m dns-record-value +(int, cell) dnsresolve(slice subdomain, int category) method_id { + int bits = subdomain.slice_bits(); + ifnot (bits) { + ;; return (0, null()); ;; zero-length input + throw(30); ;; update: throw exception for empty input + } + throw_if(30, bits & 7); ;; malformed input (~ 8n-bit) + + int name_last_byte = subdomain.slice_last(8).preload_uint(8); + if (name_last_byte) { + subdomain = begin_cell().store_slice(subdomain) ;; append zero byte + .store_uint(0, 8).end_cell().begin_parse(); + bits += 8; + } + if (bits == 8) { + return (8, null()); ;; zero-length input, but with zero byte + ;; update: return 8 as resolved, but with no data + } + int name_first_byte = subdomain.preload_uint(8); + if (name_first_byte == 0) { + ;; update: remove prefix \0 + subdomain~load_uint(8); + bits -= 8; + } + (_, _, _, cell root, _) = load_data(); + + slice cname = subdomain; + int zeros = 0; + repeat (bits >> 3) { + int c = cname~load_uint(8); + zeros -= (c == 0); + } + + ;; can't move these declarations lower, will cause errors! + slice pfx = cname; + cell val = null(); + slice tail = cname; + + do { + slice pfxname = begin_cell().store_uint(zeros, 7) + .store_slice(subdomain).end_cell().begin_parse(); + (pfx, val, tail, int succ) = root.pfxdict_get_ref(1023, pfxname); + zeros = succ ^ (zeros - 1); ;; break on success + } until (zeros <= 0); + + ifnot (zeros) { + return (0, null()); ;; failed to find entry in prefix dictionary + } + + zeros = - zeros; + + ifnot (tail.slice_empty?()) { ;; if we have tail then len(pfx) < len(subdomain) + ;; incomplete subdomain found, must return next resolver + category = "dns_next_resolver"H; ;; 0x19f02441ee588fdb26ee24b2568dd035c3c9206e11ab979be62e55558a1d17ff + ;; update: next resolver is now sha256("dns_next_resolver") instead of -1 + } + int pfx_bits = pfx.slice_bits() - 7; + cell cat_table = val; + ;; pfx.slice_bits() will contain 8m, where m is number of bytes in subdomain + ;; COUNTING the zero byte (if structurally correct: no multiple-ZB keys) + ;; which corresponds to 8m, m=one plus the number of bytes in the subdomain found) + if (category == 0) { + return (pfx_bits, cat_table); ;; return cell with entire dictionary for 0 + } else { + cell cat_found = cat_table.udict_get_ref_(256, category); ;; update: category length now u256 instead of i16 + return (pfx_bits, cat_found); + } +} diff --git a/src/func/grammar-test/elector-code.fc b/src/func/grammar-test/elector-code.fc new file mode 100644 index 000000000..97185fc21 --- /dev/null +++ b/src/func/grammar-test/elector-code.fc @@ -0,0 +1,1187 @@ +;; Elector smartcontract + +;; cur_elect credits past_elections grams active_id active_hash +(cell, cell, cell, int, int, int) load_data() inline_ref { + var cs = get_data().begin_parse(); + var res = (cs~load_dict(), cs~load_dict(), cs~load_dict(), cs~load_grams(), cs~load_uint(32), cs~load_uint(256)); + cs.end_parse(); + return res; +} + +;; cur_elect credits past_elections grams active_id active_hash +() store_data(elect, credits, past_elections, grams, active_id, active_hash) impure inline_ref { + set_data(begin_cell() + .store_dict(elect) + .store_dict(credits) + .store_dict(past_elections) + .store_grams(grams) + .store_uint(active_id, 32) + .store_uint(active_hash, 256) + .end_cell()); +} + +;; elect -> elect_at elect_close min_stake total_stake members failed finished +_ unpack_elect(elect) inline_ref { + var es = elect.begin_parse(); + var res = (es~load_uint(32), es~load_uint(32), es~load_grams(), es~load_grams(), es~load_dict(), es~load_int(1), es~load_int(1)); + es.end_parse(); + return res; +} + +cell pack_elect(elect_at, elect_close, min_stake, total_stake, members, failed, finished) inline_ref { + return begin_cell() + .store_uint(elect_at, 32) + .store_uint(elect_close, 32) + .store_grams(min_stake) + .store_grams(total_stake) + .store_dict(members) + .store_int(failed, 1) + .store_int(finished, 1) + .end_cell(); +} + +;; slice -> unfreeze_at stake_held vset_hash frozen_dict total_stake bonuses complaints +_ unpack_past_election(slice fs) inline_ref { + var res = (fs~load_uint(32), fs~load_uint(32), fs~load_uint(256), fs~load_dict(), fs~load_grams(), fs~load_grams(), fs~load_dict()); + fs.end_parse(); + return res; +} + +builder pack_past_election(int unfreeze_at, int stake_held, int vset_hash, cell frozen_dict, int total_stake, int bonuses, cell complaints) inline_ref { + return begin_cell() + .store_uint(unfreeze_at, 32) + .store_uint(stake_held, 32) + .store_uint(vset_hash, 256) + .store_dict(frozen_dict) + .store_grams(total_stake) + .store_grams(bonuses) + .store_dict(complaints); +} + +;; complaint_status#2d complaint:^ValidatorComplaint voters:(HashmapE 16 True) +;; vset_id:uint256 weight_remaining:int64 = ValidatorComplaintStatus; +_ unpack_complaint_status(slice cs) inline_ref { + throw_unless(9, cs~load_uint(8) == 0x2d); + var res = (cs~load_ref(), cs~load_dict(), cs~load_uint(256), cs~load_int(64)); + cs.end_parse(); + return res; +} + +builder pack_complaint_status(cell complaint, cell voters, int vset_id, int weight_remaining) inline_ref { + return begin_cell() + .store_uint(0x2d, 8) + .store_ref(complaint) + .store_dict(voters) + .store_uint(vset_id, 256) + .store_int(weight_remaining, 64); +} + +;; validator_complaint#bc validator_pubkey:uint256 description:^ComplaintDescr +;; created_at:uint32 severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams +;; suggested_fine_part:uint32 = ValidatorComplaint; +_ unpack_complaint(slice cs) inline_ref { + throw_unless(9, cs~load_int(8) == 0xbc - 0x100); + var res = (cs~load_uint(256), cs~load_ref(), cs~load_uint(32), cs~load_uint(8), cs~load_uint(256), cs~load_grams(), cs~load_grams(), cs~load_uint(32)); + cs.end_parse(); + return res; +} + +builder pack_complaint(int validator_pubkey, cell description, int created_at, int severity, int reward_addr, int paid, int suggested_fine, int suggested_fine_part) inline_ref { + return begin_cell() + .store_int(0xbc - 0x100, 8) + .store_uint(validator_pubkey, 256) + .store_ref(description) + .store_uint(created_at, 32) + .store_uint(severity, 8) + .store_uint(reward_addr, 256) + .store_grams(paid) + .store_grams(suggested_fine) + .store_uint(suggested_fine_part, 32); +} + +;; complaint_prices#1a deposit:Grams bit_price:Grams cell_price:Grams = ComplaintPricing; +(int, int, int) parse_complaint_prices(cell info) inline { + var cs = info.begin_parse(); + throw_unless(9, cs~load_uint(8) == 0x1a); + var res = (cs~load_grams(), cs~load_grams(), cs~load_grams()); + cs.end_parse(); + return res; +} + +;; deposit bit_price cell_price +(int, int, int) get_complaint_prices() inline_ref { + var info = config_param(13); + return info.null?() ? (1 << 36, 1, 512) : info.parse_complaint_prices(); +} + +;; elected_for elections_begin_before elections_end_before stake_held_for +(int, int, int, int) get_validator_conf() { + var cs = config_param(15).begin_parse(); + return (cs~load_int(32), cs~load_int(32), cs~load_int(32), cs.preload_int(32)); +} + +;; next three functions return information about current validator set (config param #34) +;; they are borrowed from config-code.fc +(cell, int, cell) get_current_vset() inline_ref { + var vset = config_param(34); + var cs = begin_parse(vset); + ;; validators_ext#12 utime_since:uint32 utime_until:uint32 + ;; total:(## 16) main:(## 16) { main <= total } { main >= 1 } + ;; total_weight:uint64 + throw_unless(40, cs~load_uint(8) == 0x12); + cs~skip_bits(32 + 32 + 16 + 16); + var (total_weight, dict) = (cs~load_uint(64), cs~load_dict()); + cs.end_parse(); + return (vset, total_weight, dict); +} + +(slice, int) get_validator_descr(int idx) inline_ref { + var (vset, total_weight, dict) = get_current_vset(); + var (value, _) = dict.udict_get?(16, idx); + return (value, total_weight); +} + +(int, int) unpack_validator_descr(slice cs) inline { + ;; ed25519_pubkey#8e81278a pubkey:bits256 = SigPubKey; + ;; validator#53 public_key:SigPubKey weight:uint64 = ValidatorDescr; + ;; validator_addr#73 public_key:SigPubKey weight:uint64 adnl_addr:bits256 = ValidatorDescr; + throw_unless(41, (cs~load_uint(8) & ~ 0x20) == 0x53); + throw_unless(41, cs~load_uint(32) == 0x8e81278a); + return (cs~load_uint(256), cs~load_uint(64)); +} + +() send_message_back(addr, ans_tag, query_id, body, grams, mode) impure inline_ref { + ;; int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool src:MsgAddress -> 011000 + var msg = begin_cell() + .store_uint(0x18, 6) + .store_slice(addr) + .store_grams(grams) + .store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1) + .store_uint(ans_tag, 32) + .store_uint(query_id, 64); + if (body >= 0) { + msg~store_uint(body, 32); + } + send_raw_message(msg.end_cell(), mode); +} + +() return_stake(addr, query_id, reason) impure inline_ref { + return send_message_back(addr, 0xee6f454c, query_id, reason, 0, 64); +} + +() send_confirmation(addr, query_id, comment) impure inline_ref { + return send_message_back(addr, 0xf374484c, query_id, comment, 1000000000, 2); +} + +() send_validator_set_to_config(config_addr, vset, query_id) impure inline_ref { + var msg = begin_cell() + .store_uint(0xc4ff, 17) ;; 0 11000100 0xff + .store_uint(config_addr, 256) + .store_grams(1 << 30) ;; ~1 gram of value to process and obtain answer + .store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1) + .store_uint(0x4e565354, 32) + .store_uint(query_id, 64) + .store_ref(vset); + send_raw_message(msg.end_cell(), 1); +} + +;; credits 'amount' to 'addr' inside credit dictionary 'credits' +_ ~credit_to(credits, addr, amount) inline_ref { + var (val, f) = credits.udict_get?(256, addr); + if (f) { + amount += val~load_grams(); + } + credits~udict_set_builder(256, addr, begin_cell().store_grams(amount)); + return (credits, ()); +} + +() process_new_stake(s_addr, msg_value, cs, query_id) impure inline_ref { + var (src_wc, src_addr) = parse_std_addr(s_addr); + var ds = get_data().begin_parse(); + var elect = ds~load_dict(); + if (elect.null?() | (src_wc + 1)) { + ;; no elections active, or source is not in masterchain + ;; bounce message + return return_stake(s_addr, query_id, 0); + } + ;; parse the remainder of new stake message + var validator_pubkey = cs~load_uint(256); + var stake_at = cs~load_uint(32); + var max_factor = cs~load_uint(32); + var adnl_addr = cs~load_uint(256); + var signature = cs~load_ref().begin_parse().preload_bits(512); + cs.end_parse(); + ifnot (check_data_signature(begin_cell() + .store_uint(0x654c5074, 32) + .store_uint(stake_at, 32) + .store_uint(max_factor, 32) + .store_uint(src_addr, 256) + .store_uint(adnl_addr, 256) + .end_cell().begin_parse(), signature, validator_pubkey)) { + ;; incorrect signature, return stake + return return_stake(s_addr, query_id, 1); + } + if (max_factor < 0x10000) { + ;; factor must be >= 1. = 65536/65536 + return return_stake(s_addr, query_id, 6); + } + ;; parse current election data + var (elect_at, elect_close, min_stake, total_stake, members, failed, finished) = elect.unpack_elect(); + ;; elect_at~dump(); + msg_value -= 1000000000; ;; deduct GR$1 for sending confirmation + if ((msg_value << 12) < total_stake) { + ;; stake smaller than 1/4096 of the total accumulated stakes, return + return return_stake(s_addr, query_id, 2); + } + total_stake += msg_value; ;; (provisionally) increase total stake + if (stake_at != elect_at) { + ;; stake for some other elections, return + return return_stake(s_addr, query_id, 3); + } + if (finished) { + ;; elections already finished, return stake + return return_stake(s_addr, query_id, 0); + } + var (mem, found) = members.udict_get?(256, validator_pubkey); + if (found) { + ;; entry found, merge stakes + msg_value += mem~load_grams(); + mem~load_uint(64); ;; skip timestamp and max_factor + found = (src_addr != mem~load_uint(256)); + } + if (found) { + ;; can make stakes for a public key from one address only + return return_stake(s_addr, query_id, 4); + } + if (msg_value < min_stake) { + ;; stake too small, return it + return return_stake(s_addr, query_id, 5); + } + throw_unless(44, msg_value); + accept_message(); + ;; store stake in the dictionary + members~udict_set_builder(256, validator_pubkey, begin_cell() + .store_grams(msg_value) + .store_uint(now(), 32) + .store_uint(max_factor, 32) + .store_uint(src_addr, 256) + .store_uint(adnl_addr, 256)); + ;; gather and save election data + elect = pack_elect(elect_at, elect_close, min_stake, total_stake, members, false, false); + set_data(begin_cell().store_dict(elect).store_slice(ds).end_cell()); + ;; return confirmation message + if (query_id) { + return send_confirmation(s_addr, query_id, 0); + } + return (); +} + +(cell, int) unfreeze_without_bonuses(credits, freeze_dict, tot_stakes) inline_ref { + var total = var recovered = 0; + var pubkey = -1; + do { + (pubkey, var cs, var f) = freeze_dict.udict_get_next?(256, pubkey); + if (f) { + var (addr, weight, stake, banned) = (cs~load_uint(256), cs~load_uint(64), cs~load_grams(), cs~load_int(1)); + cs.end_parse(); + if (banned) { + recovered += stake; + } else { + credits~credit_to(addr, stake); + } + total += stake; + } + } until (~ f); + throw_unless(59, total == tot_stakes); + return (credits, recovered); +} + +(cell, int) unfreeze_with_bonuses(credits, freeze_dict, tot_stakes, tot_bonuses) inline_ref { + var total = var recovered = var returned_bonuses = 0; + var pubkey = -1; + do { + (pubkey, var cs, var f) = freeze_dict.udict_get_next?(256, pubkey); + if (f) { + var (addr, weight, stake, banned) = (cs~load_uint(256), cs~load_uint(64), cs~load_grams(), cs~load_int(1)); + cs.end_parse(); + if (banned) { + recovered += stake; + } else { + var bonus = muldiv(tot_bonuses, stake, tot_stakes); + returned_bonuses += bonus; + credits~credit_to(addr, stake + bonus); + } + total += stake; + } + } until (~ f); + throw_unless(59, (total == tot_stakes) & (returned_bonuses <= tot_bonuses)); + return (credits, recovered + tot_bonuses - returned_bonuses); +} + +int stakes_sum(frozen_dict) inline_ref { + var total = 0; + var pubkey = -1; + do { + (pubkey, var cs, var f) = frozen_dict.udict_get_next?(256, pubkey); + if (f) { + cs~skip_bits(256 + 64); + total += cs~load_grams(); + } + } until (~ f); + return total; +} + +_ unfreeze_all(credits, past_elections, elect_id) inline_ref { + var (fs, f) = past_elections~udict_delete_get?(32, elect_id); + ifnot (f) { + ;; no elections with this id + return (credits, past_elections, 0); + } + var (unfreeze_at, stake_held, vset_hash, fdict, tot_stakes, bonuses, complaints) = fs.unpack_past_election(); + ;; tot_stakes = fdict.stakes_sum(); ;; TEMP BUGFIX + var unused_prizes = (bonuses > 0) ? + credits~unfreeze_with_bonuses(fdict, tot_stakes, bonuses) : + credits~unfreeze_without_bonuses(fdict, tot_stakes); + return (credits, past_elections, unused_prizes); +} + +() config_set_confirmed(s_addr, cs, query_id, ok) impure inline_ref { + var (src_wc, src_addr) = parse_std_addr(s_addr); + var config_addr = config_param(0).begin_parse().preload_uint(256); + var ds = get_data().begin_parse(); + var elect = ds~load_dict(); + if ((src_wc + 1) | (src_addr != config_addr) | elect.null?()) { + ;; not from config smc, somebody's joke? + ;; or no elections active (or just completed) + return (); + } + var (elect_at, elect_close, min_stake, total_stake, members, failed, finished) = elect.unpack_elect(); + if ((elect_at != query_id) | ~ finished) { + ;; not these elections, or elections not finished yet + return (); + } + accept_message(); + ifnot (ok) { + ;; cancel elections, return stakes + var (credits, past_elections, grams) = (ds~load_dict(), ds~load_dict(), ds~load_grams()); + (credits, past_elections, var unused_prizes) = unfreeze_all(credits, past_elections, elect_at); + set_data(begin_cell() + .store_int(false, 1) + .store_dict(credits) + .store_dict(past_elections) + .store_grams(grams + unused_prizes) + .store_slice(ds) + .end_cell()); + } + ;; ... do not remove elect until we see this set as the next elected validator set +} + +() process_simple_transfer(s_addr, msg_value) impure inline_ref { + var (elect, credits, past_elections, grams, active_id, active_hash) = load_data(); + (int src_wc, int src_addr) = parse_std_addr(s_addr); + if (src_addr | (src_wc + 1) | (active_id == 0)) { + ;; simple transfer to us (credit "nobody's" account) + ;; (or no known active validator set) + grams += msg_value; + return store_data(elect, credits, past_elections, grams, active_id, active_hash); + } + ;; zero source address -1:00..00 (collecting validator fees) + var (fs, f) = past_elections.udict_get?(32, active_id); + ifnot (f) { + ;; active validator set not found (?) + grams += msg_value; + } else { + ;; credit active validator set bonuses + var (unfreeze_at, stake_held, hash, dict, total_stake, bonuses, complaints) = fs.unpack_past_election(); + bonuses += msg_value; + past_elections~udict_set_builder(32, active_id, + pack_past_election(unfreeze_at, stake_held, hash, dict, total_stake, bonuses, complaints)); + } + return store_data(elect, credits, past_elections, grams, active_id, active_hash); +} + +() recover_stake(op, s_addr, cs, query_id) impure inline_ref { + (int src_wc, int src_addr) = parse_std_addr(s_addr); + if (src_wc + 1) { + ;; not from masterchain, return error + return send_message_back(s_addr, 0xfffffffe, query_id, op, 0, 64); + } + var ds = get_data().begin_parse(); + var (elect, credits) = (ds~load_dict(), ds~load_dict()); + var (cs, f) = credits~udict_delete_get?(256, src_addr); + ifnot (f) { + ;; no credit for sender, return error + return send_message_back(s_addr, 0xfffffffe, query_id, op, 0, 64); + } + var amount = cs~load_grams(); + cs.end_parse(); + ;; save data + set_data(begin_cell().store_dict(elect).store_dict(credits).store_slice(ds).end_cell()); + ;; send amount to sender in a new message + send_raw_message(begin_cell() + .store_uint(0x18, 6) + .store_slice(s_addr) + .store_grams(amount) + .store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1) + .store_uint(0xf96f7324, 32) + .store_uint(query_id, 64) + .end_cell(), 64); +} + +() after_code_upgrade(slice s_addr, slice cs, int query_id) impure method_id(1666) { + var op = 0x4e436f64; + return send_message_back(s_addr, 0xce436f64, query_id, op, 0, 64); +} + +int upgrade_code(s_addr, cs, query_id) inline_ref { + var c_addr = config_param(0); + if (c_addr.null?()) { + ;; no configuration smart contract known + return false; + } + var config_addr = c_addr.begin_parse().preload_uint(256); + var (src_wc, src_addr) = parse_std_addr(s_addr); + if ((src_wc + 1) | (src_addr != config_addr)) { + ;; not from configuration smart contract, return error + return false; + } + accept_message(); + var code = cs~load_ref(); + set_code(code); + ifnot(cs.slice_empty?()) { + set_c3(code.begin_parse().bless()); + after_code_upgrade(s_addr, cs, query_id); + throw(0); + } + return true; +} + +int register_complaint(s_addr, complaint, msg_value) { + var (src_wc, src_addr) = parse_std_addr(s_addr); + if (src_wc + 1) { ;; not from masterchain, return error + return -1; + } + if (complaint.slice_depth() >= 128) { + return -3; ;; invalid complaint + } + var (elect, credits, past_elections, grams, active_id, active_hash) = load_data(); + var election_id = complaint~load_uint(32); + var (fs, f) = past_elections.udict_get?(32, election_id); + ifnot (f) { ;; election not found + return -2; + } + var expire_in = fs.preload_uint(32) - now(); + if (expire_in <= 0) { ;; already expired + return -4; + } + var (validator_pubkey, description, created_at, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = unpack_complaint(complaint); + reward_addr = src_addr; + created_at = now(); + ;; compute complaint storage/creation price + var (deposit, bit_price, cell_price) = get_complaint_prices(); + var (_, bits, refs) = slice_compute_data_size(complaint, 4096); + var pps = (bits + 1024) * bit_price + (refs + 2) * cell_price; + paid = pps * expire_in + deposit; + if (msg_value < paid + (1 << 30)) { ;; not enough money + return -5; + } + ;; re-pack modified complaint + cell complaint = pack_complaint(validator_pubkey, description, created_at, severity, reward_addr, paid, suggested_fine, suggested_fine_part).end_cell(); + var (unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints) = unpack_past_election(fs); + var (fs, f) = frozen_dict.udict_get?(256, validator_pubkey); + ifnot (f) { ;; no such validator, cannot complain + return -6; + } + fs~skip_bits(256 + 64); ;; addr weight + var validator_stake = fs~load_grams(); + int fine = suggested_fine + muldiv(validator_stake, suggested_fine_part, 1 << 32); + if (fine > validator_stake) { ;; validator's stake is less than suggested fine + return -7; + } + if (fine <= paid) { ;; fine is less than the money paid for creating complaint + return -8; + } + ;; create complaint status + var cstatus = pack_complaint_status(complaint, null(), 0, 0); + ;; save complaint status into complaints + var cpl_id = complaint.cell_hash(); + ifnot (complaints~udict_add_builder?(256, cpl_id, cstatus)) { + return -9; ;; complaint already exists + } + ;; pack past election info + past_elections~udict_set_builder(32, election_id, pack_past_election(unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints)); + ;; pack persistent data + ;; next line can be commented, but it saves a lot of stack manipulations + var (elect, credits, _, grams, active_id, active_hash) = load_data(); + store_data(elect, credits, past_elections, grams, active_id, active_hash); + return paid; +} + +(cell, cell, int, int) punish(credits, frozen, complaint) inline_ref { + var (validator_pubkey, description, created_at, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = complaint.begin_parse().unpack_complaint(); + var (cs, f) = frozen.udict_get?(256, validator_pubkey); + ifnot (f) { + ;; no validator to punish + return (credits, frozen, 0, 0); + } + var (addr, weight, stake, banned) = (cs~load_uint(256), cs~load_uint(64), cs~load_grams(), cs~load_int(1)); + cs.end_parse(); + int fine = min(stake, suggested_fine + muldiv(stake, suggested_fine_part, 1 << 32)); + stake -= fine; + frozen~udict_set_builder(256, validator_pubkey, begin_cell() + .store_uint(addr, 256) + .store_uint(weight, 64) + .store_grams(stake) + .store_int(banned, 1)); + int reward = min(fine >> 3, paid * 8); + credits~credit_to(reward_addr, reward); + return (credits, frozen, fine - reward, fine); +} + +(cell, cell, int) register_vote(complaints, chash, idx, weight) inline_ref { + var (cstatus, found?) = complaints.udict_get?(256, chash); + ifnot (found?) { + ;; complaint not found + return (complaints, null(), -1); + } + var (cur_vset, total_weight, _) = get_current_vset(); + int cur_vset_id = cur_vset.cell_hash(); + var (complaint, voters, vset_id, weight_remaining) = unpack_complaint_status(cstatus); + int vset_old? = (vset_id != cur_vset_id); + if ((weight_remaining < 0) & vset_old?) { + ;; previous validator set already collected 2/3 votes, skip new votes + return (complaints, null(), -3); + } + if (vset_old?) { + ;; complaint votes belong to a previous validator set, reset voting + vset_id = cur_vset_id; + voters = null(); + weight_remaining = muldiv(total_weight, 2, 3); + } + var (_, found?) = voters.udict_get?(16, idx); + if (found?) { + ;; already voted for this proposal, ignore vote + return (complaints, null(), 0); + } + ;; register vote + voters~udict_set_builder(16, idx, begin_cell().store_uint(now(), 32)); + int old_wr = weight_remaining; + weight_remaining -= weight; + old_wr ^= weight_remaining; + ;; save voters and weight_remaining + complaints~udict_set_builder(256, chash, pack_complaint_status(complaint, voters, vset_id, weight_remaining)); + if (old_wr >= 0) { + ;; not enough votes or already accepted + return (complaints, null(), 1); + } + ;; complaint wins, prepare punishment + return (complaints, complaint, 2); +} + +int proceed_register_vote(election_id, chash, idx, weight) impure inline_ref { + var (elect, credits, past_elections, grams, active_id, active_hash) = load_data(); + var (fs, f) = past_elections.udict_get?(32, election_id); + ifnot (f) { ;; election not found + return -2; + } + var (unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints) = unpack_past_election(fs); + (complaints, var accepted_complaint, var status) = register_vote(complaints, chash, idx, weight); + if (status <= 0) { + return status; + } + ifnot (accepted_complaint.null?()) { + (credits, frozen_dict, int fine_unalloc, int fine_collected) = punish(credits, frozen_dict, accepted_complaint); + grams += fine_unalloc; + total_stake -= fine_collected; + } + past_elections~udict_set_builder(32, election_id, pack_past_election(unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints)); + store_data(elect, credits, past_elections, grams, active_id, active_hash); + return status; +} + +() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { + ;; do nothing for internal messages + var cs = in_msg_cell.begin_parse(); + var flags = cs~load_uint(4); ;; int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + if (flags & 1) { + ;; ignore all bounced messages + return (); + } + var s_addr = cs~load_msg_addr(); + if (in_msg.slice_empty?()) { + ;; inbound message has empty body + return process_simple_transfer(s_addr, msg_value); + } + int op = in_msg~load_uint(32); + if (op == 0) { + ;; simple transfer with comment, return + return process_simple_transfer(s_addr, msg_value); + } + int query_id = in_msg~load_uint(64); + if (op == 0x4e73744b) { + ;; new stake message + return process_new_stake(s_addr, msg_value, in_msg, query_id); + } + if (op == 0x47657424) { + ;; recover stake request + return recover_stake(op, s_addr, in_msg, query_id); + } + if (op == 0x4e436f64) { + ;; upgrade code (accepted only from configuration smart contract) + var ok = upgrade_code(s_addr, in_msg, query_id); + return send_message_back(s_addr, ok ? 0xce436f64 : 0xffffffff, query_id, op, 0, 64); + } + var cfg_ok = (op == 0xee764f4b); + if (cfg_ok | (op == 0xee764f6f)) { + ;; confirmation from configuration smart contract + return config_set_confirmed(s_addr, in_msg, query_id, cfg_ok); + } + if (op == 0x52674370) { + ;; new complaint + var price = register_complaint(s_addr, in_msg, msg_value); + int mode = 64; + int ans_tag = - price; + if (price >= 0) { + ;; ok, debit price + raw_reserve(price, 4); + ans_tag = 0; + mode = 128; + } + return send_message_back(s_addr, ans_tag + 0xf2676350, query_id, op, 0, mode); + } + if (op == 0x56744370) { + ;; vote for a complaint + var signature = in_msg~load_bits(512); + var msg_body = in_msg; + var (sign_tag, idx, elect_id, chash) = (in_msg~load_uint(32), in_msg~load_uint(16), in_msg~load_uint(32), in_msg~load_uint(256)); + in_msg.end_parse(); + throw_unless(37, sign_tag == 0x56744350); + var (vdescr, total_weight) = get_validator_descr(idx); + var (val_pubkey, weight) = unpack_validator_descr(vdescr); + throw_unless(34, check_data_signature(msg_body, signature, val_pubkey)); + int res = proceed_register_vote(elect_id, chash, idx, weight); + return send_message_back(s_addr, res + 0xd6745240, query_id, op, 0, 64); + } + + ifnot (op & (1 << 31)) { + ;; unknown query, return error + return send_message_back(s_addr, 0xffffffff, query_id, op, 0, 64); + } + ;; unknown answer, ignore + return (); +} + +int postpone_elections() impure { + return false; +} + +;; computes the total stake out of the first n entries of list l +_ compute_total_stake(l, n, m_stake) inline_ref { + int tot_stake = 0; + repeat (n) { + (var h, l) = uncons(l); + var stake = h.at(0); + var max_f = h.at(1); + stake = min(stake, (max_f * m_stake) >> 16); + tot_stake += stake; + } + return tot_stake; +} + +(cell, cell, int, cell, int, int) try_elect(credits, members, min_stake, max_stake, min_total_stake, max_stake_factor) { + var cs = 16.config_param().begin_parse(); + var (max_validators, _, min_validators) = (cs~load_uint(16), cs~load_uint(16), cs~load_uint(16)); + cs.end_parse(); + min_validators = max(min_validators, 1); + int n = 0; + var sdict = new_dict(); + var pubkey = -1; + do { + (pubkey, var cs, var f) = members.udict_get_next?(256, pubkey); + if (f) { + var (stake, time, max_factor, addr, adnl_addr) = (cs~load_grams(), cs~load_uint(32), cs~load_uint(32), cs~load_uint(256), cs~load_uint(256)); + cs.end_parse(); + var key = begin_cell() + .store_uint(stake, 128) + .store_int(- time, 32) + .store_uint(pubkey, 256) + .end_cell().begin_parse(); + sdict~dict_set_builder(128 + 32 + 256, key, begin_cell() + .store_uint(min(max_factor, max_stake_factor), 32) + .store_uint(addr, 256) + .store_uint(adnl_addr, 256)); + n += 1; + } + } until (~ f); + n = min(n, max_validators); + if (n < min_validators) { + return (credits, new_dict(), 0, new_dict(), 0, 0); + } + var l = nil; + do { + var (key, cs, f) = sdict~dict::delete_get_min(128 + 32 + 256); + if (f) { + var (stake, _, pubkey) = (min(key~load_uint(128), max_stake), key~load_uint(32), key.preload_uint(256)); + var (max_f, _, adnl_addr) = (cs~load_uint(32), cs~load_uint(256), cs.preload_uint(256)); + l = cons([stake, max_f, pubkey, adnl_addr], l); + } + } until (~ f); + ;; l is the list of all stakes in decreasing order + int i = min_validators - 1; + var l1 = l; + repeat (i) { + l1 = cdr(l1); + } + var (best_stake, m) = (0, 0); + do { + var stake = l1~list_next().at(0); + i += 1; + if (stake >= min_stake) { + var tot_stake = compute_total_stake(l, i, stake); + if (tot_stake > best_stake) { + (best_stake, m) = (tot_stake, i); + } + } + } until (i >= n); + if ((m == 0) | (best_stake < min_total_stake)) { + return (credits, new_dict(), 0, new_dict(), 0, 0); + } + ;; we have to select first m validators from list l + l1 = touch(l); + ;; l1~dump(); ;; DEBUG + repeat (m - 1) { + l1 = cdr(l1); + } + var m_stake = car(l1).at(0); ;; minimal stake + ;; create both the new validator set and the refund set + int i = 0; + var tot_stake = 0; + var tot_weight = 0; + var vset = new_dict(); + var frozen = new_dict(); + do { + var [stake, max_f, pubkey, adnl_addr] = l~list_next(); + ;; lookup source address first + var (val, f) = members.udict_get?(256, pubkey); + throw_unless(61, f); + (_, _, var src_addr) = (val~load_grams(), val~load_uint(64), val.preload_uint(256)); + if (i < m) { + ;; one of the first m members, include into validator set + var true_stake = min(stake, (max_f * m_stake) >> 16); + stake -= true_stake; + ;; ed25519_pubkey#8e81278a pubkey:bits256 = SigPubKey; // 288 bits + ;; validator_addr#73 public_key:SigPubKey weight:uint64 adnl_addr:bits256 = ValidatorDescr; + var weight = (true_stake << 60) / best_stake; + tot_stake += true_stake; + tot_weight += weight; + var vinfo = begin_cell() + .store_uint(adnl_addr ? 0x73 : 0x53, 8) ;; validator_addr#73 or validator#53 + .store_uint(0x8e81278a, 32) ;; ed25519_pubkey#8e81278a + .store_uint(pubkey, 256) ;; pubkey:bits256 + .store_uint(weight, 64); ;; weight:uint64 + if (adnl_addr) { + vinfo~store_uint(adnl_addr, 256); ;; adnl_addr:bits256 + } + vset~udict_set_builder(16, i, vinfo); + frozen~udict_set_builder(256, pubkey, begin_cell() + .store_uint(src_addr, 256) + .store_uint(weight, 64) + .store_grams(true_stake) + .store_int(false, 1)); + } + if (stake) { + ;; non-zero unused part of the stake, credit to the source address + credits~credit_to(src_addr, stake); + } + i += 1; + } until (l.null?()); + throw_unless(49, tot_stake == best_stake); + return (credits, vset, tot_weight, frozen, tot_stake, m); +} + +int conduct_elections(ds, elect, credits) impure { + var (elect_at, elect_close, min_stake, total_stake, members, failed, finished) = elect.unpack_elect(); + if (now() < elect_close) { + ;; elections not finished yet + return false; + } + if (config_param(0).null?()) { + ;; no configuration smart contract to send result to + return postpone_elections(); + } + var cs = config_param(17).begin_parse(); + min_stake = cs~load_grams(); + var max_stake = cs~load_grams(); + var min_total_stake = cs~load_grams(); + var max_stake_factor = cs~load_uint(32); + cs.end_parse(); + if (total_stake < min_total_stake) { + ;; insufficient total stake, postpone elections + return postpone_elections(); + } + if (failed) { + ;; do not retry failed elections until new stakes arrive + return postpone_elections(); + } + if (finished) { + ;; elections finished + return false; + } + (credits, var vdict, var total_weight, var frozen, var total_stakes, var cnt) = try_elect(credits, members, min_stake, max_stake, min_total_stake, max_stake_factor); + ;; pack elections; if cnt==0, set failed=true, finished=false. + failed = (cnt == 0); + finished = ~ failed; + elect = pack_elect(elect_at, elect_close, min_stake, total_stake, members, failed, finished); + ifnot (cnt) { + ;; elections failed, set elect_failed to true + set_data(begin_cell().store_dict(elect).store_dict(credits).store_slice(ds).end_cell()); + return postpone_elections(); + } + ;; serialize a query to the configuration smart contract + ;; to install the computed validator set as the next validator set + var (elect_for, elect_begin_before, elect_end_before, stake_held) = get_validator_conf(); + var start = max(now() + elect_end_before - 60, elect_at); + var main_validators = config_param(16).begin_parse().skip_bits(16).preload_uint(16); + var vset = begin_cell() + .store_uint(0x12, 8) ;; validators_ext#12 + .store_uint(start, 32) ;; utime_since:uint32 + .store_uint(start + elect_for, 32) ;; utime_until:uint32 + .store_uint(cnt, 16) ;; total:(## 16) + .store_uint(min(cnt, main_validators), 16) ;; main:(## 16) + .store_uint(total_weight, 64) ;; total_weight:uint64 + .store_dict(vdict) ;; list:(HashmapE 16 ValidatorDescr) + .end_cell(); + var config_addr = config_param(0).begin_parse().preload_uint(256); + send_validator_set_to_config(config_addr, vset, elect_at); + ;; add frozen to the dictionary of past elections + var past_elections = ds~load_dict(); + past_elections~udict_set_builder(32, elect_at, pack_past_election( + start + elect_for + stake_held, stake_held, vset.cell_hash(), + frozen, total_stakes, 0, null())); + ;; store credits and frozen until end + set_data(begin_cell() + .store_dict(elect) + .store_dict(credits) + .store_dict(past_elections) + .store_slice(ds) + .end_cell()); + return true; +} + +int update_active_vset_id() impure { + var (elect, credits, past_elections, grams, active_id, active_hash) = load_data(); + var cur_hash = config_param(34).cell_hash(); + if (cur_hash == active_hash) { + ;; validator set unchanged + return false; + } + if (active_id) { + ;; active_id becomes inactive + var (fs, f) = past_elections.udict_get?(32, active_id); + if (f) { + ;; adjust unfreeze time of this validator set + var unfreeze_time = fs~load_uint(32); + var fs0 = fs; + var (stake_held, hash) = (fs~load_uint(32), fs~load_uint(256)); + throw_unless(57, hash == active_hash); + unfreeze_time = now() + stake_held; + past_elections~udict_set_builder(32, active_id, begin_cell() + .store_uint(unfreeze_time, 32) + .store_slice(fs0)); + } + } + ;; look up new active_id by hash + var id = -1; + do { + (id, var fs, var f) = past_elections.udict_get_next?(32, id); + if (f) { + var (tm, hash) = (fs~load_uint(64), fs~load_uint(256)); + if (hash == cur_hash) { + ;; parse more of this record + var (dict, total_stake, bonuses) = (fs~load_dict(), fs~load_grams(), fs~load_grams()); + ;; transfer 1/8 of accumulated everybody's grams to this validator set as bonuses + var amount = (grams >> 3); + grams -= amount; + bonuses += amount; + ;; serialize back + past_elections~udict_set_builder(32, id, begin_cell() + .store_uint(tm, 64) + .store_uint(hash, 256) + .store_dict(dict) + .store_grams(total_stake) + .store_grams(bonuses) + .store_slice(fs)); + ;; found + f = false; + } + } + } until (~ f); + active_id = (id.null?() ? 0 : id); + active_hash = cur_hash; + store_data(elect, credits, past_elections, grams, active_id, active_hash); + return true; +} + +int cell_hash_eq?(cell vset, int expected_vset_hash) inline_ref { + return vset.null?() ? false : cell_hash(vset) == expected_vset_hash; +} + +int validator_set_installed(ds, elect, credits) impure { + var (elect_at, elect_close, min_stake, total_stake, members, failed, finished) = elect.unpack_elect(); + ifnot (finished) { + ;; elections not finished yet + return false; + } + var past_elections = ds~load_dict(); + var (fs, f) = past_elections.udict_get?(32, elect_at); + ifnot (f) { + ;; no election data in dictionary + return false; + } + ;; recover validator set hash + var vset_hash = fs.skip_bits(64).preload_uint(256); + if (config_param(34).cell_hash_eq?(vset_hash) | config_param(36).cell_hash_eq?(vset_hash)) { + ;; this validator set has been installed, forget elections + set_data(begin_cell() + .store_int(false, 1) ;; forget current elections + .store_dict(credits) + .store_dict(past_elections) + .store_slice(ds) + .end_cell()); + update_active_vset_id(); + return true; + } + return false; +} + +int check_unfreeze() impure { + var (elect, credits, past_elections, grams, active_id, active_hash) = load_data(); + int id = -1; + do { + (id, var fs, var f) = past_elections.udict_get_next?(32, id); + if (f) { + var unfreeze_at = fs~load_uint(32); + if ((unfreeze_at <= now()) & (id != active_id)) { + ;; unfreeze! + (credits, past_elections, var unused_prizes) = unfreeze_all(credits, past_elections, id); + grams += unused_prizes; + ;; unfreeze only one at time, exit loop + store_data(elect, credits, past_elections, grams, active_id, active_hash); + ;; exit loop + f = false; + } + } + } until (~ f); + return ~ id.null?(); +} + +int announce_new_elections(ds, elect, credits) { + var next_vset = config_param(36); ;; next validator set + ifnot (next_vset.null?()) { + ;; next validator set exists, no elections needed + return false; + } + var elector_addr = config_param(1).begin_parse().preload_uint(256); + var (my_wc, my_addr) = my_address().parse_std_addr(); + if ((my_wc + 1) | (my_addr != elector_addr)) { + ;; this smart contract is not the elections smart contract anymore, no new elections + return false; + } + var cur_vset = config_param(34); ;; current validator set + if (cur_vset.null?()) { + return false; + } + var (elect_for, elect_begin_before, elect_end_before, stake_held) = get_validator_conf(); + var cur_valid_until = cur_vset.begin_parse().skip_bits(8 + 32).preload_uint(32); + var t = now(); + var t0 = cur_valid_until - elect_begin_before; + if (t < t0) { + ;; too early for the next elections + return false; + } + ;; less than elect_before_begin seconds left, create new elections + if (t - t0 < 60) { + ;; pretend that the elections started at t0 + t = t0; + } + ;; get stake parameters + (_, var min_stake) = config_param(17).begin_parse().load_grams(); + ;; announce new elections + var elect_at = t + elect_begin_before; + ;; elect_at~dump(); + var elect_close = elect_at - elect_end_before; + elect = pack_elect(elect_at, elect_close, min_stake, 0, new_dict(), false, false); + set_data(begin_cell().store_dict(elect).store_dict(credits).store_slice(ds).end_cell()); + return true; +} + +() run_ticktock(int is_tock) impure { + ;; check whether an election is being conducted + var ds = get_data().begin_parse(); + var (elect, credits) = (ds~load_dict(), ds~load_dict()); + ifnot (elect.null?()) { + ;; have an active election + throw_if(0, conduct_elections(ds, elect, credits)); ;; elections conducted, exit + throw_if(0, validator_set_installed(ds, elect, credits)); ;; validator set installed, current elections removed + } else { + throw_if(0, announce_new_elections(ds, elect, credits)); ;; new elections announced, exit + } + throw_if(0, update_active_vset_id()); ;; active validator set id updated, exit + check_unfreeze(); +} + +;; Get methods + +;; returns active election id or 0 +int active_election_id() method_id { + var elect = get_data().begin_parse().preload_dict(); + return elect.null?() ? 0 : elect.begin_parse().preload_uint(32); +} + +;; checks whether a public key participates in current elections +int participates_in(int validator_pubkey) method_id { + var elect = get_data().begin_parse().preload_dict(); + if (elect.null?()) { + return 0; + } + var (elect_at, elect_close, min_stake, total_stake, members, failed, finished) = elect.unpack_elect(); + var (mem, found) = members.udict_get?(256, validator_pubkey); + return found ? mem~load_grams() : 0; +} + +;; returns the list of all participants of current elections with their stakes +_ participant_list() method_id { + var elect = get_data().begin_parse().preload_dict(); + if (elect.null?()) { + return nil; + } + var (elect_at, elect_close, min_stake, total_stake, members, failed, finished) = elect.unpack_elect(); + var l = nil; + var id = (1 << 255) + ((1 << 255) - 1); + do { + (id, var fs, var f) = members.udict_get_prev?(256, id); + if (f) { + l = cons([id, fs~load_grams()], l); + } + } until (~ f); + return l; +} + +;; returns the list of all participants of current elections with their data +_ participant_list_extended() method_id { + var elect = get_data().begin_parse().preload_dict(); + if (elect.null?()) { + return (0, 0, 0, 0, nil, 0, 0); + } + var (elect_at, elect_close, min_stake, total_stake, members, failed, finished) = elect.unpack_elect(); + var l = nil; + var id = (1 << 255) + ((1 << 255) - 1); + do { + (id, var cs, var f) = members.udict_get_prev?(256, id); + if (f) { + var (stake, time, max_factor, addr, adnl_addr) = (cs~load_grams(), cs~load_uint(32), cs~load_uint(32), cs~load_uint(256), cs~load_uint(256)); + cs.end_parse(); + l = cons([id, [stake, max_factor, addr, adnl_addr]], l); + } + } until (~ f); + return (elect_at, elect_close, min_stake, total_stake, l, failed, finished); +} + +;; computes the return stake +int compute_returned_stake(int wallet_addr) method_id { + var cs = get_data().begin_parse(); + (_, var credits) = (cs~load_dict(), cs~load_dict()); + var (val, f) = credits.udict_get?(256, wallet_addr); + return f ? val~load_grams() : 0; +} + +;; returns the list of past election ids +tuple past_election_ids() method_id { + var (elect, credits, past_elections, grams, active_id, active_hash) = load_data(); + var id = (1 << 32); + var list = null(); + do { + (id, var fs, var f) = past_elections.udict_get_prev?(32, id); + if (f) { + list = cons(id, list); + } + } until (~ f); + return list; +} + +tuple past_elections() method_id { + var (elect, credits, past_elections, grams, active_id, active_hash) = load_data(); + var id = (1 << 32); + var list = null(); + do { + (id, var fs, var found) = past_elections.udict_get_prev?(32, id); + if (found) { + list = cons([id, unpack_past_election(fs)], list); + } + } until (~ found); + return list; +} + +tuple past_elections_list() method_id { + var (elect, credits, past_elections, grams, active_id, active_hash) = load_data(); + var id = (1 << 32); + var list = null(); + do { + (id, var fs, var found) = past_elections.udict_get_prev?(32, id); + if (found) { + var (unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints) = unpack_past_election(fs); + list = cons([id, unfreeze_at, vset_hash, stake_held], list); + } + } until (~ found); + return list; +} + +_ complete_unpack_complaint(slice cs) inline_ref { + var (complaint, voters, vset_id, weight_remaining) = cs.unpack_complaint_status(); + var voters_list = null(); + var voter_id = (1 << 32); + do { + (voter_id, _, var f) = voters.udict_get_prev?(16, voter_id); + if (f) { + voters_list = cons(voter_id, voters_list); + } + } until (~ f); + return [[complaint.begin_parse().unpack_complaint()], voters_list, vset_id, weight_remaining]; +} + +cell get_past_complaints(int election_id) inline_ref method_id { + var (elect, credits, past_elections, grams, active_id, active_hash) = load_data(); + var (fs, found?) = past_elections.udict_get?(32, election_id); + ifnot (found?) { + return null(); + } + var (unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints) = unpack_past_election(fs); + return complaints; +} + +_ show_complaint(int election_id, int chash) method_id { + var complaints = get_past_complaints(election_id); + var (cs, found) = complaints.udict_get?(256, chash); + return found ? complete_unpack_complaint(cs) : null(); +} + +tuple list_complaints(int election_id) method_id { + var complaints = get_past_complaints(election_id); + int id = (1 << 255) + ((1 << 255) - 1); + var list = null(); + do { + (id, var cs, var found?) = complaints.udict_get_prev?(256, id); + if (found?) { + list = cons(pair(id, complete_unpack_complaint(cs)), list); + } + } until (~ found?); + return list; +} + +int complaint_storage_price(int bits, int refs, int expire_in) method_id { + ;; compute complaint storage/creation price + var (deposit, bit_price, cell_price) = get_complaint_prices(); + var pps = (bits + 1024) * bit_price + (refs + 2) * cell_price; + var paid = pps * expire_in + deposit; + return paid + (1 << 30); +} diff --git a/src/func/grammar-test/highload-wallet-code.fc b/src/func/grammar-test/highload-wallet-code.fc new file mode 100644 index 000000000..8420c1d82 --- /dev/null +++ b/src/func/grammar-test/highload-wallet-code.fc @@ -0,0 +1,47 @@ +;; Heavy-duty wallet for mass transfers (e.g., for cryptocurrency exchanges) +;; accepts orders for up to 254 internal messages (transfers) in one external message + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +() recv_external(slice in_msg) impure { + var signature = in_msg~load_bits(512); + var cs = in_msg; + var (subwallet_id, valid_until, msg_seqno) = (cs~load_uint(32), cs~load_uint(32), cs~load_uint(32)); + throw_if(35, valid_until <= now()); + var ds = get_data().begin_parse(); + var (stored_seqno, stored_subwallet, public_key) = (ds~load_uint(32), ds~load_uint(32), ds~load_uint(256)); + ds.end_parse(); + throw_unless(33, msg_seqno == stored_seqno); + throw_unless(34, subwallet_id == stored_subwallet); + throw_unless(35, check_signature(slice_hash(in_msg), signature, public_key)); + var dict = cs~load_dict(); + cs.end_parse(); + accept_message(); + int i = -1; + do { + (i, var cs, var f) = dict.idict_get_next?(16, i); + if (f) { + var mode = cs~load_uint(8); + send_raw_message(cs~load_ref(), mode); + } + } until (~ f); + set_data(begin_cell() + .store_uint(stored_seqno + 1, 32) + .store_uint(stored_subwallet, 32) + .store_uint(public_key, 256) + .end_cell()); +} + +;; Get methods + +int seqno() method_id { + return get_data().begin_parse().preload_uint(32); +} + +int get_public_key() method_id { + var cs = get_data().begin_parse(); + cs~load_uint(64); + return cs.preload_uint(256); +} diff --git a/src/func/grammar-test/highload-wallet-v2-code.fc b/src/func/grammar-test/highload-wallet-v2-code.fc new file mode 100644 index 000000000..b7626bbe5 --- /dev/null +++ b/src/func/grammar-test/highload-wallet-v2-code.fc @@ -0,0 +1,87 @@ +;; Heavy-duty wallet for mass transfers (e.g., for cryptocurrency exchanges) +;; accepts orders for up to 254 internal messages (transfers) in one external message +;; this version does not use seqno for replay protection; instead, it remembers all recent query_ids +;; in this way several external messages with different query_id can be sent in parallel + + +;; Note, when dealing with highload-wallet the following limits need to be checked and taken into account: +;; 1) Storage size limit. Currently, size of contract storage should be less than 65535 cells. If size of +;; old_queries will grow above this limit, exception in ActionPhase will be thrown and transaction will fail. +;; Failed transaction may be replayed. +;; 2) Gas limit. Currently, gas limit is 1'000'000 gas units, that means that there is a limit of how much +;; old queries may be cleaned in one tx. If number of expired queries will be higher, contract will stuck. + +;; That means that it is not recommended to set too high expiration date: +;; number of queries during expiration timespan should not exceed 1000. +;; Also, number of expired queries cleaned in one transaction should be below 100. + +;; Such precautions are not easy to follow, so it is recommended to use highload contract +;; only when strictly necessary and the developer understands the above details. + + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +() recv_external(slice in_msg) impure { + var signature = in_msg~load_bits(512); + var cs = in_msg; + var (subwallet_id, query_id) = (cs~load_uint(32), cs~load_uint(64)); + var bound = (now() << 32); + throw_if(35, query_id < bound); + var ds = get_data().begin_parse(); + var (stored_subwallet, last_cleaned, public_key, old_queries) = (ds~load_uint(32), ds~load_uint(64), ds~load_uint(256), ds~load_dict()); + ds.end_parse(); + (_, var found?) = old_queries.udict_get?(64, query_id); + throw_if(32, found?); + throw_unless(34, subwallet_id == stored_subwallet); + throw_unless(35, check_signature(slice_hash(in_msg), signature, public_key)); + var dict = cs~load_dict(); + cs.end_parse(); + accept_message(); + int i = -1; + do { + (i, var cs, var f) = dict.idict_get_next?(16, i); + if (f) { + var mode = cs~load_uint(8); + send_raw_message(cs~load_ref(), mode); + } + } until (~ f); + bound -= (64 << 32); ;; clean up records expired more than 64 seconds ago + old_queries~udict_set_builder(64, query_id, begin_cell()); + var queries = old_queries; + do { + var (old_queries', i, _, f) = old_queries.udict_delete_get_min(64); + f~touch(); + if (f) { + f = (i < bound); + } + if (f) { + old_queries = old_queries'; + last_cleaned = i; + } + } until (~ f); + set_data(begin_cell() + .store_uint(stored_subwallet, 32) + .store_uint(last_cleaned, 64) + .store_uint(public_key, 256) + .store_dict(old_queries) + .end_cell()); +} + +;; Get methods + +;; returns -1 for processed queries, 0 for unprocessed, 1 for unknown (forgotten) +int processed?(int query_id) method_id { + var ds = get_data().begin_parse(); + var (_, last_cleaned, _, old_queries) = (ds~load_uint(32), ds~load_uint(64), ds~load_uint(256), ds~load_dict()); + ds.end_parse(); + (_, var found) = old_queries.udict_get?(64, query_id); + return found ? true : - (query_id <= last_cleaned); +} + +int get_public_key() method_id { + var cs = get_data().begin_parse(); + cs~load_uint(32 + 64); + return cs.preload_uint(256); +} diff --git a/src/func/grammar-test/mathlib.fc b/src/func/grammar-test/mathlib.fc new file mode 100644 index 000000000..f2dfd73f5 --- /dev/null +++ b/src/func/grammar-test/mathlib.fc @@ -0,0 +1,939 @@ +{- + - + - FunC fixed-point mathematical library + - + -} + +{- + This file is part of TON FunC Standard Library. + + FunC Standard Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + FunC Standard Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + +-} + +#include "stdlib.fc"; +#pragma version >=0.4.2; + +{---------------- HIGH-LEVEL FUNCTION DECLARATIONS -----------------} +{- + Most functions declared here work either with integers or with fixed-point numbers of type `fixed248`. + `fixedNNN` informally denotes an alias for type `int` used to represent fixed-point numbers with scale 2^NNN. + Prefix `fixedNNN::` is prepended to the names of high-level functions that accept arguments and return values of type `fixedNNN`. +-} + +{- function declarations have been commented out, otherwise they are not inlined by the current FunC compiler + +;; nearest integer to sqrt(a*b) for non-negative integers or fixed-point numbers a and b +int geom_mean(int a, int b) inline_ref; +;; integer square root +int sqrt(int a) inline; +;; fixed-point square root +;; fixed248 sqrt(fixed248 x) +int fixed248::sqrt(int x) inline; + +int fixed248::sqr(int x) inline; +const int fixed248::One; + +;; log(2) as fixed248 +int fixed248::log2_const() inline; +;; Pi as fixed248 +int fixed248::Pi_const() inline; + +;; fixed248 exp(fixed248 x) +int fixed248::exp(int x) inline_ref; +;; fixed248 exp2(fixed248 x) +int fixed248::exp2(int x) inline_ref; + +;; fixed248 log(fixed248 x) +int fixed248::log(int x) inline_ref; +;; fixed248 log2(fixed248 x) +int fixed248::log2(int x) inline; + +;; fixed248 pow(fixed248 x, fixed248 y) +int fixed248::pow(int x, int y) inline_ref; + +;; (fixed248, fixed248) sincos(fixed248 x); +(int, int) fixed248::sincos(int x) inline_ref; +;; fixed248 sin(fixed248 x); +int fixed248::sin(int x) inline; +;; fixed248 cos(fixed248 x); +int fixed248::cos(int x) inline; +;; fixed248 tan(fixed248 x); +int fixed248::tan(int x) inline_ref; +;; fixed248 cot(fixed248 x); +int fixed248::cot(int x) inline_ref; + + +;; fixed248 asin(fixed248 x); +int fixed248::asin(int x) inline; +;; fixed248 acos(fixed248 x); +int fixed248::acos(int x) inline; +;; fixed248 atan(fixed248 x); +int fixed248::atan(int x) inline_ref; +;; fixed248 acot(fixed248 x); +int fixed248::acot(int x) inline_ref; + +;; random number uniformly distributed in [0..1) +;; fixed248 random(); +int fixed248::random() impure inline; +;; random number with standard normal distribution (2100 gas on average) +;; fixed248 nrand(); +int fixed248::nrand() impure inline; +;; generates a random number approximately distributed according to the standard normal distribution (1200 gas) +;; (fails chi-squared test, but it is shorter and faster than fixed248::nrand()) +;; fixed248 nrand_fast(); +int fixed248::nrand_fast() impure inline; + +-} ;; end (declarations) + +{-------------------- INTERMEDIATE FUNCTIONS -----------------------} + +{- + Intermediate functions are used in the implementations of high-level `fixedNNN::...` functions + if necessary, they can be used to define additional high-level functions for other fixed-point types, such as fixed128, outside this library. They can be also used in a hypothetical floating-point FunC library. + For these reasons, the declarations of these functions are collected here. +-} + +{- function declarations have been commented out, otherwise they are not inlined by the current FunC compiler + +;; fixed258 tanh(fixed258 x, int steps); +int tanh_f258(int x, int n); + +;; computes exp(x)-1 for |x| <= log(2)/2. +;; fixed257 expm1(fixed257 x); +int expm1_f257(int x); + +;; computes (sin(x+xe),-cos(x+xe)) for |x| <= Pi/4, xe very small +;; this function is very accurate, error less than 0.7 ulp (consumes ~ 5500 gas) +;; (fixed256, fixed256) sincosn(fixed256 x, fixed259 xe) +(int, int) sincosn_f256(int x, int xe); + +;; compute (sin(x),1-cos(x)) in fixed256 for |x| < 16*atan(1/16) = 0.9987 +;; (fixed256, fixed257) sincosm1_f256(fixed256 x); +;; slightly less accurate than sincosn_f256() (error up to 3/2^256), but faster (~ 4k gas) and shorter +(int, int) sincosm1_f256(int x); + +;; compute (p, q) such that p/q = tan(x) for |x|<2*atan(1/2)=1899/2048=0.927 +;; (int, int) tan_aux(fixed256 x); +(int, int) tan_aux_f256(int x); + +;; returns (y, s) such that log(x) = y/2^256 + s*log(2) for positive integer x +;; this function is very precise (error less than 0.6 ulp) and consumes < 7k gas +;; (fixed256, int) log_aux_f256(int x); +(int, int) log_aux_f256(int x); + +;; returns (y, s) such that log2(x) = y/2^256 + s for positive integer x +;; this function is very precise (error less than 0.6 ulp) and consumes < 7k gas +;; (fixed256, int) log2_aux_f256(int x); +(int, int) log2_aux_f256(int x); + +;; compute (q, z) such that atan(x)=q*atan(1/32)+z for -1 <= x < 1 +;; this function is reasonably accurate (error < 7 ulp with ulp = 2^-261), but it consumes >7k gas +;; this is sufficient for most purposes +;; (int, fixed261) atan_aux(fixed256 x) +(int, int) atan_aux_f256(int x); + +;; fixed255 atan(fixed255 x); +int atan_f255(int x); + +;; for -1 <= x < 1 only +;; fixed256 atan_small(fixed256 x); +int atan_f256_small(int x); + +;; fixed255 asin(fixed255 x); +int asin_f255(int x); + +;; fixed254 acos(fixed255 x); +int acos_f255(int x); + +;; generates normally distributed pseudo-random number +;; fixed252 nrand(); +int nrand_f252(int x); + +;; a faster and shorter variant of nrand_f252() that fails chi-squared test +;; (should suffice for most purposes) +;; fixed252 nrand_fast(); +int nrand_fast_f252(int x); + +-} ;; end (declarations) + +{---------------- MISSING OPERATIONS AND BUILT-INS -----------------} + +int sgn(int x) asm "SGN"; + +;; compute floor(log2(x))+1 +int log2_floor_p1(int x) asm "UBITSIZE"; + +int mulrshiftr(int x, int y, int s) asm "MULRSHIFTR"; +int mulrshiftr256(int x, int y) asm "256 MULRSHIFTR#"; +(int, int) mulrshift256mod(int x, int y) asm "256 MULRSHIFT#MOD"; +(int, int) mulrshiftr256mod(int x, int y) asm "256 MULRSHIFTR#MOD"; +(int, int) mulrshiftr255mod(int x, int y) asm "255 MULRSHIFTR#MOD"; +(int, int) mulrshiftr248mod(int x, int y) asm "248 MULRSHIFTR#MOD"; +(int, int) mulrshiftr5mod(int x, int y) asm "5 MULRSHIFTR#MOD"; +(int, int) mulrshiftr6mod(int x, int y) asm "6 MULRSHIFTR#MOD"; +(int, int) mulrshiftr7mod(int x, int y) asm "7 MULRSHIFTR#MOD"; + +int lshift256divr(int x, int y) asm "256 LSHIFT#DIVR"; +(int, int) lshift256divmodr(int x, int y) asm "256 LSHIFT#DIVMODR"; +(int, int) lshift255divmodr(int x, int y) asm "255 LSHIFT#DIVMODR"; +(int, int) lshift2divmodr(int x, int y) asm "2 LSHIFT#DIVMODR"; +(int, int) lshift7divmodr(int x, int y) asm "7 LSHIFT#DIVMODR"; +(int, int) lshiftdivmodr(int x, int y, int s) asm "LSHIFTDIVMODR"; + +(int, int) rshiftr256mod(int x) asm "256 RSHIFTR#MOD"; +(int, int) rshiftr248mod(int x) asm "248 RSHIFTR#MOD"; +(int, int) rshiftr4mod(int x) asm "4 RSHIFTR#MOD"; +(int, int) rshift3mod(int x) asm "3 RSHIFT#MOD"; + +;; computes y - x (FunC compiler does not try to use this by itself) +int sub_rev(int x, int y) asm "SUBR"; + +int nan() asm "PUSHNAN"; +int is_nan(int x) asm "ISNAN"; + +{------------------------ SQUARE ROOTS ----------------------------} + +;; computes sqrt(a*b) exactly rounded to the nearest integer +;; for all 0 <= a, b <= 2^256-1 +;; may be used with b=1 or b=scale of fixed-point numbers +int geom_mean(int a, int b) inline_ref { + ifnot (min(a, b)) { + return 0; + } + int s = log2_floor_p1(a); ;; throws out of range error if a < 0 or b < 0 + int t = log2_floor_p1(b); + ;; NB: (a-b)/2+b == (a+b)/2, but without overflow for large a and b + int x = (s == t ? (a - b) / 2 + b : 1 << ((s + t) / 2)); + do { + ;; if always used with b=2^const, may be optimized to "const LSHIFTDIVC#" + ;; it is important to use `muldivc` here, not `muldiv` or `muldivr` + int q = (muldivc(a, b, x) - x) / 2; + x += q; + } until (q == 0); + return x; +} + +;; integer square root, computes round(sqrt(a)) for all a>=0. +;; note: `inline` is better than `inline_ref` for such simple functions +int sqrt(int a) inline { + return geom_mean(a, 1); +} + +;; version for fixed248 = fixed-point numbers with scale 2^248 +;; fixed248 sqrt(fixed248 x) +int fixed248::sqrt(int x) inline { + return geom_mean(x, 1 << 248); +} + +;; fixed255 sqrt(fixed255 x) +int fixed255::sqrt(int x) inline { + return geom_mean(x, 1 << 255); +} + +;; fixed248 sqr(fixed248 x); +int fixed248::sqr(int x) inline { + return muldivr(x, x, 1 << 248); +} + +;; fixed255 sqr(fixed255 x); +int fixed255::sqr(int x) inline { + return muldivr(x, x, 1 << 255); +} + +const int fixed248::One = (1 << 248); +const int fixed255::One = (1 << 255); + +{-------------------- USEFUL CONSTANTS --------------------} + +;; store huge constants in inline_ref functions for reuse +;; (y,z) where y=round(log(2)*2^256), z=round((log(2)*2^256-y)*2^128) +;; then log(2) = y/2^256 + z/2^384 +(int, int) log2_xconst_f256() inline_ref { + return (80260960185991308862233904206310070533990667611589946606122867505419956976172, -32272921378999278490133606779486332143); +} + +;; (y,z) where Pi = y/2^254 + z/2^382 +(int, int) Pi_xconst_f254() inline_ref { + return (90942894222941581070058735694432465663348344332098107489693037779484723616546, 108051869516004014909778934258921521947); +} + +;; atan(1/16) as fixed260 +int Atan1_16_f260() inline_ref { + return 115641670674223639132965820642403718536242645001775371762318060545014644837101; ;; true value is ...101.0089... +} + +;; atan(1/8) as fixed259 +int Atan1_8_f259() inline_ref { + return 115194597005316551477397594802136977648153890007566736408151129975021336532841; ;; correction -0.1687... +} + +;; atan(1/32) as fixed261 +int Atan1_32_f261() inline_ref { + return 115754418570128574501879331591757054405465733718902755858991306434399246026247; ;; correction 0.395... +} + +;; inline is better than inline_ref for such very small functions +int log2_const_f256() inline { + (int c, _) = log2_xconst_f256(); + return c; +} + +int fixed248::log2_const() inline { + return log2_const_f256() ~>> 8; +} + +int Pi_const_f254() inline { + (int c, _) = Pi_xconst_f254(); + return c; +} + +int fixed248::Pi_const() inline { + return Pi_const_f254() ~>> 6; +} + +{--------------- HYPERBOLIC TANGENT AND EXPONENT -------------------} + +;; hyperbolic tangent of small x via n+2 terms of Lambert's continued fraction +;; n=17: good for |x| < log(2)/4 = 0.173 +;; fixed258 tanh_f258(fixed258 x, int n) +int tanh_f258(int x, int n) inline_ref { + int x2 = muldivr(x, x, 1 << 255); ;; x^2 as fixed261 + int c = int a = (2 * n + 5) << 250; ;; a=2n+5 as fixed250 + int Two = (1 << 251); ;; 2. as fixed250 + repeat (n) { + a = (c -= Two) + muldivr(x2, 1 << 239, a); ;; a := 2k+1+x^2/a as fixed250, k=n+1,n,...,2 + } + a = (touch(3) << 254) + muldivr(x2, 1 << 243, a); ;; a := 3+x^2/a as fixed254 + ;; y = x/(1+a') = x - x*a'/(1+a') = x - x*x^2/(a+x^2) where a' = x^2/a + return x - (muldivr(x, x2, a + (x2 ~>> 7)) ~>> 7); +} + +;; fixed257 expm1_f257(fixed257 x) +;; computes exp(x)-1 for small x via 19 terms of Lambert's continued fraction for tanh(x/2) +;; good for |x| < log(2)/2 = 0.347 (n=17); consumes ~3500 gas +int expm1_f257(int x) inline_ref { + ;; (almost) compute tanh(x/2) first; x/2 as fixed258 = x as fixed257 + int x2 = muldivr(x, x, 1 << 255); ;; x^2 as fixed261 + int Two = (1 << 251); ;; 2. as fixed250 + int c = int a = touch(39) << 250; ;; a=2n+5 as fixed250 + repeat (17) { + a = (c -= Two) + muldivr(x2, 1 << 239, a); ;; a := 2k+1+x^2/a as fixed250, k=n+1,n,...,2 + } + a = (touch(3) << 254) + muldivr(x2, 1 << 243, a); ;; a := 3+x^2/a as fixed254 + ;; now tanh(x/2) = x/(1+a') where a'=x^2/a ; apply exp(x)-1=2*tanh(x/2)/(1-tanh(x/2)) + int t = (x ~>> 4) - a; ;; t:=x-a as fixed254 + return x - muldivr(x2, t / 2, a + mulrshiftr256(x, t) ~/ 4) ~/ 4; ;; x - x^2 * (x-a) / (a + x*(x-a)) +} + +;; expm1_f257() may be used to implement specific fixed-point exponentials +;; example: +;; fixed248 exp(fixed248 x) +int fixed248::exp(int x) inline_ref { + var (l2c, l2d) = log2_xconst_f256(); + ;; divide x by log(2) and convert to fixed257 + ;; (int q, x) = muldivmodr(x, 256, l2c); ;; unfortunately, no such built-in + (int q, x) = lshiftdivmodr(x, l2c, 8); + x = 2 * x - muldivr(q, l2d, 1 << 127); + int y = expm1_f257(x); + ;; result is (1 + y) * (2^q) --> ((1 << 257) + y) >> (9 - q) + return (y ~>> (9 - q)) - (-1 << (248 + q)); + ;; note that (y ~>> (9 - q)) + (1 << (248 + q)) leads to overflow when q=8 +} + +;; compute 2^x in fixed248 +;; fixed248 exp2(fixed248 x) +int fixed248::exp2(int x) inline_ref { + ;; (int q, x) = divmodr(x, 1 << 248); ;; no such built-in + (int q, x) = rshiftr248mod(x); + x = muldivr(x, log2_const_f256(), 1 << 247); + int y = expm1_f257(x); + return (y ~>> (9 - q)) - (-1 << (248 + q)); +} + +{--------------------- TRIGONOMETRIC FUNCTIONS -----------------------} + +;; fixed260 tan(fixed260 x); +;; computes tan(x) for small |x|> 10)) ~>> 9); +} + +;; fixed260 tan(fixed260 x); +int tan_f260(int x) inline_ref { + return tan_f260_inlined(x); +} + +;; fixed258 tan(fixed258 x); +;; computes tan(x) for small |x|> 6)) ~>> 5); +} + +;; fixed258 tan(fixed258 x); +int tan_f258(int x) inline_ref { + return tan_f258_inlined(x); +} + +;; (fixed259, fixed263) sincosm1(fixed259 x) +;; computes (sin(x), 1-cos(x)) for small |x|<2*atan(1/16) +(int, int) sincosm1_f259_inlined(int x) inline { + int t = tan_f260_inlined(x); ;; t=tan(x/2) as fixed260 + int tt = mulrshiftr256(t, t); ;; t^2 as fixed264 + int y = tt ~/ 512 + (1 << 255); ;; 1+t^2 as fixed255 + ;; 2*t/(1+t^2) as fixed259 and 2*t^2/(1+t^2) as fixed263 + ;; return (muldivr(t, 1 << 255, y), muldivr(tt, 1 << 255, y)); + return (t - muldivr(t / 2, tt, y) ~/ 256, tt - muldivr(tt / 2, tt, y) ~/ 256); +} + +(int, int) sincosm1_f259(int x) inline_ref { + return sincosm1_f259_inlined(x); +} + +;; computes (sin(x+xe),-cos(x+xe)) for |x| <= Pi/4, xe very small +;; this function is very accurate, error less than 0.7 ulp (consumes ~ 5500 gas) +;; (fixed256, fixed256) sincosn(fixed256 x, fixed259 xe) +(int, int) sincosn_f256(int x, int xe) inline_ref { + ;; var (q, x1) = muldivmodr(x, 8, Atan1_8_f259()); ;; no muldivmodr() builtin + var (q, x1) = lshift2divmodr(abs(x), Atan1_8_f259()); ;; reduce mod theta where theta=2*atan(1/8) + var (si, co) = sincosm1_f259(x1 * 2 + xe); + var (a, b, c) = (-1, 0, 1); + repeat (q) { ;; (a+b*I) *= (8+I)^2 = 63+16*I + (a, b, c) = (63 * a - 16 * b, 16 * a + 63 * b, 65 * c); + } + ;; now a/c = cos(q*theta), b/c = sin(q*theta) exactly(!) + ;; compute (a+b*I)*(1-co+si*I)/c + ;; (b, a) = (lshift256divr(b, c), lshift256divr(a, c)); + (b, int br) = lshift256divmodr(b, c); br = muldivr(br, 128, c); + (a, int ar) = lshift256divmodr(a, c); ar = muldivr(ar, 128, c); + return (sgn(x) * (((mulrshiftr256(b, co) - br) ~/ 16 - mulrshiftr256(a, si)) ~/ 8 - b), + a - ((mulrshiftr256(a, co) - ar) ~/ 16 + mulrshiftr256(b, si)) ~/ 8); +} + +;; compute (sin(x),1-cos(x)) in fixed256 for |x| < 16*atan(1/16) = 0.9987 +;; (fixed256, fixed257) sincosm1_f256(fixed256 x); +;; slightly less accurate than sincosn_f256() (error up to 3/2^256), but faster (~ 4k gas) and shorter +(int, int) sincosm1_f256(int x) inline_ref { + var (si, co) = sincosm1_f259_inlined(x); ;; compute (sin,1-cos)(x/8) in (fixed259,fixed263) + int r = 7; + repeat (r / 2) { + ;; 1-cos(2*x) = 2*sin(x)^2, sin(2*x) = 2*sin(x)*cos(x) + (co, si) = (mulrshiftr256(si, si), si - (mulrshiftr256(si, co) ~>> r)); + r -= 2; + } + return (si, co); +} + +;; compute (p, q) such that p/q = tan(x) for |x|<2*atan(1/2)=1899/2048=0.927 +;; (int, int) tan_aux(fixed256 x); +(int, int) tan_aux_f256(int x) inline_ref { + int t = tan_f258_inlined(x); ;; t=tan(x/4) as fixed258 + ;; t:=2*t/(1-t^2)=2*(t-t^3/(t^2-1)) + int tt = mulrshiftr256(t, t); ;; t^2 as fixed260 + t = muldivr(t, tt, tt ~/ 16 + (-1 << 256)) ~/ 16 - t; ;; now t=-tan(x/2) as fixed259 + return (t, mulrshiftr256(t, t) ~/ 4 + (-1 << 256)); ;; return (2*t, t^2-1) as fixed256 +} + +;; sincosm1_f256() and sincosn_f256() may be used to implement trigonometric functions for different fixed-point types +;; example: +;; (fixed248, fixed248) sincos(fixed248 x); +(int, int) fixed248::sincos(int x) inline_ref { + var (Pic, Pid) = Pi_xconst_f254(); + ;; (int q, x) = muldivmodr(x, 128, Pic); ;; no muldivmodr() builtin + (int q, x) = lshift7divmodr(x, Pic); ;; reduce mod Pi/2 + x = 2 * x - muldivr(q, Pid, 1 << 127); + (int si, int co) = sincosm1_f256(x); ;; doesn't make sense to use more accurate sincosn_f256() + co = (1 << 248) - (co ~>> 9); + si ~>>= 8; + repeat (q & 3) { + (si, co) = (co, - si); + } + return (si, co); +} + +;; fixed248 sin(fixed248 x); +;; inline is better than inline_ref for such simple functions +int fixed248::sin(int x) inline { + (int si, _) = fixed248::sincos(x); + return si; +} + +;; fixed248 cos(fixed248 x); +int fixed248::cos(int x) inline { + (_, int co) = fixed248::sincos(x); + return co; +} + +;; similarly, tan_aux_f256() may be used to implement tan() and cot() for specific fixed-point formats +;; fixed248 tan(fixed248 x); +;; not very accurate when |tan(x)| is very large (difficult to do better without floating-point numbers) +;; however, the relative accuracy is approximately 2^-247 in all cases, which is good enough for arguments given up to 2^-249 +int fixed248::tan(int x) inline_ref { + var (Pic, Pid) = Pi_xconst_f254(); + ;; (int q, x) = muldivmodr(x, 128, Pic); ;; no muldivmodr() builtin + (int q, x) = lshift7divmodr(x, Pic); ;; reduce mod Pi/2 + x = 2 * x - muldivr(q, Pid, 1 << 127); + var (a, b) = tan_aux_f256(x); ;; now a/b = tan(x') + if (q & 1) { + (a, b) = (b, - a); + } + return muldivr(a, 1 << 248, b); ;; either -b/a or a/b as fixed248 +} + +;; fixed248 cot(fixed248 x); +int fixed248::cot(int x) inline_ref { + var (Pic, Pid) = Pi_xconst_f254(); + (int q, x) = lshift7divmodr(x, Pic); ;; reduce mod Pi/2 + x = 2 * x - muldivr(q, Pid, 1 << 127); + var (b, a) = tan_aux_f256(x); ;; now b/a = tan(x') + if (q & 1) { + (a, b) = (b, - a); + } + return muldivr(a, 1 << 248, b); ;; either -b/a or a/b as fixed248 +} + +{----------------- INVERSE HYPERBOLIC TANGENT AND LOGARITHMS -----------------} + +;; inverse hyperbolic tangent of small x, evaluated by means of n terms of the continued fraction +;; valid for |x| < 2^-2.5 ~ 0.18 if n=37 (slightly less accurate with n=36) +;; |x| < 1/8 if n=32; |x| < 2^-3.5 if n=28; |x| < 1/16 if n=25 +;; |x| < 2^-4.5 if n=23; |x| < 1/32 if n=21; |x| < 1/64 if n=18 +;; fixed258 atanh(fixed258 x); +int atanh_f258(int x, int n) inline_ref { + int x2 = mulrshiftr256(x, x); ;; x^2 as fixed260 + int One = (1 << 254); + int a = One ~/ n + (1 << 255); ;; a := 2 + 1/n as fixed254 + repeat (n - 1) { + ;; a := 1 + (1 - x^2 / a)(1 + 1/n) as fixed254 + int t = One - muldivr(x2, 1 << 248, a); ;; t := 1 - x^2 / a + a = muldivr(t, n, (int n1 = n - 1)) + One; + n = n1; + } + ;; x / (1 - x^2 / a) = x / (1 - d) = x + x * d / (1 - d) for d = x^2 / a + ;; int d = muldivr(x2, 1 << 255, a - (x2 ~>> 6)); ;; d/(1-d) = x^2/(a-x^2) as fixed261 + ;; return x + (mulrshiftr256(x, d) ~>> 5); + return x + muldivr(x, x2 / 2, a - x2 ~/ 64) ~/ 32; +} + +;; number of terms n should be chosen as for atanh_f258() +;; fixed261 atanh(fixed261 x); +int atanh_f261_inlined(int x, int n) inline { + int x2 = mulrshiftr256(x, x); ;; x^2 as fixed266 + int One = (1 << 254); + int a = One ~/ n + (1 << 255); ;; a := 2 + 1/n as fixed254 + repeat (n - 1) { + ;; a := 1 + (1 - x^2 / a)(1 + 1/n) as fixed254 + int t = One - muldivr(x2, 1 << 242, a); ;; t := 1 - x^2 / a + a = muldivr(t, n, (int n1 = n - 1)) + One; + n = n1; + } + ;; x / (1 - x^2 / a) = x / (1 - d) = x + x * d / (1 - d) for d = x^2 / a + ;; int d = muldivr(x2, 1 << 255, a - (x2 ~>> 12)); ;; d/(1-d) = x^2/(a-x^2) as fixed267 + ;; return x + (mulrshiftr256(x, d) ~>> 11); + return x + muldivr(x, x2, a - x2 ~/ 4096) ~/ 4096; +} + +;; fixed261 atanh(fixed261 x); +int atanh_f261(int x, int n) inline_ref { + return atanh_f261_inlined(x, n); +} + +;; returns (y, s) such that log(x) = y/2^257 + s*log(2) for positive integer x +;; (fixed257, int) log_aux(int x) +(int, int) log_aux_f257(int x) inline_ref { + int s = log2_floor_p1(x); + x <<= 256 - s; + int t = touch(-1 << 256); + if ((x >> 249) <= 90) { + ;; t~touch(); + t >>= 1; + s -= 1; + } + x += t; + int 2x = 2 * x; + int y = lshift256divr(2x, (x >> 1) - t); + ;; y = 2x - (mulrshiftr256(2x, y) ~>> 2); ;; this line could improve precision on very rare occasions + return (atanh_f258(y, 36), s); +} + +;; computes 33^m for small m +int pow33(int m) inline { + int t = 1; + repeat (m) { t *= 33; } + return t; +} + +;; computes 33^m for small 0<=m<=22 +;; slightly faster than pow33() +int pow33b(int m) inline { + (int mh, int ml) = m /% 5; + int t = 1; + repeat (ml) { t *= 33; } + repeat (mh) { t *= 33 * 33 * 33 * 33 * 33; } + return t; +} + +;; returns (s, q, y) such that log(x) = s*log(2) + q*log(33/32) + y/2^260 for positive integer x +;; (int, int, fixed260) log_auxx_f260(int x); +(int, int, int) log_auxx_f260(int x) inline_ref { + int s = log2_floor_p1(x) - 1; + x <<= 255 - s; ;; rescale to 1 <= x < 2 as fixed255 + int t = touch(2873) << 244; ;; ~ (33/32)^11 ~ sqrt(2) as fixed255 + int x1 = (x - t) >> 1; + int q = muldivr(x1, 65, x1 + t) + 11; ;; crude approximation to round(log(x)/log(33/32)) + ;; t = 1; repeat (q) { t *= 33; } ;; t:=33^q, 0<=q<=22 + t = pow33b(q); + t <<= (51 - q) * 5; ;; t:=(33/32)^q as fixed255, nearest power of 33/32 to x + x -= t; + int y = lshift256divr(x << 4, (x >> 1) + t); ;; y = (x-t)/(x+t) as fixed261 + y = atanh_f261(y, 18); ;; atanh((x-t)/(x+t)) as fixed261, or log(x/t) as fixed260 + return (s, q, y); +} + +;; returns (y, s) such that log(x) = y/2^256 + s*log(2) for positive integer x +;; this function is very precise (error less than 0.6 ulp) and consumes < 7k gas +;; (fixed256, int) log_aux_f256(int x); +(int, int) log_aux_f256(int x) inline_ref { + var (s, q, y) = log_auxx_f260(x); + var (yh, yl) = rshiftr4mod(y); ;; y ~/% 16 , but FunC does not optimize this to RSHIFTR#MOD + ;; int Log33_32 = 3563114646320977386603103333812068872452913448227778071188132859183498739150; ;; log(33/32) as fixed256 + ;; int Log33_32_l = -3769; ;; log(33/32) = Log33_32 / 2^256 + Log33_32_l / 2^269 + yh += (yl * 512 + q * -3769) ~>> 13; ;; compensation, may be removed if slightly worse accuracy is acceptable + int Log33_32 = 3563114646320977386603103333812068872452913448227778071188132859183498739150; ;; log(33/32) as fixed256 + return (yh + q * Log33_32, s); +} + +;; returns (y, s) such that log2(x) = y/2^256 + s for positive integer x +;; this function is very precise (error less than 0.6 ulp) and consumes < 7k gas +;; (fixed256, int) log2_aux_f256(int x); +(int, int) log2_aux_f256(int x) inline_ref { + var (s, q, y) = log_auxx_f260(x); + y = lshift256divr(y, log2_const_f256()) ~>> 4; ;; y/log(2) as fixed256 + int Log33_32 = 5140487830366106860412008603913034462883915832139695448455767612111363481357; ;; log_2(33/32) as fixed256 + ;; Log33_32/2^256 happens to be a very precise approximation to log_2(33/32), no compensation required + return (y + q * Log33_32, s); +} + +;; functions log_aux_f256() and log2_aux_f256() may be used to implement specific fixed-point instances of log() and log2() + +;; fixed248 log(fixed248 x) +int fixed248::log(int x) inline_ref { + var (y, s) = log_aux_f256(x); + return muldivr(s - 248, log2_const_f256(), 1 << 8) + (y ~>> 8); + ;; return muldivr(s - 248, 80260960185991308862233904206310070533990667611589946606122867505419956976172, 1 << 8) + (y ~>> 8); +} + +;; fixed248 log2(fixed248 x) +int fixed248::log2(int x) inline { + var (y, s) = log2_aux_f256(x); + return ((s - 248) << 248) + (y ~>> 8); +} + +;; computes x^y as exp(y*log(x)), x >= 0 +;; fixed248 pow(fixed248 x, fixed248 y); +int fixed248::pow(int x, int y) inline_ref { + ifnot (y) { + return 1 << 248; ;; x^0 = 1 + } + if (x <= 0) { + int bad = (x | y) < 0; + return 0 >> bad; ;; 0^y = 0 if x=0 and y>=0; "out of range" exception otherwise + } + var (l, s) = log2_aux_f256(x); + s -= 248; ;; log_2(x) = s+l, l is fixed256, 0<=l<1 + ;; compute (s+l)*y = q+ll + var (q1, r1) = mulrshiftr248mod(s, y); ;; muldivmodr(s, y, 1 << 248) + var (q2, r2) = mulrshift256mod(l, y); + r2 >>= 247; + var (q3, r3) = rshiftr248mod(q2); ;; divmodr(q2, 1 << 248); + var (q, ll) = rshiftr248mod(r1 + r3); + ll = 512 * ll + r2; + q += q1 + q3; + ;; now log_2(x^y) = y*log_2(x) = q + ll, ss integer, ll fixed257, -1/2<=ll<1/2 + int sq = q + 248; + if (sq <= 0) { + return - (sq == 0); ;; underflow + } + int y = expm1_f257(mulrshiftr256(ll, log2_const_f256())); + return (y ~>> (9 - q)) - (-1 << sq); +} + +{--------------------- INVERSE TRIGONOMETRIC FUNCTIONS -------------------} + +;; number of terms n should be chosen as for atanh_f258() +;; fixed259 atan(fixed259 x); +int atan_f259(int x, int n) inline_ref { + int x2 = mulrshiftr256(x, x); ;; x^2 as fixed262 + int One = (1 << 254); + int a = One ~/ n + (1 << 255); ;; a := 2 + 1/n as fixed254 + repeat (n - 1) { + ;; a := 1 + (1 + x^2 / a)(1 + 1/n) as fixed254 + int t = One + muldivr(x2, 1 << 246, a); ;; t := 1 + x^2 / a + a = muldivr(t, n, (int n1 = n - 1)) + One; + n = n1; + } + ;; x / (1 + x^2 / a) = x / (1 + d) = x - x * d / (1 + d) = x - x * x^2/(a+x^2) for d = x^2 / a + return x - muldivr(x, x2, a + x2 ~/ 256) ~/ 256; +} + +;; number of terms n should be chosen as for atanh_f261() +;; fixed261 atan(fixed261 x); +int atan_f261_inlined(int x, int n) inline { + int x2 = mulrshiftr256(x, x); ;; x^2 as fixed266 + int One = (1 << 254); + int a = One ~/ n + (1 << 255); ;; a := 2 + 1/n as fixed254 + repeat (n - 1) { + ;; a := 1 + (1 + x^2 / a)(1 + 1/n) as fixed254 + int t = One + muldivr(x2, 1 << 242, a); ;; t := 1 + x^2 / a + a = muldivr(t, n, (int n1 = n - 1)) + One; + n = n1; + } + ;; x / (1 + x^2 / a) = x / (1 + d) = x - x * d / (1 + d) = x - x * x^2/(a+x^2) for d = x^2 / a + return x - muldivr(x, x2, a + x2 ~/ 4096) ~/ 4096; +} + +;; fixed261 atan(fixed261 x); +int atan_f261(int x, int n) inline_ref { + return atan_f261_inlined(x, n); +} + +;; computes (q,a,b) such that q is approximately atan(x)/atan(1/32) and a+b*I=(1+I/32)^q as fixed255 +;; then b/a=atan(q*atan(1/32)) exactly, and (a,b) is almost a unit vector pointing in the direction of (1,x) +;; must have |x|<1.1, x is fixed24 +;; (int, fixed255, fixed255) atan_aux_prereduce(fixed24 x); +(int, int, int) atan_aux_prereduce(int x) inline_ref { + int xu = abs(x); + int tc = 7214596; ;; tan(13*theta) as fixed24 where theta=atan(1/32) + int t1 = muldivr(xu - tc, 1 << 88, xu * tc + (1 << 48)); ;; tan(x') as fixed64 where x'=atan(x)-13*theta + ;; t1/(3+t1^2) * 3073/32 = x'/3 * 3072/32 = x' / (96/3072) = x' / theta + int q = muldivr(t1 * 3073, 1 << 59, t1 * t1 + (touch(3) << 128)) + 13; ;; approximately round(atan(x)/theta), 0<=q<=25 + var (pa, pb) = (33226912, 5232641); ;; (32+I)^5 + var (qh, ql) = q /% 5; + var (a, b) = (1 << (5 * (51 - q)), 0); ;; (1/32^q, 0) as fixed255 + repeat (ql) { ;; a+b*I *= 32+I + (a, b) = (sub_rev(touch(b), 32 * a), a + 32 * b); ;; same as (32 * a - b, 32 * b + a), but more efficient + } + repeat (qh) { ;; a+b*I *= (32+I)^5 = pa + pb*I + (a, b) = (a * pa - b * pb, a * pb + b * pa); + } + int xs = sgn(x); + return (xs * q, a, xs * b); +} + +;; compute (q, z) such that atan(x)=q*atan(1/32)+z for -1 <= x < 1 +;; this function is reasonably accurate (error < 7 ulp with ulp = 2^-261), but it consumes >7k gas +;; this is sufficient for most purposes +;; (int, fixed261) atan_aux(fixed256 x) +(int, int) atan_aux_f256(int x) inline_ref { + var (q, a, b) = atan_aux_prereduce(x ~>> 232); ;; convert x to fixed24 + ;; now b/a = tan(q*atan(1/32)) exactly, where q is near atan(x)/atan(1/32); so b/a is near x + ;; compute y = u/v = (a*x-b)/(a+b*x) as fixed261 ; then |y|<0.0167 = 1.07/64 and atan(x)=atan(y)+q*atan(1/32) + var (u, ul) = mulrshiftr256mod(a, x); + u = (ul ~>> 250) + ((u - b) << 6); ;; |u| < 1/32, convert fixed255 -> fixed261 + int v = a + mulrshiftr256(b, x); ;; v is scalar product of (a,b) and (1,x), it is approximately in [1..sqrt(2)] as fixed255 + int y = muldivr(u, 1 << 255, v); ;; y = u/v as fixed261 + int z = atan_f261_inlined(y, 18); ;; z = atan(x)-q*atan(1/32) + return (q, z); +} + +;; compute (q, z) such that atan(x)=q*atan(1/32)+z for -1 <= x < 1 +;; this function is very accurate (error < 2 ulp), but it consumes >7k gas +;; in most cases, faster function atan_aux_f256() should be used +;; (int, fixed261) atan_auxx(fixed256 x) +(int, int) atan_auxx_f256(int x) inline_ref { + var (q, a, b) = atan_aux_prereduce(x ~>> 232); ;; convert x to fixed24 + ;; now b/a = tan(q*atan(1/32)) exactly, where q is near atan(x)/atan(1/32); so b/a is near x + ;; compute y = (a*x-b)/(a+b*x) as fixed261 ; then |y|<0.0167 = 1.07/64 and atan(x)=atan(y)+q*atan(1/32) + ;; use sort of double precision arithmetic for this + var (u, ul) = mulrshiftr256mod(a, x); + ul /= 2; + u -= b; ;; |u| < 1/32 as fixed255 + var (v, vl) = mulrshiftr256mod(b, x); + vl /= 2; + v += a; ;; v is scalar product of (a,b) and (1,x), it is approximately in [1..sqrt(2)] as fixed255 + ;; y = (u + ul*eps) / (v + vl*eps) = u/v + (ul - vl * u/v)/v * eps where eps=1/2^255 + var (y, r) = lshift255divmodr(u, v); ;; y = u/v as fixed255 + int yl = muldivr(ul + r, 1 << 255, v) - muldivr(vl, y, v); ;; y/2^255 + yl/2^510 represent u/v + y = (yl ~>> 249) + (y << 6); ;; convert y to fixed261 + int z = atan_f261_inlined(y, 18); ;; z = atan(x)-q*atan(1/32) + return (q, z); +} + +;; consumes ~ 8k gas +;; fixed255 atan(fixed255 x); +int atan_f255(int x) inline_ref { + int s = (x ~>> 256); + touch(x); + if (s) { + x = lshift256divr(-1 << 255, x); ;; x:=-1/x as fixed256 + } else { + x *= 2; ;; convert to fixed256 + } + var (q, z) = atan_aux_f256(x); + ;; now atan(x) = z + q*atan(1/32) + s*(Pi/2), z is fixed261 + var (Pi_h, Pi_l) = Pi_xconst_f254(); ;; Pi/2 as fixed255 + fixed383 + var (qh, ql) = mulrshiftr6mod (q, Atan1_32_f261()); + return qh + s * Pi_h + (z + ql + muldivr(s, Pi_l, 1 << 122)) ~/ 64; +} + +;; computes atan(x) for -1 <= x < 1 only +;; fixed256 atan_small(fixed256 x); +int atan_f256_small(int x) inline_ref { + var (q, z) = atan_aux_f256(x); + ;; now atan(x) = z + q*atan(1/32), z is fixed261 + var (qh, ql) = mulrshiftr5mod (q, Atan1_32_f261()); + return qh + (z + ql) ~/ 32; +} + +;; fixed255 asin(fixed255 x); +int asin_f255(int x) inline_ref { + int a = fixed255::One - fixed255::sqr(x); ;; a:=1-x^2 + ifnot (a) { + return sgn(x) * Pi_const_f254(); ;; Pi/2 or -Pi/2 + } + int y = fixed255::sqrt(a); ;; sqrt(1-x^2) + int t = - lshift256divr(x, (-1 << 255) - y); ;; t = x/(1+sqrt(1-x^2)) avoiding overflow + return atan_f256_small(t); ;; asin(x)=2*atan(t) +} + +;; fixed254 acos(fixed255 x); +int acos_f255(int x) inline_ref { + int Pi = Pi_const_f254(); + if (x == (-1 << 255)) { + return Pi; ;; acos(-1) = Pi + } + Pi /= 2; + int y = fixed255::sqrt(fixed255::One - fixed255::sqr(x)); ;; sqrt(1-x^2) + int t = lshift256divr(x, (-1 << 255) - y); ;; t = -x/(1+sqrt(1-x^2)) avoiding overflow + return Pi + atan_f256_small(t) ~/ 2; ;; acos(x)=Pi/2 + 2*atan(t) +} + +;; consumes ~ 10k gas +;; fixed248 asin(fixed248 x) +int fixed248::asin(int x) inline { + return asin_f255(x << 7) ~>> 7; +} + +;; consumes ~ 10k gas +;; fixed248 acos(fixed248 x) +int fixed248::acos(int x) inline { + return acos_f255(x << 7) ~>> 6; +} + +;; consumes ~ 7500 gas +;; fixed248 atan(fixed248 x); +int fixed248::atan(int x) inline_ref { + int s = (x ~>> 249); + touch(x); + if (s) { + s = sgn(s); + x = lshift256divr(-1 << 248, x); ;; x:=-1/x as fixed256 + } else { + x <<= 8; ;; convert to fixed256 + } + var (q, z) = atan_aux_f256(x); + ;; now atan(x) = z + q*atan(1/32) + s*(Pi/2), z is fixed261 + return (z ~/ 64 + s * Pi_const_f254() + muldivr(q, Atan1_32_f261(), 64)) ~/ 128; ;; compute in fixed255, then convert +} + +;; fixed248 acot(fixed248 x); +int fixed248::acot(int x) inline_ref { + int s = (x ~>> 249); + touch(x); + if (s) { + x = lshift256divr(-1 << 248, x); ;; x:=-1/x as fixed256 + s = 0; + } else { + x <<= 8; ;; convert to fixed256 + s = sgn(x); + } + var (q, z) = atan_aux_f256(x); + ;; now acot(x) = - z - q*atan(1/32) + s*(Pi/2), z is fixed261 + return (s * Pi_const_f254() - z ~/ 64 - muldivr(q, Atan1_32_f261(), 64)) ~/ 128; ;; compute in fixed255, then convert +} + +{--------------------- PSEUDO-RANDOM NUMBERS -------------------} + +;; random number with standard normal distribution N(0,1) +;; generated by Kinderman--Monahan ratio method modified by J.Leva +;; spends ~ 2k..3k gas on average +;; fixed252 nrand(); +int nrand_f252() impure inline_ref { + var (x, s, t, A, B, r0) = (nan(), touch(29483) << 236, touch(-3167) << 239, 12845, 16693, 9043); + ;; 4/sqrt(e*Pi) = 1.369 loop iterations on average + do { + var (u, v) = (random() / 16 + 1, muldivr(random() - (1 << 255), 7027, 1 << 16)); ;; fixed252; 7027=ceil(sqrt(8/e)*2^12) + int va = abs(v); + var (u1, v1) = (u - s, va - t); ;; (u - 29483/2^16, abs(v) + 3167/2^13) as fixed252 + ;; Q := u1^2 + v1 * (A*v1 - B*u1) as fixed252 where A=12845/2^16, B=16693/2^16 + int Q = muldivr(u1, u1, 1 << 252) + muldivr(v1, muldivr(v1, A, 1 << 16) - muldivr(u1, B, 1 << 16), 1 << 252); + ;; must have 9043 / 2^15 < Q < 9125 / 2^15, otherwise accept if smaller, reject if larger + int Qd = (Q >> 237) - r0; + if ((Qd < 9125 - 9043) & (va / u < 16)) { + x = muldivr(v, 1 << 252, u); ;; x:=v/u as fixed252; reject immediately if |v/u| >= 16 + if (Qd >= 0) { ;; immediately accept if Qd < 0 + ;; rarely taken branch - 0.012 times per call on average + ;; check condition v^2 < -4*u^2*log(u), or equivalent condition u < exp(-x^2/4) for x=v/u + int xx = mulrshiftr256(x, x) ~/ 4; ;; x^2/4 as fixed248 + int ex = fixed248::exp(- xx) * 16; ;; exp(-x^2/4) as fixed252 + if (u > ex) { + x = nan(); ;; condition false, reject + } + } + } + } until (~ is_nan(x)); + return x; +} + +;; generates a random number approximately distributed according to the standard normal distribution +;; much faster than nrand_f252(), should be suitable for most purposes when only several random numbers are needed +;; fixed252 nrand_fast(); +int nrand_fast_f252() impure inline_ref { + int t = touch(-3) << 253; ;; -6. as fixed252 + repeat (12) { + t += random() / 16; ;; add together 12 uniformly random numbers + } + return t; +} + +;; random number uniformly distributed in [0..1) +;; fixed248 random(); +int fixed248::random() impure inline { + return random() >> 8; +} + +;; random number with standard normal distribution +;; fixed248 nrand(); +int fixed248::nrand() impure inline { + return nrand_f252() ~>> 4; +} + +;; generates a random number approximately distributed according to the standard normal distribution +;; fixed248 nrand_fast(); +int fixed248::nrand_fast() impure inline { + return nrand_fast_f252() ~>> 4; +} diff --git a/src/func/grammar-test/payment-channel-code.fc b/src/func/grammar-test/payment-channel-code.fc new file mode 100644 index 000000000..b4b14d5cd --- /dev/null +++ b/src/func/grammar-test/payment-channel-code.fc @@ -0,0 +1,357 @@ +;; WARINIG: NOT READY FOR A PRODUCTION! + +int err:wrong_a_signature() asm "31 PUSHINT"; +int err:wrong_b_signature() asm "32 PUSHINT"; +int err:msg_value_too_small() asm "33 PUSHINT"; +int err:replay_protection() asm "34 PUSHINT"; +int err:no_timeout() asm "35 PUSHINT"; +int err:expected_init() asm "36 PUSHINT"; +int err:expected_close() asm "37 PUSHINT"; +int err:expected_payout() asm "37 PUSHINT"; +int err:no_promise_signature() asm "38 PUSHINT"; +int err:wrong_channel_id() asm "39 PUSHINT"; +int err:unknown_op() asm "40 PUSHINT"; +int err:not_enough_fee() asm "41 PUSHINT"; + +int op:pchan_cmd() asm "0x912838d1 PUSHINT"; + +int msg:init() asm "0x27317822 PUSHINT"; +int msg:close() asm "0xf28ae183 PUSHINT"; +int msg:timeout() asm "0x43278a28 PUSHINT"; +int msg:payout() asm "0x37fe7810 PUSHINT"; + +int state:init() asm "0 PUSHINT"; +int state:close() asm "1 PUSHINT"; +int state:payout() asm "2 PUSHINT"; + +int min_fee() asm "1000000000 PUSHINT"; + + +;; A - initial balance of Alice, +;; B - initial balance of B +;; +;; To determine balance we track nondecreasing list of promises +;; promise_A ;; promised by Alice to Bob +;; promise_B ;; promised by Bob to Alice +;; +;; diff - balance between Alice and Bob. 0 in the beginning +;; diff = promise_B - promise_A; +;; diff = clamp(diff, -A, +B); +;; +;; final_A = A + diff; +;; final_B = B + diff; + +;; Data pack/unpack +;; +_ unpack_data() inline_ref { + var cs = get_data().begin_parse(); + var res = (cs~load_ref(), cs~load_ref()); + cs.end_parse(); + return res; +} + +_ pack_data(cell config, cell state) impure inline_ref { + set_data(begin_cell().store_ref(config).store_ref(state).end_cell()); +} + +;; Config pack/unpack +;; +;; config$_ initTimeout:int exitTimeout:int a_key:int256 b_key:int256 a_addr b_addr channel_id:uint64 = Config; +;; +_ unpack_config(cell config) { + var cs = config.begin_parse(); + var res = ( + cs~load_uint(32), + cs~load_uint(32), + cs~load_uint(256), + cs~load_uint(256), + cs~load_ref().begin_parse(), + cs~load_ref().begin_parse(), + cs~load_uint(64), + cs~load_grams()); + cs.end_parse(); + return res; +} + +;; takes +;; signedMesage$_ a_sig:Maybe b_sig:Maybe msg:Message = SignedMessage; +;; checks signatures and unwap message. +(slice, (int, int)) unwrap_signatures(slice cs, int a_key, int b_key) { + int a? = cs~load_int(1); + slice a_sig = cs; + if (a?) { + a_sig = cs~load_ref().begin_parse().preload_bits(512); + } + var b? = cs~load_int(1); + slice b_sig = cs; + if (b?) { + b_sig = cs~load_ref().begin_parse().preload_bits(512); + } + int hash = cs.slice_hash(); + if (a?) { + throw_unless(err:wrong_a_signature(), check_signature(hash, a_sig, a_key)); + } + if (b?) { + throw_unless(err:wrong_b_signature(), check_signature(hash, b_sig, b_key)); + } + return (cs, (a?, b?)); +} + +;; process message, give state is stateInit +;; +;; stateInit signed_A?:Bool signed_B?:Bool min_A:Grams min_B:Grams expire_at:uint32 A:Grams B:Grams = State; +_ unpack_state_init(slice state) { + return ( + state~load_int(1), + state~load_int(1), + state~load_grams(), + state~load_grams(), + state~load_uint(32), + state~load_grams(), + state~load_grams()); + +} +_ pack_state_init(int signed_A?, int signed_B?, int min_A, int min_B, int expire_at, int A, int B) { + return begin_cell() + .store_int(state:init(), 3) + .store_int(signed_A?, 1) + .store_int(signed_B?, 1) + .store_grams(min_A) + .store_grams(min_B) + .store_uint(expire_at, 32) + .store_grams(A) + .store_grams(B).end_cell(); +} + +;; stateClosing$10 signed_A?:bool signed_B?:Bool promise_A:Grams promise_B:Grams exipire_at:uint32 A:Grams B:Grams = State; +_ unpack_state_close(slice state) { + return ( + state~load_int(1), + state~load_int(1), + state~load_grams(), + state~load_grams(), + state~load_uint(32), + state~load_grams(), + state~load_grams()); +} + +_ pack_state_close(int signed_A?, int signed_B?, int promise_A, int promise_B, int expire_at, int A, int B) { + return begin_cell() + .store_int(state:close(), 3) + .store_int(signed_A?, 1) + .store_int(signed_B?, 1) + .store_grams(promise_A) + .store_grams(promise_B) + .store_uint(expire_at, 32) + .store_grams(A) + .store_grams(B).end_cell(); +} + +_ send_payout(slice s_addr, int amount, int channel_id, int flags) impure { + send_raw_message(begin_cell() + .store_uint(0x10, 6) + .store_slice(s_addr) + .store_grams(amount) + .store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1) + .store_uint(msg:payout(), 32) + .store_uint(channel_id, 64) + .end_cell(), flags); +} + + +cell do_payout(int promise_A, int promise_B, int A, int B, slice a_addr, slice b_addr, int channel_id) impure { + accept_message(); + + int diff = promise_B - promise_A; + if (diff < - A) { + diff = - A; + } + if (diff > B) { + diff = B; + } + A += diff; + B -= diff; + + send_payout(b_addr, B, channel_id, 3); + send_payout(a_addr, A, channel_id, 3 + 128); + + return begin_cell() + .store_int(state:payout(), 3) + .store_grams(A) + .store_grams(B) + .end_cell(); +} + + +;; +;; init$000 inc_A:Grams inc_B:Grams min_A:Grams min_B:Grams = Message; +;; +cell with_init(slice state, int msg_value, slice msg, int msg_signed_A?, int msg_signed_B?, + slice a_addr, slice b_addr, int init_timeout, int channel_id, int min_A_extra) { + ;; parse state + (int signed_A?, int signed_B?, int min_A, int min_B, int expire_at, int A, int B) = unpack_state_init(state); + + if (expire_at == 0) { + expire_at = now() + init_timeout; + } + + int op = msg~load_uint(32); + if (op == msg:timeout()) { + throw_unless(err:no_timeout(), expire_at < now()); + return do_payout(0, 0, A, B, a_addr, b_addr, channel_id); + } + throw_unless(err:expected_init(), op == msg:init()); + + ;; unpack init message + (int inc_A, int inc_B, int upd_min_A, int upd_min_B, int got_channel_id) = + (msg~load_grams(), msg~load_grams(), msg~load_grams(), msg~load_grams(), msg~load_uint(64)); + throw_unless(err:wrong_channel_id(), got_channel_id == channel_id); + + ;; TODO: we should reserve some part of the value for comission + throw_if(err:msg_value_too_small(), msg_value < inc_A + inc_B); + throw_unless(err:replay_protection(), (msg_signed_A? < signed_A?) | (msg_signed_B? < signed_B?)); + + A += inc_A; + B += inc_B; + + signed_A? |= msg_signed_A?; + if (min_A < upd_min_A) { + min_A = upd_min_A; + } + + signed_B? |= msg_signed_B?; + if (min_B < upd_min_B) { + min_B = upd_min_B; + } + + if (signed_A? & signed_B?) { + A -= min_A_extra; + if ((min_A > A) | (min_B > B)) { + return do_payout(0, 0, A, B, a_addr, b_addr, channel_id); + } + + return pack_state_close(0, 0, 0, 0, 0, A, B); + } + + return pack_state_init(signed_A?, signed_B?, min_A, min_B, expire_at, A, B); +} + +;; close$001 extra_A:Grams extra_B:Grams sig:Maybe promise_A:Grams promise_B:Grams = Message; + +cell with_close(slice cs, slice msg, int msg_signed_A?, int msg_signed_B?, int a_key, int b_key, + slice a_addr, slice b_addr, int expire_timeout, int channel_id) { + ;; parse state + (int signed_A?, int signed_B?, int promise_A, int promise_B, int expire_at, int A, int B) = unpack_state_close(cs); + + if (expire_at == 0) { + expire_at = now() + expire_timeout; + } + + int op = msg~load_uint(32); + if (op == msg:timeout()) { + throw_unless(err:no_timeout(), expire_at < now()); + return do_payout(promise_A, promise_B, A, B, a_addr, b_addr, channel_id); + } + throw_unless(err:expected_close(), op == msg:close()); + + ;; also ensures that (msg_signed_A? | msg_signed_B?) is true + throw_unless(err:replay_protection(), (msg_signed_A? < signed_A?) | (msg_signed_B? < signed_B?)); + signed_A? |= msg_signed_A?; + signed_B? |= msg_signed_B?; + + ;; unpack close message + (int extra_A, int extra_B) = (msg~load_grams(), msg~load_grams()); + int has_sig = msg~load_int(1); + if (has_sig) { + slice sig = msg~load_ref().begin_parse().preload_bits(512); + int hash = msg.slice_hash(); + ifnot (msg_signed_A?) { + throw_unless(err:wrong_a_signature(), check_signature(hash, sig, a_key)); + extra_A = 0; + } + ifnot (msg_signed_B?) { + throw_unless(err:wrong_b_signature(), check_signature(hash, sig, b_key)); + extra_B = 0; + } + } else { + throw_unless(err:no_promise_signature(), msg_signed_A? & msg_signed_B?); + extra_A = 0; + extra_B = 0; + } + (int got_channel_id, int update_promise_A, int update_promise_B) = (msg~load_uint(64), msg~load_grams(), msg~load_grams()); + throw_unless(err:wrong_channel_id(), got_channel_id == channel_id); + + + accept_message(); + update_promise_A += extra_A; + if (promise_A < update_promise_A) { + promise_A = update_promise_A; + } + update_promise_B += extra_B; + if (promise_B < update_promise_B) { + promise_B = update_promise_B; + } + + if (signed_A? & signed_B?) { + return do_payout(promise_A, promise_B, A, B, a_addr, b_addr, channel_id); + } + return pack_state_close(signed_A?, signed_B?, promise_A, promise_B, expire_at, A, B); +} + +() with_payout(slice cs, slice msg, slice a_addr, slice b_addr, int channel_id) impure { + int op = msg~load_uint(32); + throw_unless(err:expected_payout(), op == msg:payout()); + (int A, int B) = (cs~load_grams(), cs~load_grams()); + throw_unless(err:not_enough_fee(), A + B + 1000000000 < get_balance().pair_first()); + accept_message(); + send_payout(b_addr, B, channel_id, 3); + send_payout(a_addr, A, channel_id, 3 + 128); +} + +() recv_any(int msg_value, slice msg) impure { + if (msg.slice_empty?()) { + return(); + } + ;; op is not signed, but we don't need it to be signed. + int op = msg~load_uint(32); + if (op <= 1) { + ;; simple transfer with comment, return + ;; external message will be aborted + ;; internal message will be accepted + return (); + } + throw_unless(err:unknown_op(), op == op:pchan_cmd()); + + (cell config, cell state) = unpack_data(); + (int init_timeout, int close_timeout, int a_key, int b_key, + slice a_addr, slice b_addr, int channel_id, int min_A_extra) = config.unpack_config(); + (int msg_signed_A?, int msg_signed_B?) = msg~unwrap_signatures(a_key, b_key); + + slice cs = state.begin_parse(); + int state_type = cs~load_uint(3); + + if (state_type == state:init()) { ;; init + state = with_init(cs, msg_value, msg, msg_signed_A?, msg_signed_B?, a_addr, b_addr, init_timeout, channel_id, min_A_extra); + } if (state_type == state:close()) { + state = with_close(cs, msg, msg_signed_A?, msg_signed_B?, a_key, b_key, a_addr, b_addr, close_timeout, channel_id); + } if (state_type == state:payout()) { + with_payout(cs, msg, a_addr, b_addr, channel_id); + } + + pack_data(config, state); +} + +() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { + ;; TODO: uncomment when supported in tests + ;; var cs = in_msg_cell.begin_parse(); + ;; var flags = cs~load_uint(4); ;; int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + ;; if (flags & 1) { + ;; ;; ignore all bounced messages + ;; return (); + ;; } + recv_any(msg_value, in_msg); +} + +() recv_external(slice in_msg) impure { + recv_any(0, in_msg); +} diff --git a/src/func/grammar-test/pow-testgiver-code.fc b/src/func/grammar-test/pow-testgiver-code.fc new file mode 100644 index 000000000..6361a4613 --- /dev/null +++ b/src/func/grammar-test/pow-testgiver-code.fc @@ -0,0 +1,158 @@ +;; Advanced TestGiver smart contract with Proof-of-Work verification + +int ufits(int x, int bits) impure asm "UFITSX"; + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +() check_proof_of_work(slice cs) impure inline_ref { + var hash = slice_hash(cs); + var ds = get_data().begin_parse(); + var (stored_seqno_sw, public_key, seed, pow_complexity) = (ds~load_uint(64), ds~load_uint(256), ds~load_uint(128), ds~load_uint(256)); + throw_unless(24, hash < pow_complexity); ;; hash problem NOT solved + var (op, flags, expire, whom, rdata1, rseed, rdata2) = (cs~load_uint(32), cs~load_int(8), cs~load_uint(32), cs~load_uint(256), cs~load_uint(256), cs~load_uint(128), cs~load_uint(256)); + cs.end_parse(); + ufits(expire - now(), 10); + throw_unless(25, (rseed == seed) & (rdata1 == rdata2)); + ;; Proof of Work correct + accept_message(); + randomize_lt(); + randomize(rdata1); + var (last_success, xdata) = (ds~load_uint(32), ds~load_ref()); + ds.end_parse(); + ds = xdata.begin_parse(); + var (amount, target_delta, min_cpl, max_cpl) = (ds~load_grams(), ds~load_uint(32), ds~load_uint(8), ds~load_uint(8)); + ds.end_parse(); + ;; recompute complexity + int delta = now() - last_success; + if (delta > 0) { + int factor = muldivr(delta, 1 << 128, target_delta); + factor = min(max(factor, 7 << 125), 9 << 125); ;; factor must be in range 7/8 .. 9/8 + pow_complexity = muldivr(pow_complexity, factor, 1 << 128); ;; rescale complexity + pow_complexity = min(max(pow_complexity, 1 << min_cpl), 1 << max_cpl); + } + ;; update data + set_data(begin_cell() + .store_uint(stored_seqno_sw, 64) + .store_uint(public_key, 256) + .store_uint(random() >> 128, 128) ;; new seed + .store_uint(pow_complexity, 256) + .store_uint(now(), 32) ;; new last_success + .store_ref(xdata) + .end_cell()); + commit(); + ;; create outbound message + send_raw_message(begin_cell() + .store_uint(((flags & 1) << 6) | 0x84, 9) + .store_int(flags >> 2, 8) + .store_uint(whom, 256) + .store_grams(amount) + .store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1) + .end_cell(), 3); +} + +() rescale_complexity(slice cs) impure inline_ref { + var (op, expire) = (cs~load_uint(32), cs~load_uint(32)); + cs.end_parse(); + int time = now(); + throw_unless(28, time > expire); + var ds = get_data().begin_parse(); + var (skipped_data, pow_complexity, last_success, xdata) = (ds~load_bits(64 + 256 + 128), ds~load_uint(256), ds~load_uint(32), ds~load_ref()); + ds.end_parse(); + throw_unless(29, expire > last_success); + ds = xdata.begin_parse(); + var (amount, target_delta) = (ds~load_grams(), ds~load_uint(32)); + int delta = time - last_success; + throw_unless(30, delta >= target_delta * 16); + accept_message(); + var (min_cpl, max_cpl) = (ds~load_uint(8), ds~load_uint(8)); + ds.end_parse(); + int factor = muldivr(delta, 1 << 128, target_delta); + int max_complexity = (1 << max_cpl); + int max_factor = muldiv(max_complexity, 1 << 128, pow_complexity); + pow_complexity = (max_factor < factor ? max_complexity : muldivr(pow_complexity, factor, 1 << 128)); + last_success = time - target_delta; + set_data(begin_cell() + .store_slice(skipped_data) + .store_uint(pow_complexity, 256) + .store_uint(last_success, 32) ;; new last_success + .store_ref(xdata) + .end_cell()); +} + +(slice, ()) ~update_params(slice ds, cell pref) inline_ref { + var cs = pref.begin_parse(); + var reset_cpl = cs~load_uint(8); + var (seed, pow_complexity, last_success) = (ds~load_uint(128), ds~load_uint(256), ds~load_uint(32)); + if (reset_cpl) { + randomize(seed); + pow_complexity = (1 << reset_cpl); + seed = (random() >> 128); + } + var c = begin_cell() + .store_uint(seed, 128) + .store_uint(pow_complexity, 256) + .store_uint(now(), 32) + .store_ref(begin_cell().store_slice(cs).end_cell()) + .end_cell(); + return (begin_parse(c), ()); +} + +() recv_external(slice in_msg) impure { + var op = in_msg.preload_uint(32); + if (op == 0x4d696e65) { + ;; Mine = Obtain test grams by presenting valid proof of work + return check_proof_of_work(in_msg); + } + if (op == 0x5253636c) { + ;; RScl = Rescale complexity if no success for long time + return rescale_complexity(in_msg); + } + var signature = in_msg~load_bits(512); + var cs = in_msg; + var (subwallet_id, valid_until, msg_seqno) = (cs~load_uint(32), cs~load_uint(32), cs~load_uint(32)); + throw_if(35, valid_until <= now()); + var ds = get_data().begin_parse(); + var (stored_seqno, stored_subwallet, public_key) = (ds~load_uint(32), ds~load_uint(32), ds~load_uint(256)); + throw_unless(33, msg_seqno == stored_seqno); + throw_unless(34, (subwallet_id == stored_subwallet) | (subwallet_id == 0)); + throw_unless(35, check_signature(slice_hash(in_msg), signature, public_key)); + accept_message(); + cs~touch(); + while (cs.slice_refs()) { + var ref = cs~load_ref(); + var mode = cs~load_uint(8); + if (mode < 0xff) { + send_raw_message(ref, mode); + } else { + ds~update_params(ref); + } + } + set_data(begin_cell() + .store_uint(stored_seqno + 1, 32) + .store_uint(stored_subwallet, 32) + .store_uint(public_key, 256) + .store_slice(ds) + .end_cell()); +} + +;; Get methods + +int seqno() method_id { + return get_data().begin_parse().preload_uint(32); +} + +;; gets (seed, pow_complexity, amount, interval) +(int, int, int, int) get_pow_params() method_id { + var ds = get_data().begin_parse().skip_bits(32 + 32 + 256); + var (seed, pow_complexity, xdata) = (ds~load_uint(128), ds~load_uint(256), ds.preload_ref()); + ds = xdata.begin_parse(); + return (seed, pow_complexity, ds~load_grams(), ds.preload_uint(32)); +} + +int get_public_key() method_id { + var ds = get_data().begin_parse(); + ds~load_uint(32 + 32); + return ds.preload_uint(256); +} diff --git a/src/func/grammar-test/restricted-wallet-code.fc b/src/func/grammar-test/restricted-wallet-code.fc new file mode 100644 index 000000000..a31683406 --- /dev/null +++ b/src/func/grammar-test/restricted-wallet-code.fc @@ -0,0 +1,73 @@ +;; Restricted wallet (a variant of wallet-code.fc) +;; until configuration parameter -13 is set, accepts messages only to elector smc + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +_ restricted?() inline { + var p = config_param(-13); + return null?(p) ? true : begin_parse(p).preload_uint(32) > now(); +} + +_ check_destination(msg, dest) inline_ref { + var cs = msg.begin_parse(); + var flags = cs~load_uint(4); + if (flags & 8) { + ;; external messages are always valid + return true; + } + var (s_addr, d_addr) = (cs~load_msg_addr(), cs~load_msg_addr()); + var (dest_wc, dest_addr) = parse_std_addr(d_addr); + return (dest_wc == -1) & (dest_addr == dest); +} + +() recv_external(slice in_msg) impure { + var signature = in_msg~load_bits(512); + var cs = in_msg; + var (msg_seqno, valid_until) = (cs~load_uint(32), cs~load_uint(32)); + throw_if(35, valid_until <= now()); + var ds = get_data().begin_parse(); + var (stored_seqno, public_key) = (ds~load_uint(32), ds~load_uint(256)); + ds.end_parse(); + throw_unless(33, msg_seqno == stored_seqno); + ifnot (msg_seqno) { + accept_message(); + set_data(begin_cell().store_uint(stored_seqno + 1, 32).store_uint(public_key, 256).end_cell()); + return (); + } + throw_unless(34, check_signature(slice_hash(in_msg), signature, public_key)); + accept_message(); + var restrict = restricted?(); + var elector = config_param(1).begin_parse().preload_uint(256); + cs~touch(); + while (cs.slice_refs()) { + var mode = cs~load_uint(8); + var msg = cs~load_ref(); + var ok = true; + if (restrict) { + ok = check_destination(msg, elector); + } + if (ok) { + send_raw_message(msg, mode); + } + } + cs.end_parse(); + set_data(begin_cell().store_uint(stored_seqno + 1, 32).store_uint(public_key, 256).end_cell()); +} + +;; Get methods + +int seqno() method_id { + return get_data().begin_parse().preload_uint(32); +} + +int get_public_key() method_id { + var cs = get_data().begin_parse(); + cs~load_uint(32); + return cs.preload_uint(256); +} + +int balance() method_id { + return restricted?() ? 0 : get_balance().pair_first(); +} diff --git a/src/func/grammar-test/restricted-wallet2-code.fc b/src/func/grammar-test/restricted-wallet2-code.fc new file mode 100644 index 000000000..fbad6c092 --- /dev/null +++ b/src/func/grammar-test/restricted-wallet2-code.fc @@ -0,0 +1,88 @@ +;; Restricted wallet (a variant of wallet-code.fc) +;; restricts access to parts of balance until certain dates + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +_ seconds_passed(int start_at, int utime) inline_ref { + ifnot (start_at) { + var p = config_param(-13); + start_at = null?(p) ? 0 : begin_parse(p).preload_uint(32); + } + return start_at ? utime - start_at : -1; +} + +() recv_external(slice in_msg) impure { + var signature = in_msg~load_bits(512); + var cs = in_msg; + var (msg_seqno, valid_until) = (cs~load_uint(32), cs~load_uint(32)); + throw_if(35, valid_until <= now()); + var ds = get_data().begin_parse(); + var (stored_seqno, public_key, start_at, rdict) = (ds~load_uint(32), ds~load_uint(256), ds~load_uint(32), ds~load_dict()); + ds.end_parse(); + throw_unless(33, msg_seqno == stored_seqno); + ifnot (msg_seqno) { + accept_message(); + set_data(begin_cell() + .store_uint(stored_seqno + 1, 32) + .store_uint(public_key, 256) + .store_uint(start_at, 32) + .store_dict(rdict) + .end_cell()); + return (); + } + throw_unless(34, check_signature(slice_hash(in_msg), signature, public_key)); + accept_message(); + var ts = seconds_passed(start_at, now()); + var (_, value, found) = rdict.idict_get_preveq?(32, ts); + if (found) { + raw_reserve(value~load_grams(), 2); + } + cs~touch(); + while (cs.slice_refs()) { + var mode = cs~load_uint(8); + var msg = cs~load_ref(); + send_raw_message(msg, mode); + } + cs.end_parse(); + set_data(begin_cell() + .store_uint(stored_seqno + 1, 32) + .store_uint(public_key, 256) + .store_uint(start_at, 32) + .store_dict(rdict) + .end_cell()); +} + +;; Get methods + +int seqno() method_id { + return get_data().begin_parse().preload_uint(32); +} + +int get_public_key() method_id { + var cs = get_data().begin_parse(); + cs~load_uint(32); + return cs.preload_uint(256); +} + +int compute_balance_at(int utime) inline_ref { + var ds = get_data().begin_parse().skip_bits(32 + 256); + var (start_at, rdict) = (ds~load_uint(32), ds~load_dict()); + ds.end_parse(); + var ts = seconds_passed(start_at, utime); + var balance = get_balance().pair_first(); + var (_, value, found) = rdict.idict_get_preveq?(32, ts); + if (found) { + balance = max(balance - value~load_grams(), 0); + } + return balance; +} + +int balance_at(int utime) method_id { + return compute_balance_at(utime); +} + +int balance() method_id { + return compute_balance_at(now()); +} diff --git a/src/func/grammar-test/restricted-wallet3-code.fc b/src/func/grammar-test/restricted-wallet3-code.fc new file mode 100644 index 000000000..aab860654 --- /dev/null +++ b/src/func/grammar-test/restricted-wallet3-code.fc @@ -0,0 +1,103 @@ +;; Restricted wallet initialized by a third party (a variant of restricted-wallet2-code.fc) +;; restricts access to parts of balance until certain dates + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +_ seconds_passed(int start_at, int utime) inline_ref { + ifnot (start_at) { + var p = config_param(-13); + start_at = null?(p) ? 0 : begin_parse(p).preload_uint(32); + } + return start_at ? utime - start_at : -1; +} + +() recv_external(slice in_msg) impure { + var signature = in_msg~load_bits(512); + var cs = in_msg; + var (subwallet_id, valid_until, msg_seqno) = (cs~load_uint(32), cs~load_uint(32), cs~load_uint(32)); + throw_if(35, valid_until <= now()); + var ds = get_data().begin_parse(); + var (stored_seqno, stored_subwallet, public_key) = (ds~load_uint(32), ds~load_uint(32), ds~load_uint(256)); + throw_unless(33, msg_seqno == stored_seqno); + throw_unless(34, subwallet_id == stored_subwallet); + throw_unless(36, check_signature(slice_hash(in_msg), signature, public_key)); + ifnot (msg_seqno) { + public_key = ds~load_uint(256); ;; load "final" public key + ds.end_parse(); + cs~touch(); + var (start_at, rdict) = (cs~load_uint(32), cs~load_dict()); + cs.end_parse(); + accept_message(); + set_data(begin_cell() + .store_uint(stored_seqno + 1, 32) + .store_uint(stored_subwallet, 32) + .store_uint(public_key, 256) + .store_uint(start_at, 32) + .store_dict(rdict) + .end_cell()); + return (); + } + var (start_at, rdict) = (ds~load_uint(32), ds~load_dict()); + ds.end_parse(); + accept_message(); + var ts = seconds_passed(start_at, now()); + var (_, value, found) = rdict.idict_get_preveq?(32, ts); + if (found) { + raw_reserve(value~load_grams(), 2); + } + cs~touch(); + while (cs.slice_refs()) { + var mode = cs~load_uint(8); + var msg = cs~load_ref(); + send_raw_message(msg, mode); + } + cs.end_parse(); + set_data(begin_cell() + .store_uint(stored_seqno + 1, 32) + .store_uint(stored_subwallet, 32) + .store_uint(public_key, 256) + .store_uint(start_at, 32) + .store_dict(rdict) + .end_cell()); +} + +;; Get methods + +int seqno() method_id { + return get_data().begin_parse().preload_uint(32); +} + +int wallet_id() method_id { + var ds = get_data().begin_parse(); + ds~load_uint(32); + return ds.preload_uint(32); +} + +int get_public_key() method_id { + var ds = get_data().begin_parse(); + ds~load_uint(32 + 32); + return ds.preload_uint(256); +} + +int compute_balance_at(int utime) inline_ref { + var ds = get_data().begin_parse().skip_bits(32 + 32 + 256); + var (start_at, rdict) = (ds~load_uint(32), ds~load_dict()); + ds.end_parse(); + var ts = seconds_passed(start_at, utime); + var balance = get_balance().pair_first(); + var (_, value, found) = rdict.idict_get_preveq?(32, ts); + if (found) { + balance = max(balance - value~load_grams(), 0); + } + return balance; +} + +int balance_at(int utime) method_id { + return compute_balance_at(utime); +} + +int balance() method_id { + return compute_balance_at(now()); +} diff --git a/src/func/grammar-test/simple-wallet-code.fc b/src/func/grammar-test/simple-wallet-code.fc new file mode 100644 index 000000000..a43b8b929 --- /dev/null +++ b/src/func/grammar-test/simple-wallet-code.fc @@ -0,0 +1,25 @@ +;; Simple wallet smart contract + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +() recv_external(slice in_msg) impure { + var signature = in_msg~load_bits(512); + var cs = in_msg; + int msg_seqno = cs~load_uint(32); + var cs2 = begin_parse(get_data()); + var stored_seqno = cs2~load_uint(32); + var public_key = cs2~load_uint(256); + cs2.end_parse(); + throw_unless(33, msg_seqno == stored_seqno); + throw_unless(34, check_signature(slice_hash(in_msg), signature, public_key)); + accept_message(); + cs~touch(); + if (cs.slice_refs()) { + var mode = cs~load_uint(8); + send_raw_message(cs~load_ref(), mode); + } + cs.end_parse(); + set_data(begin_cell().store_uint(stored_seqno + 1, 32).store_uint(public_key, 256).end_cell()); +} diff --git a/src/func/grammar-test/simple-wallet-ext-code.fc b/src/func/grammar-test/simple-wallet-ext-code.fc new file mode 100644 index 000000000..fb43e8332 --- /dev/null +++ b/src/func/grammar-test/simple-wallet-ext-code.fc @@ -0,0 +1,68 @@ +;; Simple wallet smart contract + +cell create_state(int seqno, int public_key) { + return begin_cell().store_uint(seqno, 32).store_uint(public_key, 256).end_cell(); +} + +(int, int) load_state() { + var cs2 = begin_parse(get_data()); + return (cs2~load_uint(32), cs2~load_uint(256)); +} + +() save_state(int seqno, int public_key) impure { + set_data(create_state(seqno, public_key)); +} + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +slice do_verify_message(slice in_msg, int seqno, int public_key) { + var signature = in_msg~load_bits(512); + var cs = in_msg; + int msg_seqno = cs~load_uint(32); + throw_unless(33, msg_seqno == seqno); + throw_unless(34, check_signature(slice_hash(in_msg), signature, public_key)); + return cs; +} + +() recv_external(slice in_msg) impure { + (int stored_seqno, int public_key) = load_state(); + var cs = do_verify_message(in_msg, stored_seqno, public_key); + accept_message(); + cs~touch(); + if (cs.slice_refs()) { + var mode = cs~load_uint(8); + send_raw_message(cs~load_ref(), mode); + } + cs.end_parse(); + save_state(stored_seqno + 1, public_key); +} + +;; Get methods + +int seqno() method_id { + return get_data().begin_parse().preload_uint(32); +} + +int get_public_key() method_id { + var (seqno, public_key) = load_state(); + return public_key; +} + +cell create_init_state(int public_key) method_id { + return create_state(0, public_key); +} + +cell prepare_send_message_with_seqno(int mode, cell msg, int seqno) method_id { + return begin_cell().store_uint(seqno, 32).store_uint(mode, 8).store_ref(msg).end_cell(); +} + +cell prepare_send_message(int mode, cell msg) method_id { + return prepare_send_message_with_seqno(mode, msg, seqno()); +} + +slice verify_message(slice msg) method_id { + var (stored_seqno, public_key) = load_state(); + return do_verify_message(msg, stored_seqno, public_key); +} diff --git a/src/func/grammar-test/stdlib.fc b/src/func/grammar-test/stdlib.fc new file mode 100644 index 000000000..978b94738 --- /dev/null +++ b/src/func/grammar-test/stdlib.fc @@ -0,0 +1,639 @@ +;; Standard library for funC +;; + +{- + This file is part of TON FunC Standard Library. + + FunC Standard Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + FunC Standard Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + +-} + +{- + # Tuple manipulation primitives + The names and the types are mostly self-explaining. + See [polymorhism with forall](https://ton.org/docs/#/func/functions?id=polymorphism-with-forall) + for more info on the polymorphic functions. + + Note that currently values of atomic type `tuple` can't be cast to composite tuple type (e.g. `[int, cell]`) + and vise versa. +-} + +{- + # Lisp-style lists + + Lists can be represented as nested 2-elements tuples. + Empty list is conventionally represented as TVM `null` value (it can be obtained by calling [null()]). + For example, tuple `(1, (2, (3, null)))` represents list `[1, 2, 3]`. Elements of a list can be of different types. +-} + +;;; Adds an element to the beginning of lisp-style list. +forall X -> tuple cons(X head, tuple tail) asm "CONS"; + +;;; Extracts the head and the tail of lisp-style list. +forall X -> (X, tuple) uncons(tuple list) asm "UNCONS"; + +;;; Extracts the tail and the head of lisp-style list. +forall X -> (tuple, X) list_next(tuple list) asm( -> 1 0) "UNCONS"; + +;;; Returns the head of lisp-style list. +forall X -> X car(tuple list) asm "CAR"; + +;;; Returns the tail of lisp-style list. +tuple cdr(tuple list) asm "CDR"; + +;;; Creates tuple with zero elements. +tuple empty_tuple() asm "NIL"; + +;;; Appends a value `x` to a `Tuple t = (x1, ..., xn)`, but only if the resulting `Tuple t' = (x1, ..., xn, x)` +;;; is of length at most 255. Otherwise throws a type check exception. +forall X -> tuple tpush(tuple t, X value) asm "TPUSH"; +forall X -> (tuple, ()) ~tpush(tuple t, X value) asm "TPUSH"; + +;;; Creates a tuple of length one with given argument as element. +forall X -> [X] single(X x) asm "SINGLE"; + +;;; Unpacks a tuple of length one +forall X -> X unsingle([X] t) asm "UNSINGLE"; + +;;; Creates a tuple of length two with given arguments as elements. +forall X, Y -> [X, Y] pair(X x, Y y) asm "PAIR"; + +;;; Unpacks a tuple of length two +forall X, Y -> (X, Y) unpair([X, Y] t) asm "UNPAIR"; + +;;; Creates a tuple of length three with given arguments as elements. +forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) asm "TRIPLE"; + +;;; Unpacks a tuple of length three +forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) asm "UNTRIPLE"; + +;;; Creates a tuple of length four with given arguments as elements. +forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) asm "4 TUPLE"; + +;;; Unpacks a tuple of length four +forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) asm "4 UNTUPLE"; + +;;; Returns the first element of a tuple (with unknown element types). +forall X -> X first(tuple t) asm "FIRST"; + +;;; Returns the second element of a tuple (with unknown element types). +forall X -> X second(tuple t) asm "SECOND"; + +;;; Returns the third element of a tuple (with unknown element types). +forall X -> X third(tuple t) asm "THIRD"; + +;;; Returns the fourth element of a tuple (with unknown element types). +forall X -> X fourth(tuple t) asm "3 INDEX"; + +;;; Returns the first element of a pair tuple. +forall X, Y -> X pair_first([X, Y] p) asm "FIRST"; + +;;; Returns the second element of a pair tuple. +forall X, Y -> Y pair_second([X, Y] p) asm "SECOND"; + +;;; Returns the first element of a triple tuple. +forall X, Y, Z -> X triple_first([X, Y, Z] p) asm "FIRST"; + +;;; Returns the second element of a triple tuple. +forall X, Y, Z -> Y triple_second([X, Y, Z] p) asm "SECOND"; + +;;; Returns the third element of a triple tuple. +forall X, Y, Z -> Z triple_third([X, Y, Z] p) asm "THIRD"; + + +;;; Push null element (casted to given type) +;;; By the TVM type `Null` FunC represents absence of a value of some atomic type. +;;; So `null` can actually have any atomic type. +forall X -> X null() asm "PUSHNULL"; + +;;; Moves a variable [x] to the top of the stack +forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP"; + + + +;;; Returns the current Unix time as an Integer +int now() asm "NOW"; + +;;; Returns the internal address of the current smart contract as a Slice with a `MsgAddressInt`. +;;; If necessary, it can be parsed further using primitives such as [parse_std_addr]. +slice my_address() asm "MYADDR"; + +;;; Returns the balance of the smart contract as a tuple consisting of an int +;;; (balance in nanotoncoins) and a `cell` +;;; (a dictionary with 32-bit keys representing the balance of "extra currencies") +;;; at the start of Computation Phase. +;;; Note that RAW primitives such as [send_raw_message] do not update this field. +[int, cell] get_balance() asm "BALANCE"; + +;;; Returns the logical time of the current transaction. +int cur_lt() asm "LTIME"; + +;;; Returns the starting logical time of the current block. +int block_lt() asm "BLOCKLT"; + +;;; Computes the representation hash of a `cell` [c] and returns it as a 256-bit unsigned integer `x`. +;;; Useful for signing and checking signatures of arbitrary entities represented by a tree of cells. +int cell_hash(cell c) asm "HASHCU"; + +;;; Computes the hash of a `slice s` and returns it as a 256-bit unsigned integer `x`. +;;; The result is the same as if an ordinary cell containing only data and references from `s` had been created +;;; and its hash computed by [cell_hash]. +int slice_hash(slice s) asm "HASHSU"; + +;;; Computes sha256 of the data bits of `slice` [s]. If the bit length of `s` is not divisible by eight, +;;; throws a cell underflow exception. The hash value is returned as a 256-bit unsigned integer `x`. +int string_hash(slice s) asm "SHA256U"; + +{- + # Signature checks +-} + +;;; Checks the Ed25519-`signature` of a `hash` (a 256-bit unsigned integer, usually computed as the hash of some data) +;;; using [public_key] (also represented by a 256-bit unsigned integer). +;;; The signature must contain at least 512 data bits; only the first 512 bits are used. +;;; The result is `−1` if the signature is valid, `0` otherwise. +;;; Note that `CHKSIGNU` creates a 256-bit slice with the hash and calls `CHKSIGNS`. +;;; That is, if [hash] is computed as the hash of some data, these data are hashed twice, +;;; the second hashing occurring inside `CHKSIGNS`. +int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU"; + +;;; Checks whether [signature] is a valid Ed25519-signature of the data portion of `slice data` using `public_key`, +;;; similarly to [check_signature]. +;;; If the bit length of [data] is not divisible by eight, throws a cell underflow exception. +;;; The verification of Ed25519 signatures is the standard one, +;;; with sha256 used to reduce [data] to the 256-bit number that is actually signed. +int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS"; + +{--- + # Computation of boc size + The primitives below may be useful for computing storage fees of user-provided data. +-} + +;;; Returns `(x, y, z, -1)` or `(null, null, null, 0)`. +;;; Recursively computes the count of distinct cells `x`, data bits `y`, and cell references `z` +;;; in the DAG rooted at `cell` [c], effectively returning the total storage used by this DAG taking into account +;;; the identification of equal cells. +;;; The values of `x`, `y`, and `z` are computed by a depth-first traversal of this DAG, +;;; with a hash table of visited cell hashes used to prevent visits of already-visited cells. +;;; The total count of visited cells `x` cannot exceed non-negative [max_cells]; +;;; otherwise the computation is aborted before visiting the `(max_cells + 1)`-st cell and +;;; a zero flag is returned to indicate failure. If [c] is `null`, returns `x = y = z = 0`. +(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE"; + +;;; Similar to [compute_data_size?], but accepting a `slice` [s] instead of a `cell`. +;;; The returned value of `x` does not take into account the cell that contains the `slice` [s] itself; +;;; however, the data bits and the cell references of [s] are accounted for in `y` and `z`. +(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE"; + +;;; A non-quiet version of [compute_data_size?] that throws a cell overflow exception (`8`) on failure. +(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; + +;;; A non-quiet version of [slice_compute_data_size?] that throws a cell overflow exception (8) on failure. +(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; + +;;; Throws an exception with exit_code excno if cond is not 0 (commented since implemented in compilator) +;; () throw_if(int excno, int cond) impure asm "THROWARGIF"; + +{-- + # Debug primitives + Only works for local TVM execution with debug level verbosity +-} +;;; Dumps the stack (at most the top 255 values) and shows the total stack depth. +() dump_stack() impure asm "DUMPSTK"; + +{- + # Persistent storage save and load +-} + +;;; Returns the persistent contract storage cell. It can be parsed or modified with slice and builder primitives later. +cell get_data() asm "c4 PUSH"; + +;;; Sets `cell` [c] as persistent contract data. You can update persistent contract storage with this primitive. +() set_data(cell c) impure asm "c4 POP"; + +{- + # Continuation primitives +-} +;;; Usually `c3` has a continuation initialized by the whole code of the contract. It is used for function calls. +;;; The primitive returns the current value of `c3`. +cont get_c3() impure asm "c3 PUSH"; + +;;; Updates the current value of `c3`. Usually, it is used for updating smart contract code in run-time. +;;; Note that after execution of this primitive the current code +;;; (and the stack of recursive function calls) won't change, +;;; but any other function call will use a function from the new code. +() set_c3(cont c) impure asm "c3 POP"; + +;;; Transforms a `slice` [s] into a simple ordinary continuation `c`, with `c.code = s` and an empty stack and savelist. +cont bless(slice s) impure asm "BLESS"; + +{--- + # Gas related primitives +-} + +;;; Sets current gas limit `gl` to its maximal allowed value `gm`, and resets the gas credit `gc` to zero, +;;; decreasing the value of `gr` by `gc` in the process. +;;; In other words, the current smart contract agrees to buy some gas to finish the current transaction. +;;; This action is required to process external messages, which bring no value (hence no gas) with themselves. +;;; +;;; For more details check [accept_message effects](https://ton.org/docs/#/smart-contracts/accept). +() accept_message() impure asm "ACCEPT"; + +;;; Sets current gas limit `gl` to the minimum of limit and `gm`, and resets the gas credit `gc` to zero. +;;; If the gas consumed so far (including the present instruction) exceeds the resulting value of `gl`, +;;; an (unhandled) out of gas exception is thrown before setting new gas limits. +;;; Notice that [set_gas_limit] with an argument `limit ≥ 2^63 − 1` is equivalent to [accept_message]. +() set_gas_limit(int limit) impure asm "SETGASLIMIT"; + +;;; Commits the current state of registers `c4` (“persistent data”) and `c5` (“actions”) +;;; so that the current execution is considered “successful” with the saved values even if an exception +;;; in Computation Phase is thrown later. +() commit() impure asm "COMMIT"; + +;;; Not implemented +;;() buy_gas(int gram) impure asm "BUYGAS"; + +;;; Computes the amount of gas that can be bought for `amount` nanoTONs, +;;; and sets `gl` accordingly in the same way as [set_gas_limit]. +() buy_gas(int amount) impure asm "BUYGAS"; + +;;; Computes the minimum of two integers [x] and [y]. +int min(int x, int y) asm "MIN"; + +;;; Computes the maximum of two integers [x] and [y]. +int max(int x, int y) asm "MAX"; + +;;; Sorts two integers. +(int, int) minmax(int x, int y) asm "MINMAX"; + +;;; Computes the absolute value of an integer [x]. +int abs(int x) asm "ABS"; + +{- + # Slice primitives + + It is said that a primitive _loads_ some data, + if it returns the data and the remainder of the slice + (so it can also be used as [modifying method](https://ton.org/docs/#/func/statements?id=modifying-methods)). + + It is said that a primitive _preloads_ some data, if it returns only the data + (it can be used as [non-modifying method](https://ton.org/docs/#/func/statements?id=non-modifying-methods)). + + Unless otherwise stated, loading and preloading primitives read the data from a prefix of the slice. +-} + + +;;; Converts a `cell` [c] into a `slice`. Notice that [c] must be either an ordinary cell, +;;; or an exotic cell (see [TVM.pdf](https://ton-blockchain.github.io/docs/tvm.pdf), 3.1.2) +;;; which is automatically loaded to yield an ordinary cell `c'`, converted into a `slice` afterwards. +slice begin_parse(cell c) asm "CTOS"; + +;;; Checks if [s] is empty. If not, throws an exception. +() end_parse(slice s) impure asm "ENDS"; + +;;; Loads the first reference from the slice. +(slice, cell) load_ref(slice s) asm( -> 1 0) "LDREF"; + +;;; Preloads the first reference from the slice. +cell preload_ref(slice s) asm "PLDREF"; + + {- Functions below are commented because are implemented on compilator level for optimisation -} + +;;; Loads a signed [len]-bit integer from a slice [s]. +;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX"; + +;;; Loads an unsigned [len]-bit integer from a slice [s]. +;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX"; + +;;; Preloads a signed [len]-bit integer from a slice [s]. +;; int preload_int(slice s, int len) asm "PLDIX"; + +;;; Preloads an unsigned [len]-bit integer from a slice [s]. +;; int preload_uint(slice s, int len) asm "PLDUX"; + +;;; Loads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate `slice s''`. +;; (slice, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX"; + +;;; Preloads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate `slice s''`. +;; slice preload_bits(slice s, int len) asm "PLDSLICEX"; + +;;; Loads serialized amount of TonCoins (any unsigned integer up to `2^120 - 1`). +(slice, int) load_grams(slice s) asm( -> 1 0) "LDGRAMS"; +(slice, int) load_coins(slice s) asm( -> 1 0) "LDGRAMS"; + +;;; Returns all but the first `0 ≤ len ≤ 1023` bits of `slice` [s]. +slice skip_bits(slice s, int len) asm "SDSKIPFIRST"; +(slice, ()) ~skip_bits(slice s, int len) asm "SDSKIPFIRST"; + +;;; Returns the first `0 ≤ len ≤ 1023` bits of `slice` [s]. +slice first_bits(slice s, int len) asm "SDCUTFIRST"; + +;;; Returns all but the last `0 ≤ len ≤ 1023` bits of `slice` [s]. +slice skip_last_bits(slice s, int len) asm "SDSKIPLAST"; +(slice, ()) ~skip_last_bits(slice s, int len) asm "SDSKIPLAST"; + +;;; Returns the last `0 ≤ len ≤ 1023` bits of `slice` [s]. +slice slice_last(slice s, int len) asm "SDCUTLAST"; + +;;; Loads a dictionary `D` (HashMapE) from `slice` [s]. +;;; (returns `null` if `nothing` constructor is used). +(slice, cell) load_dict(slice s) asm( -> 1 0) "LDDICT"; + +;;; Preloads a dictionary `D` from `slice` [s]. +cell preload_dict(slice s) asm "PLDDICT"; + +;;; Loads a dictionary as [load_dict], but returns only the remainder of the slice. +slice skip_dict(slice s) asm "SKIPDICT"; + +;;; Loads (Maybe ^Cell) from `slice` [s]. +;;; In other words loads 1 bit and if it is true +;;; loads first ref and return it with slice remainder +;;; otherwise returns `null` and slice remainder +(slice, cell) load_maybe_ref(slice s) asm( -> 1 0) "LDOPTREF"; + +;;; Preloads (Maybe ^Cell) from `slice` [s]. +cell preload_maybe_ref(slice s) asm "PLDOPTREF"; + + +;;; Returns the depth of `cell` [c]. +;;; If [c] has no references, then return `0`; +;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [c]. +;;; If [c] is a `null` instead of a cell, returns zero. +int cell_depth(cell c) asm "CDEPTH"; + + +{- + # Slice size primitives +-} + +;;; Returns the number of references in `slice` [s]. +int slice_refs(slice s) asm "SREFS"; + +;;; Returns the number of data bits in `slice` [s]. +int slice_bits(slice s) asm "SBITS"; + +;;; Returns both the number of data bits and the number of references in `slice` [s]. +(int, int) slice_bits_refs(slice s) asm "SBITREFS"; + +;;; Checks whether a `slice` [s] is empty (i.e., contains no bits of data and no cell references). +int slice_empty?(slice s) asm "SEMPTY"; + +;;; Checks whether `slice` [s] has no bits of data. +int slice_data_empty?(slice s) asm "SDEMPTY"; + +;;; Checks whether `slice` [s] has no references. +int slice_refs_empty?(slice s) asm "SREMPTY"; + +;;; Returns the depth of `slice` [s]. +;;; If [s] has no references, then returns `0`; +;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [s]. +int slice_depth(slice s) asm "SDEPTH"; + +{- + # Builder size primitives +-} + +;;; Returns the number of cell references already stored in `builder` [b] +int builder_refs(builder b) asm "BREFS"; + +;;; Returns the number of data bits already stored in `builder` [b]. +int builder_bits(builder b) asm "BBITS"; + +;;; Returns the depth of `builder` [b]. +;;; If no cell references are stored in [b], then returns 0; +;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [b]. +int builder_depth(builder b) asm "BDEPTH"; + +{- + # Builder primitives + It is said that a primitive _stores_ a value `x` into a builder `b` + if it returns a modified version of the builder `b'` with the value `x` stored at the end of it. + It can be used as [non-modifying method](https://ton.org/docs/#/func/statements?id=non-modifying-methods). + + All the primitives below first check whether there is enough space in the `builder`, + and only then check the range of the value being serialized. +-} + +;;; Creates a new empty `builder`. +builder begin_cell() asm "NEWC"; + +;;; Converts a `builder` into an ordinary `cell`. +cell end_cell(builder b) asm "ENDC"; + +;;; Stores a reference to `cell` [c] into `builder` [b]. +builder store_ref(builder b, cell c) asm(c b) "STREF"; + +;;; Stores an unsigned [len]-bit integer `x` into `b` for `0 ≤ len ≤ 256`. +;; builder store_uint(builder b, int x, int len) asm(x b len) "STUX"; + +;;; Stores a signed [len]-bit integer `x` into `b` for` 0 ≤ len ≤ 257`. +;; builder store_int(builder b, int x, int len) asm(x b len) "STIX"; + + +;;; Stores `slice` [s] into `builder` [b] +builder store_slice(builder b, slice s) asm "STSLICER"; + +;;; Stores (serializes) an integer [x] in the range `0..2^120 − 1` into `builder` [b]. +;;; The serialization of [x] consists of a 4-bit unsigned big-endian integer `l`, +;;; which is the smallest integer `l ≥ 0`, such that `x < 2^8l`, +;;; followed by an `8l`-bit unsigned big-endian representation of [x]. +;;; If [x] does not belong to the supported range, a range check exception is thrown. +;;; +;;; Store amounts of TonCoins to the builder as VarUInteger 16 +builder store_grams(builder b, int x) asm "STGRAMS"; +builder store_coins(builder b, int x) asm "STGRAMS"; + +;;; Stores dictionary `D` represented by `cell` [c] or `null` into `builder` [b]. +;;; In other words, stores a `1`-bit and a reference to [c] if [c] is not `null` and `0`-bit otherwise. +builder store_dict(builder b, cell c) asm(c b) "STDICT"; + +;;; Stores (Maybe ^Cell) to builder: +;;; if cell is null store 1 zero bit +;;; otherwise store 1 true bit and ref to cell +builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF"; + + +{- + # Address manipulation primitives + The address manipulation primitives listed below serialize and deserialize values according to the following TL-B scheme: + ```TL-B + addr_none$00 = MsgAddressExt; + addr_extern$01 len:(## 8) external_address:(bits len) + = MsgAddressExt; + anycast_info$_ depth:(#<= 30) { depth >= 1 } + rewrite_pfx:(bits depth) = Anycast; + addr_std$10 anycast:(Maybe Anycast) + workchain_id:int8 address:bits256 = MsgAddressInt; + addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9) + workchain_id:int32 address:(bits addr_len) = MsgAddressInt; + _ _:MsgAddressInt = MsgAddress; + _ _:MsgAddressExt = MsgAddress; + + int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + src:MsgAddress dest:MsgAddressInt + value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams + created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed; + ext_out_msg_info$11 src:MsgAddress dest:MsgAddressExt + created_lt:uint64 created_at:uint32 = CommonMsgInfoRelaxed; + ``` + A deserialized `MsgAddress` is represented by a tuple `t` as follows: + + - `addr_none` is represented by `t = (0)`, + i.e., a tuple containing exactly one integer equal to zero. + - `addr_extern` is represented by `t = (1, s)`, + where slice `s` contains the field `external_address`. In other words, ` + t` is a pair (a tuple consisting of two entries), containing an integer equal to one and slice `s`. + - `addr_std` is represented by `t = (2, u, x, s)`, + where `u` is either a `null` (if `anycast` is absent) or a slice `s'` containing `rewrite_pfx` (if anycast is present). + Next, integer `x` is the `workchain_id`, and slice `s` contains the address. + - `addr_var` is represented by `t = (3, u, x, s)`, + where `u`, `x`, and `s` have the same meaning as for `addr_std`. +-} + +;;; Loads from slice [s] the only prefix that is a valid `MsgAddress`, +;;; and returns both this prefix `s'` and the remainder `s''` of [s] as slices. +(slice, slice) load_msg_addr(slice s) asm( -> 1 0) "LDMSGADDR"; + +;;; Decomposes slice [s] containing a valid `MsgAddress` into a `tuple t` with separate fields of this `MsgAddress`. +;;; If [s] is not a valid `MsgAddress`, a cell deserialization exception is thrown. +tuple parse_addr(slice s) asm "PARSEMSGADDR"; + +;;; Parses slice [s] containing a valid `MsgAddressInt` (usually a `msg_addr_std`), +;;; applies rewriting from the anycast (if present) to the same-length prefix of the address, +;;; and returns both the workchain and the 256-bit address as integers. +;;; If the address is not 256-bit, or if [s] is not a valid serialization of `MsgAddressInt`, +;;; throws a cell deserialization exception. +(int, int) parse_std_addr(slice s) asm "REWRITESTDADDR"; + +;;; A variant of [parse_std_addr] that returns the (rewritten) address as a slice [s], +;;; even if it is not exactly 256 bit long (represented by a `msg_addr_var`). +(int, slice) parse_var_addr(slice s) asm "REWRITEVARADDR"; + +{- + # Dictionary primitives +-} + + +;;; Sets the value associated with [key_len]-bit key signed index in dictionary [dict] to [value] (cell), +;;; and returns the resulting dictionary. +cell idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; +(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; + +;;; Sets the value associated with [key_len]-bit key unsigned index in dictionary [dict] to [value] (cell), +;;; and returns the resulting dictionary. +cell udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; +(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; + +cell idict_get_ref(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETOPTREF"; +(cell, int) idict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETREF" "NULLSWAPIFNOT"; +(cell, int) udict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETREF" "NULLSWAPIFNOT"; +(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETGETOPTREF"; +(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETGETOPTREF"; +(cell, int) idict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL"; +(cell, int) udict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL"; +(slice, int) idict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; +(slice, int) udict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; +(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +cell udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; +(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; +cell idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; +(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; +cell dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; +(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; +(cell, int) udict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUADD"; +(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACE"; +(cell, int) idict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIADD"; +(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACE"; +cell udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; +(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; +cell idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; +(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; +cell dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; +(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; +(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUADDB"; +(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEB"; +(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIADDB"; +(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEB"; +(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; + +;;; Creates an empty dictionary, which is actually a null value. Equivalent to PUSHNULL +cell new_dict() asm "NEWDICT"; +;;; Checks whether a dictionary is empty. Equivalent to cell_null?. +int dict_empty?(cell c) asm "DICTEMPTY"; + + +{- Prefix dictionary primitives -} +(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; +(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) asm(value key dict key_len) "PFXDICTSET"; +(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTDEL"; + +;;; Returns the value of the global configuration parameter with integer index `i` as a `cell` or `null` value. +cell config_param(int x) asm "CONFIGOPTPARAM"; +;;; Checks whether c is a null. Note, that FunC also has polymorphic null? built-in. +int cell_null?(cell c) asm "ISNULL"; + +;;; Creates an output action which would reserve exactly amount nanotoncoins (if mode = 0), at most amount nanotoncoins (if mode = 2), or all but amount nanotoncoins (if mode = 1 or mode = 3), from the remaining balance of the account. It is roughly equivalent to creating an outbound message carrying amount nanotoncoins (or b − amount nanotoncoins, where b is the remaining balance) to oneself, so that the subsequent output actions would not be able to spend more money than the remainder. Bit +2 in mode means that the external action does not fail if the specified amount cannot be reserved; instead, all remaining balance is reserved. Bit +8 in mode means `amount <- -amount` before performing any further actions. Bit +4 in mode means that amount is increased by the original balance of the current account (before the compute phase), including all extra currencies, before performing any other checks and actions. Currently, amount must be a non-negative integer, and mode must be in the range 0..15. +() raw_reserve(int amount, int mode) impure asm "RAWRESERVE"; +;;; Similar to raw_reserve, but also accepts a dictionary extra_amount (represented by a cell or null) with extra currencies. In this way currencies other than TonCoin can be reserved. +() raw_reserve_extra(int amount, cell extra_amount, int mode) impure asm "RAWRESERVEX"; +;;; Sends a raw message contained in msg, which should contain a correctly serialized object Message X, with the only exception that the source address is allowed to have dummy value addr_none (to be automatically replaced with the current smart contract address), and ihr_fee, fwd_fee, created_lt and created_at fields can have arbitrary values (to be rewritten with correct values during the action phase of the current transaction). Integer parameter mode contains the flags. Currently mode = 0 is used for ordinary messages; mode = 128 is used for messages that are to carry all the remaining balance of the current smart contract (instead of the value originally indicated in the message); mode = 64 is used for messages that carry all the remaining value of the inbound message in addition to the value initially indicated in the new message (if bit 0 is not set, the gas fees are deducted from this amount); mode' = mode + 1 means that the sender wants to pay transfer fees separately; mode' = mode + 2 means that any errors arising while processing this message during the action phase should be ignored. Finally, mode' = mode + 32 means that the current account must be destroyed if its resulting balance is zero. This flag is usually employed together with +128. +() send_raw_message(cell msg, int mode) impure asm "SENDRAWMSG"; +;;; Creates an output action that would change this smart contract code to that given by cell new_code. Notice that this change will take effect only after the successful termination of the current run of the smart contract +() set_code(cell new_code) impure asm "SETCODE"; + +;;; Generates a new pseudo-random unsigned 256-bit integer x. The algorithm is as follows: if r is the old value of the random seed, considered as a 32-byte array (by constructing the big-endian representation of an unsigned 256-bit integer), then its sha512(r) is computed; the first 32 bytes of this hash are stored as the new value r' of the random seed, and the remaining 32 bytes are returned as the next random value x. +int random() impure asm "RANDU256"; +;;; Generates a new pseudo-random integer z in the range 0..range−1 (or range..−1, if range < 0). More precisely, an unsigned random value x is generated as in random; then z := x * range / 2^256 is computed. +int rand(int range) impure asm "RAND"; +;;; Returns the current random seed as an unsigned 256-bit Integer. +int get_seed() impure asm "RANDSEED"; +;;; Sets the random seed to unsigned 256-bit seed. +() set_seed(int) impure asm "SETRAND"; +;;; Mixes unsigned 256-bit integer x into the random seed r by setting the random seed to sha256 of the concatenation of two 32-byte strings: the first with the big-endian representation of the old seed r, and the second with the big-endian representation of x. +() randomize(int x) impure asm "ADDRAND"; +;;; Equivalent to randomize(cur_lt());. +() randomize_lt() impure asm "LTIME" "ADDRAND"; + +;;; Checks whether the data parts of two slices coinside +int equal_slice_bits (slice a, slice b) asm "SDEQ"; + +;;; Concatenates two builders +builder store_builder(builder to, builder from) asm "STBR"; diff --git a/src/func/grammar-test/wallet-code.fc b/src/func/grammar-test/wallet-code.fc new file mode 100644 index 000000000..9d4cddb71 --- /dev/null +++ b/src/func/grammar-test/wallet-code.fc @@ -0,0 +1,37 @@ +;; Simple wallet smart contract + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +() recv_external(slice in_msg) impure { + var signature = in_msg~load_bits(512); + var cs = in_msg; + var (msg_seqno, valid_until) = (cs~load_uint(32), cs~load_uint(32)); + throw_if(35, valid_until <= now()); + var ds = get_data().begin_parse(); + var (stored_seqno, public_key) = (ds~load_uint(32), ds~load_uint(256)); + ds.end_parse(); + throw_unless(33, msg_seqno == stored_seqno); + throw_unless(34, check_signature(slice_hash(in_msg), signature, public_key)); + accept_message(); + cs~touch(); + while (cs.slice_refs()) { + var mode = cs~load_uint(8); + send_raw_message(cs~load_ref(), mode); + } + cs.end_parse(); + set_data(begin_cell().store_uint(stored_seqno + 1, 32).store_uint(public_key, 256).end_cell()); +} + +;; Get methods + +int seqno() method_id { + return get_data().begin_parse().preload_uint(32); +} + +int get_public_key() method_id { + var cs = get_data().begin_parse(); + cs~load_uint(32); + return cs.preload_uint(256); +} diff --git a/src/func/grammar-test/wallet3-code.fc b/src/func/grammar-test/wallet3-code.fc new file mode 100644 index 000000000..964b35cda --- /dev/null +++ b/src/func/grammar-test/wallet3-code.fc @@ -0,0 +1,41 @@ +;; Simple wallet smart contract + +() recv_internal(slice in_msg) impure { + ;; do nothing for internal messages +} + +() recv_external(slice in_msg) impure { + var signature = in_msg~load_bits(512); + var cs = in_msg; + var (subwallet_id, valid_until, msg_seqno) = (cs~load_uint(32), cs~load_uint(32), cs~load_uint(32)); + throw_if(35, valid_until <= now()); + var ds = get_data().begin_parse(); + var (stored_seqno, stored_subwallet, public_key) = (ds~load_uint(32), ds~load_uint(32), ds~load_uint(256)); + ds.end_parse(); + throw_unless(33, msg_seqno == stored_seqno); + throw_unless(34, subwallet_id == stored_subwallet); + throw_unless(35, check_signature(slice_hash(in_msg), signature, public_key)); + accept_message(); + cs~touch(); + while (cs.slice_refs()) { + var mode = cs~load_uint(8); + send_raw_message(cs~load_ref(), mode); + } + set_data(begin_cell() + .store_uint(stored_seqno + 1, 32) + .store_uint(stored_subwallet, 32) + .store_uint(public_key, 256) + .end_cell()); +} + +;; Get methods + +int seqno() method_id { + return get_data().begin_parse().preload_uint(32); +} + +int get_public_key() method_id { + var cs = get_data().begin_parse(); + cs~load_uint(64); + return cs.preload_uint(256); +} diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 885cd2e26..362f5bf4b 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -1,5 +1,17 @@ FunC { - Module = Pragma* Include* ModuleItem* + Module = ModuleItem* + + // + // Top-level, module items (with compiler directives) + // + + ModuleItem = Pragma + | Include + | GlobalVariablesDeclaration + | ConstantsDefinition + | AsmFunctionDefinition + | FunctionDeclaration + | FunctionDefinition // // Compiler pragmas and includes @@ -11,16 +23,6 @@ FunC { Include = "#include" stringLiteral ";" - // - // Top-level, module items - // - - ModuleItem = GlobalVariablesDeclaration - | ConstantsDefinition - | AsmFunctionDefinition - | FunctionDeclaration - | FunctionDefinition - // // Declarations of global variables // @@ -30,7 +32,7 @@ FunC { TypeGlob = TypeBuiltinGlob ("->" TypeGlob)? - TypeBuiltinGlob = #("int" | "cell" | "slice" | "builder" | "cont" | "tuple" | "_") ~#rawId --simple + TypeBuiltinGlob = #("int" | "cell" | "slice" | "builder" | "cont" | "tuple" | hole) ~#rawId --simple | unit | tupleEmpty | TensorGlob | TupleGlob TensorGlob = "(" NonemptyListOf ")" @@ -77,17 +79,18 @@ FunC { TensorReturn = "(" NonemptyListOf ")" TupleReturn = "[" NonemptyListOf "]" - // Function parameters + // Function parameters (upper is defined in Ohm's built-in rules) Parameters = "(" ListOf ")" - Parameter = TypeParameter &#whiteSpace (unusedId | id) --regular - | id --inferredType + Parameter = TypeParameter (unusedId | functionId)? --regular + | functionId --inferredType + | "_" --hole // Function parameter types TypeParameter = TypeBuiltinParameter (&#whiteSpace "->" &#whiteSpace TypeParameter)? - TypeBuiltinParameter = id + TypeBuiltinParameter = upperId | "int" | "cell" | "slice" | "builder" | "cont" | "tuple" - | unit | tupleEmpty | TensorParameter | TupleParameter + | hole | unit | tupleEmpty | TensorParameter | TupleParameter TensorParameter = "(" NonemptyListOf ")" TupleParameter = "[" NonemptyListOf "]" @@ -150,7 +153,7 @@ FunC { // parse_expr10 ExpressionAssign = ExpressionConditional - &#whiteSpace ("=" | "+=" | "-=" | "*=" | "/=" | "%=" + &#whiteSpace ("=" ~#"=" | "+=" | "-=" | "*=" | "/=" | "%=" | "~/=" | "~%=" | "^/=" | "^%=" | "&=" | "|=" | "^=" | "<<=" | ">>=" | "~>>=" | "^>>=") &#whiteSpace ExpressionAssign --op @@ -179,6 +182,7 @@ FunC { ExpressionMulBitwise (&#whiteSpace ("+" | "-" | "|" | "^") &#whiteSpace ExpressionMulBitwise)+ --ops + | "-" &#whiteSpace ExpressionMulBitwise --negate | ExpressionMulBitwise // parse_expr30 @@ -242,6 +246,7 @@ FunC { TypeBuiltinVarDecl = #("int" | "cell" | "slice" | "builder" | "cont" | "tuple" | hole) ~#rawId --simple | unit | tupleEmpty | TensorVarDecl | TupleVarDecl // TODO: return `| id`, differentiate between function calls and variable declarations during syntax analysis and AST construction (through careful use of declared type variables in `forall`) + // NOTE: this can be easily added using the same heuristic as in parameters -- upperId, because type variables are advised to be named starting with an uppercase letter. TensorVarDecl = "(" NonemptyListOf ")" TupleVarDecl = "[" NonemptyListOf "]" @@ -251,7 +256,7 @@ FunC { // // Special types or values - hole = ("_" | "var") ~id + hole = ("_" | "var") ~rawId unit = "(" whiteSpace* ")" // (not a separate type, added purely for convenience) tupleEmpty = "[" whiteSpace* "]" @@ -280,6 +285,9 @@ FunC { // Method identifiers (not a separate type, added purely for convenience) methodId = ~("\"" | "{-") ("." | "~") ~((hole | integerLiteral | delimiter | operator | primitive) ~rawId) rawId + // Uppercase plain identifiers (common for type variables) + upperId = ~("\"" | "{-" | "." | "~") ~((hole | integerLiteral | delimiter | operator | primitive) ~plainId) &upper plainId + // Identifiers, with invalidation (keywords, numbers, etc.) during syntax analysis // — this makes this parser closer to the C++ one, and also improves error messages id = ~("\"" | "{-" | "." | "~") ~((hole | integerLiteral | delimiter | operator | primitive) ~rawId) rawId diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 34f191ce8..de265e4b4 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -459,8 +459,6 @@ function checkMethodId(ident: string, loc: FuncSrcInfo): void | never { export type FuncAstNode = | FuncAstModule - | FuncAstPragma - | FuncAstInclude | FuncAstModuleItem | FuncAstStatement | FuncAstExpression @@ -469,8 +467,6 @@ export type FuncAstNode = export type FuncAstModule = { kind: "module"; - pragmas: FuncAstPragma[]; - includes: FuncAstInclude[]; items: FuncAstModuleItem[]; loc: FuncSrcInfo; }; @@ -532,6 +528,8 @@ export type FuncAstInclude = { // export type FuncAstModuleItem = + | FuncAstPragma + | FuncAstInclude | FuncAstGlobalVariablesDeclaration | FuncAstConstantsDefinition | FuncAstAsmFunctionDefinition @@ -668,12 +666,12 @@ export type FuncAstTypeVar = { /** * Note, that id can be an underscore only if type is defined * - * Type? id + * Type id? */ export type FuncAstParameter = { kind: "parameter"; ty: FuncAstType | undefined; - name: FuncAstQuotedId | FuncAstPlainId | FuncAstUnusedId; + name: FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId | FuncAstUnusedId | undefined; loc: FuncSrcInfo; }; @@ -942,6 +940,8 @@ export type FuncExpressionBitwiseShiftPart = { export type FuncOpBitwiseShift = "<<" | ">>" | "~>>" | "^>>"; /** + * Note, that sometimes `ops` can be an empty array, due to the unary minus (`negateLeft`) + * * parse_expr20 */ export type FuncAstExpressionAddBitwise = { @@ -1365,11 +1365,9 @@ export type FuncAstCommentMultiLine = { const semantics = FuncGrammar.createSemantics(); semantics.addOperation("astOfModule", { - Module(pragmas, includes, items) { + Module(items) { return { kind: "module", - pragmas: pragmas.children.map((x) => x.astOfPragma()), - includes: includes.children.map((x) => x.astOfInclude()), items: items.children.map((x) => x.astOfModuleItem()), loc: createSrcInfo(this), }; @@ -1408,9 +1406,12 @@ semantics.addOperation("astOfModule", { }, }); -semantics.addOperation("astOfPragma", { +semantics.addOperation("astOfModuleItem", { + ModuleItem(item) { + return item.astOfModuleItem(); + }, Pragma(pragma) { - return pragma.astOfPragma(); + return pragma.astOfModuleItem(); }, Pragma_literal(_pragmaKwd, literal, _semicolon) { return { @@ -1451,9 +1452,6 @@ semantics.addOperation("astOfPragma", { loc: createSrcInfo(this), }; }, -}); - -semantics.addOperation("astOfInclude", { Include(_includeKwd, path, _semicolon) { return { kind: "include", @@ -1461,12 +1459,6 @@ semantics.addOperation("astOfInclude", { loc: createSrcInfo(this), }; }, -}); - -semantics.addOperation("astOfModuleItem", { - ModuleItem(item) { - return item.astOfModuleItem(); - }, GlobalVariablesDeclaration(_globalKwd, globals, _semicolon) { return { kind: "global_variables_declaration", @@ -1710,6 +1702,15 @@ semantics.addOperation("astOfExpression", { loc: createSrcInfo(this), }; }, + ExpressionAddBitwise_negate(_negateOp, _space, expr) { + return { + kind: "expression_add_bitwise", + negateLeft: true, + left: expr.astOfExpression(), + ops: [], + loc: createSrcInfo(this), + } + }, // parse_expr30 ExpressionMulBitwise(expr) { @@ -2019,7 +2020,6 @@ semantics.addOperation("astOfVersionRange", { const major = majorVers.astOfExpression() as FuncAstIntegerLiteral; const minor = unwrapOptNode(optMinorVers, t => t.astOfExpression()) as (FuncAstIntegerLiteral | undefined); const patch = unwrapOptNode(optPatchVers, t => t.astOfExpression()) as (FuncAstIntegerLiteral | undefined); - return { kind: "version_range", op: op, @@ -2035,15 +2035,12 @@ semantics.addOperation("astOfVersionRange", { semantics.addOperation("astOfGlobalVariable", { GlobalVariableDeclaration(optGlobTy, globName) { const name = globName.astOfExpression() as FuncAstId; - // if a plainId, then check for validity if (name.kind === "plain_id") { checkPlainId(name.value, createSrcInfo(this), "Name of the global variable"); } - // check that it can be declared (also excludes operatorId and unusedId) checkDeclaredId(name.value, createSrcInfo(this), "Name of the global variable"); - // and that it's not a methodId if (name.kind === "method_id") { throwFuncSyntaxError( @@ -2051,7 +2048,6 @@ semantics.addOperation("astOfGlobalVariable", { createSrcInfo(this), ); } - // leaving only quotedId or plainId return { kind: "global_variable", @@ -2067,15 +2063,12 @@ semantics.addOperation("astOfConstant", { ConstantDefinition(optConstTy, constName, _eqSign, expr) { const ty = unwrapOptNode(optConstTy, t => t.sourceString); const name = constName.astOfExpression() as FuncAstId; - // if a plainId, then check for validity if (name.kind === "plain_id") { checkPlainId(name.value, createSrcInfo(this), "Name of the constant"); } - // check that it can be declared (also excludes operatorId and unusedId) checkDeclaredId(name.value, createSrcInfo(this), "Name of the constant"); - // and that it's not a methodId if (name.kind === "method_id") { throwFuncSyntaxError( @@ -2083,7 +2076,6 @@ semantics.addOperation("astOfConstant", { createSrcInfo(this), ); } - return { kind: "constant", ty: ty !== undefined ? ty as ("slice" | "int") : undefined, @@ -2107,15 +2099,12 @@ type FuncFunctionCommonPrefix = { semantics.addOperation("astOfFunctionCommonPrefix", { FunctionCommonPrefix(optForall, retTy, fnName, fnParams, fnAttributes) { const name = fnName.astOfExpression() as FuncAstId; - // if a plainId, then check for validity if (name.kind === "plain_id") { checkPlainId(name.value, createSrcInfo(this), "Name of the function"); } - // check that it can be declared (also excludes operatorId and unusedId) checkDeclaredId(name.value, createSrcInfo(this), "Name of the function"); - return { forall: unwrapOptNode(optForall, t => t.astOfForall()), returnTy: retTy.astOfType(), @@ -2149,55 +2138,53 @@ semantics.addOperation("astOfParameter", { Parameter(param) { return param.astOfParameter(); }, - Parameter_regular(paramTy, _space, unusedIdOrId) { - const name = unusedIdOrId.astOfExpression() as FuncAstId; - + Parameter_regular(paramTy, optId) { + const name = unwrapOptNode(optId, t => t.astOfExpression() as FuncAstId); + if (name === undefined) { + return { + kind: "parameter", + ty: paramTy.astOfType(), + name: undefined, + loc: createSrcInfo(this), + }; + } // if a plainId, then check for validity if (name.kind === "plain_id") { checkPlainId(name.value, createSrcInfo(this), "Name of the parameter"); } - // check that it can be declared (also excludes operatorId, but not unusedId) checkDeclaredId(name.value, createSrcInfo(this), "Name of the parameter", true); - - // and that it's not a methodId - if (name.kind === "method_id") { - throwFuncSyntaxError( - "Name of the parameter cannot start with ~ or .", - createSrcInfo(this), - ); - } - return { kind: "parameter", ty: paramTy.astOfType(), - name: name as (FuncAstQuotedId | FuncAstPlainId | FuncAstUnusedId), + name: name as (FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId | FuncAstUnusedId | undefined), loc: createSrcInfo(this), }; }, - Parameter_inferredType(paramName) { - const name = paramName.astOfExpression() as FuncAstId; - + Parameter_inferredType(funId) { + const name = funId.astOfExpression() as FuncAstId; // if a plainId, then check for validity if (name.kind === "plain_id") { checkPlainId(name.value, createSrcInfo(this), "Name of the parameter"); } - // check that it can be declared (also excludes operatorId and unusedId) checkDeclaredId(name.value, createSrcInfo(this), "Name of the parameter"); - - // and that it's not a methodId - if (name.kind === "method_id") { - throwFuncSyntaxError( - "Name of the parameter cannot start with ~ or .", - createSrcInfo(this), - ); - } - return { kind: "parameter", ty: undefined, - name: name as (FuncAstQuotedId | FuncAstPlainId), + name: name as (FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId), + loc: createSrcInfo(this), + }; + }, + Parameter_hole(node) { + return { + kind: "parameter", + ty: { + kind: "hole", + value: "_", + loc: createSrcInfo(this), + }, + name: undefined, loc: createSrcInfo(this), }; }, @@ -2282,6 +2269,21 @@ semantics.addOperation("astOfType", { loc: createSrcInfo(this), }; }, + upperId(_lookahead, upperPlainId) { + return { + kind: "type_var", + keyword: false, + name: upperPlainId.astOfExpression(), + loc: createSrcInfo(this), + }; + }, + hole(node) { + return { + kind: "hole", + value: node.sourceString as ("var" | "_"), + loc: createSrcInfo(this), + }; + }, unit(_lparen, _space, _rparen) { return { kind: "unit", @@ -2312,17 +2314,12 @@ semantics.addOperation("astOfType", { return globBiTy.astOfType(); }, TypeBuiltinGlob_simple(globBiTy) { - const ty = globBiTy.sourceString; - if (ty === "_") { - return { - kind: "hole", - value: "_", - loc: createSrcInfo(this), - }; + if (!globBiTy.isTerminal()) { + return globBiTy.astOfType(); } return { kind: "type_primitive", - value: ty as FuncTypePrimitive, + value: globBiTy.sourceString as FuncTypePrimitive, loc: createSrcInfo(this), }; }, @@ -2407,17 +2404,9 @@ semantics.addOperation("astOfType", { }, TypeBuiltinParameter(paramBiTy) { if (paramBiTy.isTerminal()) { - const ty = paramBiTy.sourceString; - if (ty === "_") { - return { - kind: "hole", - value: "_", - loc: createSrcInfo(this), - }; - } return { kind: "type_primitive", - value: ty as FuncTypePrimitive, + value: paramBiTy.sourceString as FuncTypePrimitive, loc: createSrcInfo(this), }; } From f31583415bf263349ad08dc1e21b58145724bcc5 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:21:00 +0200 Subject: [PATCH 104/162] chore(func-parser): change the note --- src/func/grammar.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/func/grammar.ts b/src/func/grammar.ts index de265e4b4..fb27d7fbf 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -452,9 +452,8 @@ function checkMethodId(ident: string, loc: FuncSrcInfo): void | never { } // -// FIXME: Those are matching contents of the grammar.ohm with some minor optimizations for clarity -// FIXME: Pls, unite with syntax.ts and refactor dependent files -// FIXME: Would need help once parser is done on my side :) +// Types used to construct the AST of FunC +// Those mostly match the grammar.ohm, albeit with some minor optimizations for clarity and ease of use // export type FuncAstNode = From 9658c5b638ba6aa4b15c1bf3ab5e8ff5e1b139f0 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Sun, 11 Aug 2024 13:57:25 +0200 Subject: [PATCH 105/162] chore(func-parser): simplify `upperId`' regex and reformat `grammar.ts` Tiny nits --- src/func/grammar.ohm | 2 +- src/func/grammar.spec.ts | 2 +- src/func/grammar.ts | 553 +++++++++++++++++++++++++++------------ 3 files changed, 393 insertions(+), 164 deletions(-) diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 362f5bf4b..02a1aa1fc 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -286,7 +286,7 @@ FunC { methodId = ~("\"" | "{-") ("." | "~") ~((hole | integerLiteral | delimiter | operator | primitive) ~rawId) rawId // Uppercase plain identifiers (common for type variables) - upperId = ~("\"" | "{-" | "." | "~") ~((hole | integerLiteral | delimiter | operator | primitive) ~plainId) &upper plainId + upperId = &upper plainId // Identifiers, with invalidation (keywords, numbers, etc.) during syntax analysis // — this makes this parser closer to the C++ one, and also improves error messages diff --git a/src/func/grammar.spec.ts b/src/func/grammar.spec.ts index a856655c8..626e16f3b 100644 --- a/src/func/grammar.spec.ts +++ b/src/func/grammar.spec.ts @@ -36,7 +36,7 @@ describe("FunC grammar and parser", () => { for (const r of loadCases(__dirname + "/grammar-test-failed/", ext)) { it("should NOT parse " + r.name, () => { expect(() => - parseFile(r.code, r.name + `.${ext}`) + parseFile(r.code, r.name + `.${ext}`), ).toThrowErrorMatchingSnapshot(); }); } diff --git a/src/func/grammar.ts b/src/func/grammar.ts index fb27d7fbf..47564c212 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -192,7 +192,7 @@ const funcBuiltinOperatorFunctions = [ "_>=_", "_<=>_", ]; - + const funcBuiltinFunctions = [ "divmod", "moddiv", @@ -348,7 +348,12 @@ const funcHexIntRegex = /^\-?0x[0-9a-fA-F]+$/; * - NOT a builtin constant * - NOT an underscore (unless it's a parameter or variable declaration) */ -function checkDeclaredId(ident: string, loc: FuncSrcInfo, altPrefix?: string, allowUnused?: boolean): void | never { +function checkDeclaredId( + ident: string, + loc: FuncSrcInfo, + altPrefix?: string, + allowUnused?: boolean, +): void | never { // not an operatorId if (funcBuiltinOperatorFunctions.includes(ident)) { throwFuncSyntaxError( @@ -408,33 +413,61 @@ function checkOperatorId(ident: string): boolean { * - NOT an operator (without underscores, like operatorId) * - NOT a number */ -function checkPlainId(ident: string, loc: FuncSrcInfo, altPrefix?: string): void | never { +function checkPlainId( + ident: string, + loc: FuncSrcInfo, + altPrefix?: string, +): void | never { if (funcKeywords.includes(ident)) { - throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a keyword`, loc); + throwFuncSyntaxError( + `${altPrefix ?? "Identifier"} cannot be a keyword`, + loc, + ); } if (funcControlKeywords.includes(ident)) { - throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a control keyword`, loc); + throwFuncSyntaxError( + `${altPrefix ?? "Identifier"} cannot be a control keyword`, + loc, + ); } if (funcTypeKeywords.includes(ident)) { - throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a type keyword`, loc); + throwFuncSyntaxError( + `${altPrefix ?? "Identifier"} cannot be a type keyword`, + loc, + ); } if (funcDirectives.includes(ident)) { - throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a compiler directive`, loc); + throwFuncSyntaxError( + `${altPrefix ?? "Identifier"} cannot be a compiler directive`, + loc, + ); } if (funcDelimiters.includes(ident)) { - throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be a delimiter`, loc); + throwFuncSyntaxError( + `${altPrefix ?? "Identifier"} cannot be a delimiter`, + loc, + ); } if (funcOperators.includes(ident)) { - throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be an operator`, loc); + throwFuncSyntaxError( + `${altPrefix ?? "Identifier"} cannot be an operator`, + loc, + ); } - if (ident.match(funcDecIntRegex) !== null || ident.match(funcHexIntRegex) !== null) { - throwFuncSyntaxError(`${altPrefix ?? "Identifier"} cannot be an integer literal`, loc); + if ( + ident.match(funcDecIntRegex) !== null || + ident.match(funcHexIntRegex) !== null + ) { + throwFuncSyntaxError( + `${altPrefix ?? "Identifier"} cannot be an integer literal`, + loc, + ); } } @@ -670,7 +703,12 @@ export type FuncAstTypeVar = { export type FuncAstParameter = { kind: "parameter"; ty: FuncAstType | undefined; - name: FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId | FuncAstUnusedId | undefined; + name: + | FuncAstMethodId + | FuncAstQuotedId + | FuncAstPlainId + | FuncAstUnusedId + | undefined; loc: FuncSrcInfo; }; @@ -896,7 +934,7 @@ export type FuncOpAssign = | ">>=" | "~>>=" | "^>>="; - + /** * parse_expr13 */ @@ -974,7 +1012,15 @@ export type FuncExpressionMulBitwiseOp = { }; export type FuncOpMulBitwise = - | "*" | "/%" | "/" | "%" | "~/" | "~%" | "^/" | "^%" | "&"; + | "*" + | "/%" + | "/" + | "%" + | "~/" + | "~%" + | "^/" + | "^%" + | "&"; /** * parse_expr75 @@ -1154,7 +1200,13 @@ export type FuncAstTypePrimitive = { loc: FuncSrcInfo; }; -export type FuncTypePrimitive = "int" | "cell" | "slice" | "builder" | "cont" | "tuple"; +export type FuncTypePrimitive = + | "int" + | "cell" + | "slice" + | "builder" + | "cont" + | "tuple"; /** * (..., ...) or [..., ...] or (_ | var) or () @@ -1415,7 +1467,9 @@ semantics.addOperation("astOfModuleItem", { Pragma_literal(_pragmaKwd, literal, _semicolon) { return { kind: "pragma_literal", - literal: literal.sourceString as ("allow-post-modification" | "compute-asm-ltr"), + literal: literal.sourceString as + | "allow-post-modification" + | "compute-asm-ltr", loc: createSrcInfo(this), }; }, @@ -1461,14 +1515,18 @@ semantics.addOperation("astOfModuleItem", { GlobalVariablesDeclaration(_globalKwd, globals, _semicolon) { return { kind: "global_variables_declaration", - globals: globals.asIteration().children.map((x) => x.astOfGlobalVariable()), + globals: globals + .asIteration() + .children.map((x) => x.astOfGlobalVariable()), loc: createSrcInfo(this), }; }, ConstantsDefinition(_constKwd, constants, _semicolon) { return { kind: "constants_definition", - constants: constants.asIteration().children.map((x) => x.astOfConstant()), + constants: constants + .asIteration() + .children.map((x) => x.astOfConstant()), loc: createSrcInfo(this), }; }, @@ -1487,8 +1545,10 @@ semantics.addOperation("astOfModuleItem", { name: prefix.name, parameters: prefix.parameters, attributes: prefix.attributes, - arrangement: unwrapOptNode(optArrangement, t => t.astOfAsmArrangement()), - asmStrings: asmStrings.children.map(x => x.astOfExpression()), + arrangement: unwrapOptNode(optArrangement, (t) => + t.astOfAsmArrangement(), + ), + asmStrings: asmStrings.children.map((x) => x.astOfExpression()), loc: createSrcInfo(this), }; }, @@ -1503,7 +1563,6 @@ semantics.addOperation("astOfModuleItem", { attributes: prefix.attributes, loc: createSrcInfo(this), }; - }, FunctionDefinition(fnCommonPrefix, _lbrace, stmts, _rbrace) { const prefix = fnCommonPrefix.astOfFunctionCommonPrefix(); @@ -1514,10 +1573,9 @@ semantics.addOperation("astOfModuleItem", { name: prefix.name, parameters: prefix.parameters, attributes: prefix.attributes, - statements: stmts.children.map(x => x.astOfStatement()), + statements: stmts.children.map((x) => x.astOfStatement()), loc: createSrcInfo(this), }; - }, }); @@ -1531,7 +1589,7 @@ semantics.addOperation("astOfStatement", { kind: "statement_return", expression: expr.astOfExpression(), loc: createSrcInfo(this), - } + }; }, StatementBlock(_lbrace, statements, _rbrace) { return { @@ -1544,7 +1602,7 @@ semantics.addOperation("astOfStatement", { return { kind: "statement_empty", loc: createSrcInfo(this), - } + }; }, StatementCondition(cond) { return cond.astOfStatement(); @@ -1554,21 +1612,37 @@ semantics.addOperation("astOfStatement", { kind: "statement_condition_if", positive: ifOr.sourceString === "if" ? true : false, condition: cond.astOfExpression(), - consequences: stmts.children.map(x => x.astOfStatement()), - alternatives: unwrapOptNode(optElse, t => t.astOfElseBlock()), - loc: createSrcInfo(this), - }; - }, - StatementCondition_elseif(ifOr, condIf, _lbrace, stmtsIf, _rbrace, elseifOr, condElseif, _lbrace2, stmtsElseif, _rbrace2, optElse) { + consequences: stmts.children.map((x) => x.astOfStatement()), + alternatives: unwrapOptNode(optElse, (t) => t.astOfElseBlock()), + loc: createSrcInfo(this), + }; + }, + StatementCondition_elseif( + ifOr, + condIf, + _lbrace, + stmtsIf, + _rbrace, + elseifOr, + condElseif, + _lbrace2, + stmtsElseif, + _rbrace2, + optElse, + ) { return { kind: "statement_condition_elseif", positiveIf: ifOr.sourceString === "if" ? true : false, conditionIf: condIf.astOfExpression(), - consequencesIf: stmtsIf.children.map(x => x.astOfStatement()), + consequencesIf: stmtsIf.children.map((x) => x.astOfStatement()), positiveElseif: elseifOr.sourceString === "elseif" ? true : false, conditionElseif: condElseif.astOfExpression(), - consequencesElseif: stmtsElseif.children.map(x => x.astOfStatement()), - alternativesElseif: unwrapOptNode(optElse, t => t.astOfElseBlock()), + consequencesElseif: stmtsElseif.children.map((x) => + x.astOfStatement(), + ), + alternativesElseif: unwrapOptNode(optElse, (t) => + t.astOfElseBlock(), + ), loc: createSrcInfo(this), }; }, @@ -1576,14 +1650,22 @@ semantics.addOperation("astOfStatement", { return { kind: "statement_repeat", iterations: expr.astOfExpression(), - statements: stmts.children.map(x => x.astOfStatement()), + statements: stmts.children.map((x) => x.astOfStatement()), loc: createSrcInfo(this), }; }, - StatementUntil(_doKwd, _lbrace, stmts, _rbrace, _untilKwd, cond, _semicolon) { + StatementUntil( + _doKwd, + _lbrace, + stmts, + _rbrace, + _untilKwd, + cond, + _semicolon, + ) { return { kind: "statement_until", - statements: stmts.children.map(x => x.astOfStatement()), + statements: stmts.children.map((x) => x.astOfStatement()), condition: cond.astOfExpression(), loc: createSrcInfo(this), }; @@ -1592,17 +1674,31 @@ semantics.addOperation("astOfStatement", { return { kind: "statement_while", condition: cond.astOfExpression(), - statements: stmts.children.map(x => x.astOfStatement()), - loc: createSrcInfo(this), - }; - }, - StatementTryCatch(_tryKwd, _lbrace, stmtsTry, _rbrace, _catchKwd, _lparen, exceptionName, _comma, exitCodeName, _rparen, _lbrace2, stmtsCatch, _rbrace2) { + statements: stmts.children.map((x) => x.astOfStatement()), + loc: createSrcInfo(this), + }; + }, + StatementTryCatch( + _tryKwd, + _lbrace, + stmtsTry, + _rbrace, + _catchKwd, + _lparen, + exceptionName, + _comma, + exitCodeName, + _rparen, + _lbrace2, + stmtsCatch, + _rbrace2, + ) { return { kind: "statement_try_catch", - statementsTry: stmtsTry.children.map(x => x.astOfStatement()), + statementsTry: stmtsTry.children.map((x) => x.astOfStatement()), catchExceptionName: exceptionName.astOfExpression(), catchExitCodeName: exitCodeName.astOfExpression(), - statementsCatch: stmtsCatch.children.map(x => x.astOfStatement()), + statementsCatch: stmtsCatch.children.map((x) => x.astOfStatement()), loc: createSrcInfo(this), }; }, @@ -1640,7 +1736,17 @@ semantics.addOperation("astOfExpression", { ExpressionConditional(expr) { return expr.astOfExpression(); }, - ExpressionConditional_ternary(exprLeft, _space1, _qmark, _space2, exprMiddle, _space3, _colon, _space4, exprRight) { + ExpressionConditional_ternary( + exprLeft, + _space1, + _qmark, + _space2, + exprMiddle, + _space3, + _colon, + _space4, + exprRight, + ) { return { kind: "expression_conditional", condition: exprLeft.astOfExpression(), @@ -1669,11 +1775,15 @@ semantics.addOperation("astOfExpression", { return expr.astOfExpression(); }, ExpressionBitwiseShift_ops(exprLeft, _space, ops, _spaces, exprs) { - const resolvedOps = ops.children.map(x => x.sourceString as FuncOpBitwiseShift); - const resolvedExprs = exprs.children.map(x => x.astOfExpression() as FuncAstExpressionAddBitwise); - const zipped = resolvedOps.map( - (resOp, i) => { return { op: resOp, expr: resolvedExprs[i]! } } + const resolvedOps = ops.children.map( + (x) => x.sourceString as FuncOpBitwiseShift, ); + const resolvedExprs = exprs.children.map( + (x) => x.astOfExpression() as FuncAstExpressionAddBitwise, + ); + const zipped = resolvedOps.map((resOp, i) => { + return { op: resOp, expr: resolvedExprs[i]! }; + }); return { kind: "expression_bitwise_shift", left: exprLeft.astOfExpression(), @@ -1686,13 +1796,25 @@ semantics.addOperation("astOfExpression", { ExpressionAddBitwise(expr) { return expr.astOfExpression(); }, - ExpressionAddBitwise_ops(optNegate, _optSpace, exprLeft, _space, ops, _spaces,exprs) { - const negate = unwrapOptNode(optNegate, t => t.sourceString); - const resolvedOps = ops.children.map(x => x.sourceString as FuncOpAddBitwise); - const resolvedExprs = exprs.children.map(x => x.astOfExpression() as FuncAstExpressionMulBitwise); - const zipped = resolvedOps.map( - (resOp, i) => { return { op: resOp, expr: resolvedExprs[i]! } } + ExpressionAddBitwise_ops( + optNegate, + _optSpace, + exprLeft, + _space, + ops, + _spaces, + exprs, + ) { + const negate = unwrapOptNode(optNegate, (t) => t.sourceString); + const resolvedOps = ops.children.map( + (x) => x.sourceString as FuncOpAddBitwise, + ); + const resolvedExprs = exprs.children.map( + (x) => x.astOfExpression() as FuncAstExpressionMulBitwise, ); + const zipped = resolvedOps.map((resOp, i) => { + return { op: resOp, expr: resolvedExprs[i]! }; + }); return { kind: "expression_add_bitwise", negateLeft: negate === undefined ? false : true, @@ -1708,7 +1830,7 @@ semantics.addOperation("astOfExpression", { left: expr.astOfExpression(), ops: [], loc: createSrcInfo(this), - } + }; }, // parse_expr30 @@ -1716,11 +1838,15 @@ semantics.addOperation("astOfExpression", { return expr.astOfExpression(); }, ExpressionMulBitwise_ops(exprLeft, _space, ops, _spaces, exprs) { - const resolvedOps = ops.children.map(x => x.sourceString as FuncOpMulBitwise); - const resolvedExprs = exprs.children.map(x => x.astOfExpression() as FuncAstExpressionUnary); - const zipped = resolvedOps.map( - (resOp, i) => { return { op: resOp, expr: resolvedExprs[i]! } } + const resolvedOps = ops.children.map( + (x) => x.sourceString as FuncOpMulBitwise, + ); + const resolvedExprs = exprs.children.map( + (x) => x.astOfExpression() as FuncAstExpressionUnary, ); + const zipped = resolvedOps.map((resOp, i) => { + return { op: resOp, expr: resolvedExprs[i]! }; + }); return { kind: "expression_mul_bitwise", left: exprLeft.astOfExpression(), @@ -1739,7 +1865,7 @@ semantics.addOperation("astOfExpression", { op: notOp.sourceString as "~", operand: operand.astOfExpression(), loc: createSrcInfo(this), - } + }; }, // parse_expr80 @@ -1747,11 +1873,15 @@ semantics.addOperation("astOfExpression", { return expr.astOfExpression(); }, ExpressionMethod_calls(exprLeft, methodIds, _lookahead, exprs) { - const resolvedIds = methodIds.children.map(x => x.astOfExpression() as FuncAstMethodId); - const resolvedExprs = exprs.children.map(x => x.astOfExpression() as FuncArgument); - const zipped = resolvedIds.map( - (resId, i) => { return { name: resId, argument: resolvedExprs[i]! } } + const resolvedIds = methodIds.children.map( + (x) => x.astOfExpression() as FuncAstMethodId, + ); + const resolvedExprs = exprs.children.map( + (x) => x.astOfExpression() as FuncArgument, ); + const zipped = resolvedIds.map((resId, i) => { + return { name: resId, argument: resolvedExprs[i]! }; + }); return { kind: "expression_method", object: exprLeft.astOfExpression(), @@ -1759,7 +1889,7 @@ semantics.addOperation("astOfExpression", { loc: createSrcInfo(this), }; }, - + // parse_expr90, and some inner things ExpressionVarFun(expr) { return expr.astOfExpression(); @@ -1773,24 +1903,34 @@ semantics.addOperation("astOfExpression", { if (node.kind === "method_id") { throwFuncSyntaxError( "Name of the variable cannot start with . or ~", - createSrcInfo(this) + createSrcInfo(this), ); } if (node.kind === "plain_id") { - checkPlainId(node.value, createSrcInfo(this), "Name of the variable"); + checkPlainId( + node.value, + createSrcInfo(this), + "Name of the variable", + ); } - checkDeclaredId(node.value, createSrcInfo(this), "Name of the variable"); + checkDeclaredId( + node.value, + createSrcInfo(this), + "Name of the variable", + ); }; - if (names.kind === "expression_tensor_var_decl" - || names.kind === "expression_tuple_var_decl") { + if ( + names.kind === "expression_tensor_var_decl" || + names.kind === "expression_tuple_var_decl" + ) { for (let i = 0; i < names.names.length; i += 1) { checkVarDeclName(names.names[i]!); } } else { checkVarDeclName(names); } - + return { kind: "expression_var_decl", ty: varDeclTy.astOfType(), @@ -1805,14 +1945,14 @@ semantics.addOperation("astOfExpression", { return { kind: "expression_fun_call", object: expr.astOfExpression(), - arguments: args.children.map(x => x.astOfExpression()), + arguments: args.children.map((x) => x.astOfExpression()), loc: createSrcInfo(this), }; }, ExpressionArgument(expr) { return expr.astOfExpression(); }, - + // parse_expr100, and some inner things ExpressionPrimary(expr) { return expr.astOfExpression(); @@ -1827,7 +1967,9 @@ semantics.addOperation("astOfExpression", { ExpressionTensor(_lparen, exprs, _rparen) { return { kind: "expression_tensor", - expressions: exprs.asIteration().children.map(x => x.astOfExpression()), + expressions: exprs + .asIteration() + .children.map((x) => x.astOfExpression()), loc: createSrcInfo(this), }; }, @@ -1836,19 +1978,22 @@ semantics.addOperation("astOfExpression", { kind: "expression_tuple", expressions: [], loc: createSrcInfo(this), - } + }; }, ExpressionTuple(_lparen, exprs, _rparen) { return { kind: "expression_tuple", - expressions: exprs.asIteration().children.map(x => x.astOfExpression()), + expressions: exprs + .asIteration() + .children.map((x) => x.astOfExpression()), loc: createSrcInfo(this), }; }, integerLiteral(optNegate, numLit) { - const negate = unwrapOptNode(optNegate, t => t.sourceString); - const value = (negate === undefined ? 1n : -1n) * BigInt(numLit.sourceString); - + const negate = unwrapOptNode(optNegate, (t) => t.sourceString); + const value = + (negate === undefined ? 1n : -1n) * BigInt(numLit.sourceString); + return { kind: "integer_literal", value: value, @@ -1883,20 +2028,24 @@ semantics.addOperation("astOfExpression", { return { kind: "string_singleline", value: contents.sourceString, - ty: unwrapOptNode(optTy, t => t.sourceString) as (FuncStringType | undefined), + ty: unwrapOptNode(optTy, (t) => t.sourceString) as + | FuncStringType + | undefined, loc: createSrcInfo(this), - } + }; }, stringLiteral_multiLine(_lquote, contents, _rquote, optTy) { return { kind: "string_multiline", value: contents.sourceString, - ty: unwrapOptNode(optTy, t => t.sourceString) as (FuncStringType | undefined), + ty: unwrapOptNode(optTy, (t) => t.sourceString) as + | FuncStringType + | undefined, loc: createSrcInfo(this), - } + }; }, functionId(optPrefix, rawId) { - const prefix = unwrapOptNode(optPrefix, t => t.sourceString); + const prefix = unwrapOptNode(optPrefix, (t) => t.sourceString); if (prefix === undefined) { return rawId.astOfExpression(); @@ -1904,7 +2053,7 @@ semantics.addOperation("astOfExpression", { return { kind: "method_id", - prefix: prefix as ("." | "~"), + prefix: prefix as "." | "~", value: (rawId.astOfExpression() as FuncAstId).value, loc: createSrcInfo(this), }; @@ -1912,10 +2061,10 @@ semantics.addOperation("astOfExpression", { methodId(prefix, rawId) { return { kind: "method_id", - prefix: prefix.sourceString as ("." | "~"), + prefix: prefix.sourceString as "." | "~", value: (rawId.astOfExpression() as FuncAstId).value, loc: createSrcInfo(this), - } + }; }, id(rawId) { return rawId.astOfExpression(); @@ -1928,21 +2077,21 @@ semantics.addOperation("astOfExpression", { kind: "quoted_id", value: [ltick, idContents.sourceString, rtick].join(""), loc: createSrcInfo(this), - } + }; }, operatorId(opId) { return opId.astOfExpression(); }, operatorId_common(optCaret, underscore1, op, underscore2) { const value = [ - unwrapOptNode(optCaret, t => t.sourceString) ?? "", - underscore1, op, underscore2, + unwrapOptNode(optCaret, (t) => t.sourceString) ?? "", + underscore1, + op, + underscore2, ].join(""); return { - kind: checkOperatorId(value) - ? "operator_id" - : "plain_id", + kind: checkOperatorId(value) ? "operator_id" : "plain_id", value: value, loc: createSrcInfo(this), }; @@ -1967,14 +2116,14 @@ semantics.addOperation("astOfExpression", { kind: "plain_id", value: value, loc: createSrcInfo(this), - } + }; }, unusedId(underscore) { return { kind: "unused_id", value: underscore.sourceString as "_", loc: createSrcInfo(this), - } + }; }, }); @@ -1989,14 +2138,14 @@ semantics.addOperation("astOfVarDeclPart", { ExpressionTensorVarDecl(_lparen, ids, _rparen) { return { kind: "expression_tensor_var_decl", - names: ids.asIteration().children.map(x => x.astOfIdOrUnusedId()), + names: ids.asIteration().children.map((x) => x.astOfIdOrUnusedId()), loc: createSrcInfo(this), }; }, ExpressionTupleVarDecl(_lbrack, ids, _rbrack) { return { kind: "expression_tuple_var_decl", - names: ids.asIteration().children.map(x => x.astOfIdOrUnusedId()), + names: ids.asIteration().children.map((x) => x.astOfIdOrUnusedId()), loc: createSrcInfo(this), }; }, @@ -2008,17 +2157,35 @@ semantics.addOperation("astOfIdOrUnusedId", { }); // Miscellaneous utility nodes, gathered together for convenience -// +// // A couple of them don't even have their own dedicated TypeScript types, // and most were introduced mostly for parsing convenience // op? decNum (. decNum)? (. decNum)? semantics.addOperation("astOfVersionRange", { - versionRange(optOp, majorVers, _optDot, optMinorVers, _optDot2, optPatchVers) { - const op = unwrapOptNode(optOp, t => t.sourceString) as ("=" | "^" | "<=" | ">=" | "<" | ">" | undefined); + versionRange( + optOp, + majorVers, + _optDot, + optMinorVers, + _optDot2, + optPatchVers, + ) { + const op = unwrapOptNode(optOp, (t) => t.sourceString) as + | "=" + | "^" + | "<=" + | ">=" + | "<" + | ">" + | undefined; const major = majorVers.astOfExpression() as FuncAstIntegerLiteral; - const minor = unwrapOptNode(optMinorVers, t => t.astOfExpression()) as (FuncAstIntegerLiteral | undefined); - const patch = unwrapOptNode(optPatchVers, t => t.astOfExpression()) as (FuncAstIntegerLiteral | undefined); + const minor = unwrapOptNode(optMinorVers, (t) => + t.astOfExpression(), + ) as FuncAstIntegerLiteral | undefined; + const patch = unwrapOptNode(optPatchVers, (t) => + t.astOfExpression(), + ) as FuncAstIntegerLiteral | undefined; return { kind: "version_range", op: op, @@ -2026,7 +2193,7 @@ semantics.addOperation("astOfVersionRange", { minor: minor?.value, patch: patch?.value, loc: createSrcInfo(this), - } + }; }, }); @@ -2036,10 +2203,18 @@ semantics.addOperation("astOfGlobalVariable", { const name = globName.astOfExpression() as FuncAstId; // if a plainId, then check for validity if (name.kind === "plain_id") { - checkPlainId(name.value, createSrcInfo(this), "Name of the global variable"); + checkPlainId( + name.value, + createSrcInfo(this), + "Name of the global variable", + ); } // check that it can be declared (also excludes operatorId and unusedId) - checkDeclaredId(name.value, createSrcInfo(this), "Name of the global variable"); + checkDeclaredId( + name.value, + createSrcInfo(this), + "Name of the global variable", + ); // and that it's not a methodId if (name.kind === "method_id") { throwFuncSyntaxError( @@ -2050,8 +2225,8 @@ semantics.addOperation("astOfGlobalVariable", { // leaving only quotedId or plainId return { kind: "global_variable", - ty: unwrapOptNode(optGlobTy, t => t.astOfType()), - name: name as (FuncAstQuotedId | FuncAstPlainId), + ty: unwrapOptNode(optGlobTy, (t) => t.astOfType()), + name: name as FuncAstQuotedId | FuncAstPlainId, loc: createSrcInfo(this), }; }, @@ -2060,14 +2235,22 @@ semantics.addOperation("astOfGlobalVariable", { // (slice | int)? id = Expression semantics.addOperation("astOfConstant", { ConstantDefinition(optConstTy, constName, _eqSign, expr) { - const ty = unwrapOptNode(optConstTy, t => t.sourceString); + const ty = unwrapOptNode(optConstTy, (t) => t.sourceString); const name = constName.astOfExpression() as FuncAstId; // if a plainId, then check for validity if (name.kind === "plain_id") { - checkPlainId(name.value, createSrcInfo(this), "Name of the constant"); + checkPlainId( + name.value, + createSrcInfo(this), + "Name of the constant", + ); } // check that it can be declared (also excludes operatorId and unusedId) - checkDeclaredId(name.value, createSrcInfo(this), "Name of the constant"); + checkDeclaredId( + name.value, + createSrcInfo(this), + "Name of the constant", + ); // and that it's not a methodId if (name.kind === "method_id") { throwFuncSyntaxError( @@ -2077,8 +2260,8 @@ semantics.addOperation("astOfConstant", { } return { kind: "constant", - ty: ty !== undefined ? ty as ("slice" | "int") : undefined, - name: name as (FuncAstQuotedId | FuncAstPlainId), + ty: ty !== undefined ? (ty as "slice" | "int") : undefined, + name: name as FuncAstQuotedId | FuncAstPlainId, value: expr.astOfExpression(), loc: createSrcInfo(this), }; @@ -2100,16 +2283,26 @@ semantics.addOperation("astOfFunctionCommonPrefix", { const name = fnName.astOfExpression() as FuncAstId; // if a plainId, then check for validity if (name.kind === "plain_id") { - checkPlainId(name.value, createSrcInfo(this), "Name of the function"); + checkPlainId( + name.value, + createSrcInfo(this), + "Name of the function", + ); } // check that it can be declared (also excludes operatorId and unusedId) - checkDeclaredId(name.value, createSrcInfo(this), "Name of the function"); + checkDeclaredId( + name.value, + createSrcInfo(this), + "Name of the function", + ); return { - forall: unwrapOptNode(optForall, t => t.astOfForall()), + forall: unwrapOptNode(optForall, (t) => t.astOfForall()), returnTy: retTy.astOfType(), - name: name as (FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId), + name: name as FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId, parameters: fnParams.astOfParameters(), - attributes: fnAttributes.children.map(x => x.astOfFunctionAttribute()), + attributes: fnAttributes.children.map((x) => + x.astOfFunctionAttribute(), + ), }; }, }); @@ -2119,16 +2312,16 @@ semantics.addOperation("astOfForall", { Forall(_forallKwd, _space1, typeVars, _space2, _mapsToKwd, _space3) { return { kind: "forall", - tyVars: typeVars.asIteration().children.map(x => x.astOfType()), + tyVars: typeVars.asIteration().children.map((x) => x.astOfType()), loc: createSrcInfo(this), - } + }; }, }); // (Type? Id, ...) semantics.addOperation("astOfParameters", { Parameters(_lparen, params, _rparen) { - return params.asIteration().children.map(x => x.astOfParameter()); + return params.asIteration().children.map((x) => x.astOfParameter()); }, }); @@ -2138,7 +2331,10 @@ semantics.addOperation("astOfParameter", { return param.astOfParameter(); }, Parameter_regular(paramTy, optId) { - const name = unwrapOptNode(optId, t => t.astOfExpression() as FuncAstId); + const name = unwrapOptNode( + optId, + (t) => t.astOfExpression() as FuncAstId, + ); if (name === undefined) { return { kind: "parameter", @@ -2149,14 +2345,28 @@ semantics.addOperation("astOfParameter", { } // if a plainId, then check for validity if (name.kind === "plain_id") { - checkPlainId(name.value, createSrcInfo(this), "Name of the parameter"); + checkPlainId( + name.value, + createSrcInfo(this), + "Name of the parameter", + ); } // check that it can be declared (also excludes operatorId, but not unusedId) - checkDeclaredId(name.value, createSrcInfo(this), "Name of the parameter", true); + checkDeclaredId( + name.value, + createSrcInfo(this), + "Name of the parameter", + true, + ); return { kind: "parameter", ty: paramTy.astOfType(), - name: name as (FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId | FuncAstUnusedId | undefined), + name: name as + | FuncAstMethodId + | FuncAstQuotedId + | FuncAstPlainId + | FuncAstUnusedId + | undefined, loc: createSrcInfo(this), }; }, @@ -2164,14 +2374,22 @@ semantics.addOperation("astOfParameter", { const name = funId.astOfExpression() as FuncAstId; // if a plainId, then check for validity if (name.kind === "plain_id") { - checkPlainId(name.value, createSrcInfo(this), "Name of the parameter"); + checkPlainId( + name.value, + createSrcInfo(this), + "Name of the parameter", + ); } // check that it can be declared (also excludes operatorId and unusedId) - checkDeclaredId(name.value, createSrcInfo(this), "Name of the parameter"); + checkDeclaredId( + name.value, + createSrcInfo(this), + "Name of the parameter", + ); return { kind: "parameter", ty: undefined, - name: name as (FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId), + name: name as FuncAstMethodId | FuncAstQuotedId | FuncAstPlainId, loc: createSrcInfo(this), }; }, @@ -2197,7 +2415,7 @@ semantics.addOperation("astOfAsmArrangement", { AsmArrangement_arguments(_lparen, args, _rparen) { return { kind: "asm_arrangement", - arguments: args.children.map(x => x.astOfExpression()), + arguments: args.children.map((x) => x.astOfExpression()), returns: undefined, loc: createSrcInfo(this), }; @@ -2206,15 +2424,23 @@ semantics.addOperation("astOfAsmArrangement", { return { kind: "asm_arrangement", arguments: undefined, - returns: rets.children.map(x => x.astOfExpression()), + returns: rets.children.map((x) => x.astOfExpression()), loc: createSrcInfo(this), }; }, - AsmArrangement_argumentsToReturns(_lparen, args, _space, _mapsTo, _space1, rets, _rparen) { + AsmArrangement_argumentsToReturns( + _lparen, + args, + _space, + _mapsTo, + _space1, + rets, + _rparen, + ) { return { kind: "asm_arrangement", - arguments: args.children.map(x => x.astOfExpression()), - returns: rets.children.map(x => x.astOfExpression()), + arguments: args.children.map((x) => x.astOfExpression()), + returns: rets.children.map((x) => x.astOfExpression()), loc: createSrcInfo(this), }; }, @@ -2229,10 +2455,10 @@ semantics.addOperation("astOfFunctionAttribute", { kind: "method_id", value: undefined, loc: createSrcInfo(this), - } + }; } return { - kind: attr.sourceString as ("impure" | "inline_ref" | "inline"), + kind: attr.sourceString as "impure" | "inline_ref" | "inline", loc: createSrcInfo(this), }; } @@ -2246,17 +2472,20 @@ semantics.addOperation("astOfFunctionAttribute", { }); // method_id "(" Integer | String ")" -semantics.addOperation("astOfMethodIdValue", { - MethodIdValue(mtd) { - return mtd.astOfMethodIdValue(); - }, - MethodIdValue_int(_methodIdKwd, _lparen, intLit, _rparen) { - return intLit.astOfExpression() as FuncAstIntegerLiteral; - }, - MethodIdValue_string(_methodIdKwd, _lparen, strLit, _rparen) { - return strLit.astOfExpression() as FuncAstStringLiteral; - }, -}); +semantics.addOperation( + "astOfMethodIdValue", + { + MethodIdValue(mtd) { + return mtd.astOfMethodIdValue(); + }, + MethodIdValue_int(_methodIdKwd, _lparen, intLit, _rparen) { + return intLit.astOfExpression() as FuncAstIntegerLiteral; + }, + MethodIdValue_string(_methodIdKwd, _lparen, strLit, _rparen) { + return strLit.astOfExpression() as FuncAstStringLiteral; + }, + }, +); // All the types, united under FuncAstType semantics.addOperation("astOfType", { @@ -2279,7 +2508,7 @@ semantics.addOperation("astOfType", { hole(node) { return { kind: "hole", - value: node.sourceString as ("var" | "_"), + value: node.sourceString as "var" | "_", loc: createSrcInfo(this), }; }, @@ -2295,10 +2524,10 @@ semantics.addOperation("astOfType", { kind: "type_tuple", types: [], loc: createSrcInfo(this), - } + }; }, TypeGlob(globBiTy, _optMapsTo, optGlobTy) { - const mapsTo = unwrapOptNode(optGlobTy, t => t.astOfType()); + const mapsTo = unwrapOptNode(optGlobTy, (t) => t.astOfType()); if (mapsTo !== undefined) { return { kind: "type_mapped", @@ -2325,19 +2554,19 @@ semantics.addOperation("astOfType", { TensorGlob(_lparen, globTys, _rparen) { return { kind: "type_tensor", - types: globTys.asIteration().children.map(x => x.astOfType()), + types: globTys.asIteration().children.map((x) => x.astOfType()), loc: createSrcInfo(this), }; }, TupleGlob(_lbrack, globTys, _rbrack) { return { kind: "type_tuple", - types: globTys.asIteration().children.map(x => x.astOfType()), + types: globTys.asIteration().children.map((x) => x.astOfType()), loc: createSrcInfo(this), }; }, TypeVar(optTypeKwd, _space, typeVar) { - const typeKwd = unwrapOptNode(optTypeKwd, t => t.sourceString); + const typeKwd = unwrapOptNode(optTypeKwd, (t) => t.sourceString); return { kind: "type_var", keyword: typeKwd !== undefined ? true : false, @@ -2346,7 +2575,7 @@ semantics.addOperation("astOfType", { }; }, TypeReturn(retBiTy, _space1, _optMapsTo, _space2, optRetTy) { - const mapsTo = unwrapOptNode(optRetTy, t => t.astOfType()); + const mapsTo = unwrapOptNode(optRetTy, (t) => t.astOfType()); if (mapsTo !== undefined) { return { kind: "type_mapped", @@ -2378,19 +2607,19 @@ semantics.addOperation("astOfType", { TensorReturn(_lparen, retTys, _rparen) { return { kind: "type_tensor", - types: retTys.asIteration().children.map(x => x.astOfType()), + types: retTys.asIteration().children.map((x) => x.astOfType()), loc: createSrcInfo(this), }; }, TupleReturn(_lparen, retTys, _rparen) { return { kind: "type_tuple", - types: retTys.asIteration().children.map(x => x.astOfType()), + types: retTys.asIteration().children.map((x) => x.astOfType()), loc: createSrcInfo(this), }; }, TypeParameter(paramBiTy, _space1, _optMapsTo, _space2, optRetTy) { - const mapsTo = unwrapOptNode(optRetTy, t => t.astOfType()); + const mapsTo = unwrapOptNode(optRetTy, (t) => t.astOfType()); if (mapsTo !== undefined) { return { kind: "type_mapped", @@ -2414,19 +2643,19 @@ semantics.addOperation("astOfType", { TensorParameter(_lparen, retTys, _rparen) { return { kind: "type_tensor", - types: retTys.asIteration().children.map(x => x.astOfType()), + types: retTys.asIteration().children.map((x) => x.astOfType()), loc: createSrcInfo(this), }; }, TupleParameter(_lparen, retTys, _rparen) { return { kind: "type_tuple", - types: retTys.asIteration().children.map(x => x.astOfType()), + types: retTys.asIteration().children.map((x) => x.astOfType()), loc: createSrcInfo(this), }; }, TypeVarDecl(varDeclBiTy, _space1, _optMapsTo, _space2, optRetTy) { - const mapsTo = unwrapOptNode(optRetTy, t => t.astOfType()); + const mapsTo = unwrapOptNode(optRetTy, (t) => t.astOfType()); if (mapsTo !== undefined) { return { kind: "type_mapped", @@ -2457,14 +2686,14 @@ semantics.addOperation("astOfType", { TensorVarDecl(_lparen, varDeclTys, _rparen) { return { kind: "type_tensor", - types: varDeclTys.asIteration().children.map(x => x.astOfType()), + types: varDeclTys.asIteration().children.map((x) => x.astOfType()), loc: createSrcInfo(this), }; }, TupleVarDecl(_lparen, varDeclTys, _rparen) { return { kind: "type_tuple", - types: varDeclTys.asIteration().children.map(x => x.astOfType()), + types: varDeclTys.asIteration().children.map((x) => x.astOfType()), loc: createSrcInfo(this), }; }, @@ -2473,7 +2702,7 @@ semantics.addOperation("astOfType", { // Not a standalone statement, produces a list of statements instead semantics.addOperation("astOfElseBlock", { ElseBlock(_elseKwd, _lbrace, stmts, _rbrace) { - return stmts.children.map(x => x.astOfStatement()); + return stmts.children.map((x) => x.astOfStatement()); }, }); From 43e1c4c261b48e3aae9444ac99717fa90643c975 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Sun, 11 Aug 2024 14:05:41 +0200 Subject: [PATCH 106/162] chore(func-parser): spelling --- cspell.json | 14 ++++++++++++++ src/func/grammar.ts | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cspell.json b/cspell.json index 300167f87..4fa1521d8 100644 --- a/cspell.json +++ b/cspell.json @@ -33,12 +33,20 @@ "jettons", "jsxdev", "langle", + "lbrack", "lparen", + "lquote", + "ltick", "lvalue", "masterchain", "maxint", "minmax", "mintable", + "moddiv", + "muldiv", + "muldivc", + "muldivmod", + "muldivr", "multiformats", "Korshakov", "nocheck", @@ -50,8 +58,12 @@ "Parens", "POSIX", "prando", + "qmark", "rangle", + "rbrack", "rparen", + "rquote", + "rtick", "rugpull", "rugpulled", "sctx", @@ -59,6 +71,7 @@ "shiki", "Stateinit", "stdlib", + "stdump", "struct", "structs", "subtyping", @@ -86,6 +99,7 @@ "examples/__snapshots__/multisig-3.spec.ts.snap", "/func", "scripts/func", + "src/func/__snapshots__/*", "src/func/grammar.ohm*", "src/func/funcfiftlib*", "src/func/grammar-test/*", diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 47564c212..3e8d6baff 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -88,7 +88,7 @@ function locationStr(sourceInfo: FuncSrcInfo): string { } /** - * Throws a FunC parse error occured in the given `path` file + * Throws a FunC parse error occurred in the given `path` file */ export function throwFuncParseError( matchResult: MatchResult, @@ -106,7 +106,7 @@ export function throwFuncParseError( } /** - * Throws a FunC syntax error occcured with the given `source` + * Throws a FunC syntax error occurred with the given `source` */ export function throwFuncSyntaxError( message: string, From e69cd14cad94f445d2b7bd253df7ffb387e171f6 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 12 Aug 2024 04:11:55 +0000 Subject: [PATCH 107/162] fix(generator): Fix compilation errors --- src/codegen/generator.ts | 46 ++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 5400a0d66..1d0c0c32a 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -7,7 +7,11 @@ import { WriterContext, ModuleGen, WrittenFunction } from "."; import { getRawAST } from "../grammar/store"; import { ContractABI } from "@ton/core"; import { FuncFormatter } from "../func/formatter"; -import { FuncAstModule, FuncAstComment } from "../func/syntax"; +import { + FuncAstModule, + FuncAstFunctionDefinition, + FuncAstAsmFunction, +} from "../func/syntax"; import { deepCopy } from "../func/syntaxUtils"; import { comment, @@ -112,9 +116,7 @@ export class FuncGenerator { // TODO // Finalize and dump the main contract, as we have just obtained the structure of the project - m.entries.unshift( - ...generated.files.map((f) => include(f.name)), - ); + m.entries.unshift(...generated.files.map((f) => include(f.name))); m.entries.unshift( ...[ `version =${CODEGEN_FUNC_VERSION}`, @@ -168,6 +170,7 @@ export class FuncGenerator { functions.forEach((f) => { if ( f.kind === "generic" && + f.definition !== undefined && f.definition.kind === "function_definition" ) { m.entries.push( @@ -214,7 +217,9 @@ export class FuncGenerator { if (stdlibFunctions) { generated.imported.push("stdlib"); } - stdlibFunctions.forEach((f) => m.entries.push(f.definition)); + stdlibFunctions.forEach((f) => { + if (f.definition !== undefined) m.entries.push(f.definition); + }); generated.files.push({ name: `${this.basename}.stdlib.fc`, code: new FuncFormatter().dump(m), @@ -246,7 +251,19 @@ export class FuncGenerator { generated.files.push({ name: `${this.basename}.constants.fc`, code: new FuncFormatter().dump( - mod(...constantsFunctions.map((v) => v.definition)), + mod( + ...constantsFunctions.reduce( + (acc, v) => { + if (v.definition !== undefined) + acc.push(v.definition); + return acc; + }, + [] as ( + | FuncAstFunctionDefinition + | FuncAstAsmFunction + )[], + ), + ), ), }); } @@ -299,7 +316,22 @@ export class FuncGenerator { comments.push(""); } generatedModules.push( - mod(...[comment(...comments), ...ffs.map((f) => f.definition)]), + mod( + ...[ + comment(...comments), + ...ffs.reduce( + (acc, f) => { + if (f.definition !== undefined) + acc.push(f.definition); + return acc; + }, + [] as ( + | FuncAstFunctionDefinition + | FuncAstAsmFunction + )[], + ), + ], + ), ); } if (generatedModules.length > 0) { From dd7cf6ceb9ddf2c545874ed0140f07c028840139 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 12 Aug 2024 04:39:23 +0000 Subject: [PATCH 108/162] feat(grammar): Add dummy definitions --- src/func/grammar.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 3e8d6baff..77866c788 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -2,6 +2,8 @@ import { Interval as RawInterval, IterationNode, MatchResult, + grammar, + Grammar, Node, } from "ohm-js"; import path from "path"; @@ -41,6 +43,14 @@ export class FuncSrcInfo { } } +// Dummy definitions needed to generate AST programmatically. +const DummyGrammar: Grammar = grammar("Dummy { DummyRule = any }"); +const DUMMY_INTERVAL = DummyGrammar.match("").getInterval(); +export const dummySrcInfo: FuncSrcInfo = new FuncSrcInfo( + DUMMY_INTERVAL, + undefined, +); + /** * Generic FunC error in FunC parser */ From 804ab800d0ab648e25095aee9e4137ad1bc92256 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 12 Aug 2024 04:39:42 +0000 Subject: [PATCH 109/162] chore(grammar): Extract type --- src/func/grammar.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 77866c788..c832a2c73 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -525,12 +525,14 @@ export type FuncAstPragma = | FuncAstPragmaVersionRange | FuncAstPragmaVersionString; +export type FuncAstPragmaLiteralValue = "allow-post-modification" | "compute-asm-ltr"; + /** * #pragma something-something-something; */ export type FuncAstPragmaLiteral = { kind: "pragma_literal"; - literal: "allow-post-modification" | "compute-asm-ltr"; + literal: FuncAstPragmaLiteralValue; loc: FuncSrcInfo; }; From a3eee3acff0d4845a40c266852b8a08e2e188320 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:23:39 +0200 Subject: [PATCH 110/162] chore(func-parser): remove redundant snapshots and rename couple things in `grammar.ts`' --- src/func/__snapshots__/grammar.spec.ts.snap | 128586 ----------------- src/func/grammar.spec.ts | 9 +- src/func/grammar.ts | 12 +- 3 files changed, 13 insertions(+), 128594 deletions(-) diff --git a/src/func/__snapshots__/grammar.spec.ts.snap b/src/func/__snapshots__/grammar.spec.ts.snap index 5db776434..8ca5d446b 100644 --- a/src/func/__snapshots__/grammar.spec.ts.snap +++ b/src/func/__snapshots__/grammar.spec.ts.snap @@ -236,128589 +236,3 @@ Line 1, col 9: 2 | " `; - -exports[`FunC grammar and parser should parse __tact_crc16 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "include_stdlib.fc", - }, - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_crc16", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_data", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "s", - "value": "0000", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_data_empty?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_data", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "byte", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mask", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mask", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reg", - }, - "loc": FuncSrcInfo {}, - "op": "<<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "byte", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mask", - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reg", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mask", - }, - "loc": FuncSrcInfo {}, - "op": ">>=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reg", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 65535n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reg", - }, - "loc": FuncSrcInfo {}, - "op": "&=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 65535n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reg", - }, - "loc": FuncSrcInfo {}, - "op": "^=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4129n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reg", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "divmod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse __tact_debug 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "include_stdlib.fc", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STRDUMP", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DROP", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "s0 DUMP", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DROP", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_debug", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "debug_print", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse __tact_load_address 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "include_stdlib.fc", - }, - }, - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "__tact_verify_address.fc", - }, - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_load_address", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_msg_addr", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_verify_address", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse __tact_load_address_opt 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "include_stdlib.fc", - }, - }, - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "__tact_verify_address.fc", - }, - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_load_address_opt", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - ], - }, - "statements": [ - { - "alternatives": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_msg_addr", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_verify_address", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse __tact_load_bool 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "include_stdlib.fc", - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "1 LDI", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_load_bool", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse __tact_store_address 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "include_stdlib.fc", - }, - }, - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "__tact_verify_address.fc", - }, - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_store_address", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_verify_address", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse __tact_store_address_opt 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "include_stdlib.fc", - }, - }, - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "__tact_store_address.fc", - }, - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_store_address_opt", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - "statements": [ - { - "alternatives": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_store_address", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null?", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse __tact_verify_address 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "include_stdlib.fc", - }, - }, - { - "constants": [ - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "INVALID_ADDRESS", - }, - "ty": "int", - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 136n, - }, - }, - ], - "kind": "constants_definition", - "loc": FuncSrcInfo {}, - }, - { - "constants": [ - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "MC_NOT_ENABLED", - }, - "ty": "int", - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 137n, - }, - }, - ], - "kind": "constants_definition", - "loc": FuncSrcInfo {}, - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_verify_address", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "INVALID_ADDRESS", - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 267n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "h", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 11n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "MC_NOT_ENABLED", - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "h", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1279n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "INVALID_ADDRESS", - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "h", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1024n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_verify_address_masterchain", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "INVALID_ADDRESS", - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 267n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "h", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 11n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "INVALID_ADDRESS", - }, - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "h", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1024n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "h", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1279n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "address", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse asm-functions 1`] = ` -{ - "items": [ - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "INC NEGATE", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_then_negate", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "INC", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NEGATE", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_then_negate'", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "INC NEGATE", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_then_negate''", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": " - "Hello" - " " - "World" - $+ $+ $>s - PUSHSLICE -", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hello_world", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "INC", - }, - { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": " - NEGATE -", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_then_negate'''", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STUXQ", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_uint_quiet", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STUXQ", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_uint_quiet'", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STUXQ", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_uint_quiet''", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STUXQ", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_uint_quiet'''", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "UNSINGLE", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unsingle", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse constants 1`] = ` -{ - "items": [ - { - "constants": [ - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c1", - }, - "ty": undefined, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - }, - ], - "kind": "constants_definition", - "loc": FuncSrcInfo {}, - }, - { - "constants": [ - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c2", - }, - "ty": undefined, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 27n, - }, - }, - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c3", - }, - "ty": undefined, - "value": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c1", - }, - }, - ], - "kind": "constants_definition", - "loc": FuncSrcInfo {}, - }, - { - "constants": [ - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c4", - }, - "ty": "int", - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c5", - }, - "ty": undefined, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c6", - }, - "ty": "slice", - "value": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "s", - "value": "It's Zendaya", - }, - }, - ], - "kind": "constants_definition", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse dns-auto-code 1`] = ` -{ - "items": [ - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUGETOPTREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_ref_", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_prices", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dd", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tuple_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sp", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dd", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sp", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_info", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tag", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "body", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 24n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tag", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "body", - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "body", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "error_code", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_info", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "error_code", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_ok", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw_reserve", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_info", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4016791929n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "housekeeping", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dd", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_steps", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 60n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dd", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mkey", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_min?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_steps", - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mkey", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mkey", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "%", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dd", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_delete?", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dd", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_delete?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mkey", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_min?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "alternative": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4294967295n, - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - "consequence": { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mkey", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": ">>", - }, - ], - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_steps", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dd", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "calcprice_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 100n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_data_size", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_bits", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_owner", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_info", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "strict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "strict", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4000281702n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_info", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "strict", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4000263474n, - }, - "op": "&", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ERR_BAD2", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3798033458n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sown", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_info", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sown", - }, - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "+", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ERR_BAD2", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sown", - }, - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 40915n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ERR_BAD2", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_wc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sown", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sown", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_wc", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_addr", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4000282478n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "perform_ctl_op", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4000282478n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1130909810n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_ok", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_info", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1128555884n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "housekeeping", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4000605549n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4016791929n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1415670629n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4016791929n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4294967295n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg_cell", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_msg_addr", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "parse_std_addr", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_info", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 31n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 24n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 67n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "perform_ctl_op", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1919248228n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1886547820n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1970300004n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1735354211n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4294967295n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_steps", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_steps", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "housekeeping", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4016791929n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain_cell", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_maybe_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fail", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_bits_refs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fail", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bytes", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fail", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bytes", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bytes", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "*", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fail", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fail", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_last", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fail", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4000275504n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_info", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": "^>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "skip_last_bits", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "string_hash", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cown", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_ref?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_info", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cown", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4017511472n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "owner_info", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_owner", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "dict_empty?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "oinfo", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_ref?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "oinfo", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 31n, - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "+", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 31n, - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 19n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 40915n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "minok", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_min?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "maxok", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_max?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 31n, - }, - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "minok", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "maxok", - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tuple_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3545187910n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "calcprice_internal", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3883023472n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "req_expires_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - "op": "+", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4083511919n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gckeyO", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gckeyN", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gckeyO", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_delete?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gckeyO", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gckeyN", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "housekeeping", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_ok", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3781980773n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_error", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expires_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expires_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gckey", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expires_at", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "op": "|", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gckey", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expires_at", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "housekeeping", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_ok", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qt", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domdata", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "housekeeping", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_ok", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dd", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nhk", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lhk", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ctl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dd", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "gc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prices", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4294967295n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dnsdictlookup", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nowtime", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain_last_byte", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_last", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain_last_byte", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain_first_byte", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain_first_byte", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail_bits", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "skip_last_bits", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "string_hash", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "-", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nowtime", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail_bits", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail_bits", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "skip_last_bits", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail_bits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dnsresolve", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "category", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exact?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dnsdictlookup", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exact?", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exact?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "category", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "H", - "value": "dns_next_resolver", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx_bits", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_found", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_ref_", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "category", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx_bits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "category", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx_bits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "getexpirationx", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nowtime", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nowtime", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dnsdictlookup", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exp", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "getexpiration", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "getexpirationx", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "getstdperiod", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_prices", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stdper", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "getppr", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_prices", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "getppc", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_prices", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "getppb", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_prices", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "calcprice", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_prices", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "calcprice_internal", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "calcregprice", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_prices", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppr", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "domain", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ppb", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "calcprice_internal", - }, - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse dns-manual-code 1`] = ` -{ - "items": [ - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUGETOPTREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_ref_", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfxdict_set_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "pfxdict_set?", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_maybe_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfxdict_get_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "succ", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "pfxdict_get?", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "alternative": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "succ", - }, - "consequence": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_maybe_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "succ", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "contract_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "contract_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg_cell", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1666n, - }, - }, - ], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "after_code_upgrade", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_code", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cont", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "process_op", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 10n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_code", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_code", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_code", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_code", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_c3", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "bless", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_code", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_c3", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_code", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "after_code_upgrade", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 45n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 20n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "is_name_ref", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "*", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name_len", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "is_name_ref", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 38n, - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name_last_byte", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_last", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 40n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name_last_byte", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cname", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cname", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": "^>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cname", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 20n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "succ", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "pfxdict_get_ref", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1023n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "succ", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_empty?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 11n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_maybe_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_get_ref", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_value", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "pfxdict_set_ref", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1023n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 12n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_delete?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "pfxdict_set_ref", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1023n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 21n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_cat_table", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_maybe_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "pfxdict_set_ref", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1023n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_cat_table", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 22n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "pfxdict_delete?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1023n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 31n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_tree_root", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_maybe_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_tree_root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 44n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "process_ops", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stop", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stop", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "process_op", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_data_empty?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stop", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "contract_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "shash", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_contract", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bound", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bound", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "contract_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_contract", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "shash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "process_ops", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 51n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bound", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "queries", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries'", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_delete_get_min", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bound", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries'", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "contract_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1666n, - }, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "after_code_upgrade", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ops", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_code", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cont", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_contract_id", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dnsresolve", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subdomain", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "category", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subdomain", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name_last_byte", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_last", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subdomain", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name_last_byte", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subdomain", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subdomain", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name_first_byte", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subdomain", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "name_first_byte", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subdomain", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cname", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subdomain", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cname", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cname", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cname", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfxname", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subdomain", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "succ", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "pfxdict_get_ref", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1023n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfxname", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "root", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "succ", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "^", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "zeros", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_empty?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "category", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "H", - "value": "dns_next_resolver", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx_bits", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_bits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_found", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_ref_", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "category", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx_bits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "category", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfx_bits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cat_table", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse elector-code 1`] = ` -{ - "items": [ - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_elect", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "es", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "es", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "es", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "es", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "es", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "es", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "es", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "es", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "es", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_elect", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_past_election", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_past_election", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_complaint_status", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 45n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_complaint_status", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 45n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_complaint", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 188n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "-", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_complaint", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "description", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "created_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "severity", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine_part", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 188n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "-", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "description", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "created_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "severity", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine_part", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_complaint_prices", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "info", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "info", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 26n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_complaint_prices", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "info", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 13n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "alternative": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "parse_complaint_prices", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "info", - }, - }, - "condition": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "info", - }, - }, - "consequence": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 36n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_validator_conf", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 15n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_current_vset", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_parse", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 40n, - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 18n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_weight", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_weight", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_validator_descr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_weight", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_current_vset", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_weight", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_validator_descr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 41n, - }, - { - "kind": "expression_compare", - "left": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 83n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 41n, - }, - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2390828938n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ans_tag", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "body", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 24n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ans_tag", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "body", - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "body", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stake", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reason", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4000269644n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reason", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_confirmation", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "comment", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4084484172n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "comment", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1000000000n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_validator_set_to_config", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 50431n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 17n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1314280276n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "credit_to", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "process_new_stake", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_std_addr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_at", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1699500148n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_data_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 65536n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_elect", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1000000000n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 12n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_at", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mem", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mem", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mem", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mem", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 5n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 44n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_confirmation", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_without_bonuses", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "freeze_dict", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stakes", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recovered", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_next?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "freeze_dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "banned", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "credit_to", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "banned", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recovered", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 59n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stakes", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recovered", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_with_bonuses", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "freeze_dict", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stakes", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_bonuses", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recovered", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "returned_bonuses", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_next?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "freeze_dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "banned", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonus", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stakes", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldiv", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ed_bonuses", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonus", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "credit_to", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonus", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "banned", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recovered", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 59n, - }, - { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stakes", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "returned_bonuses", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_bonuses", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recovered", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_bonuses", - }, - "op": "+", - }, - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "returned_bonuses", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stakes_sum", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_next?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_all", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_id", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_delete_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fdict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stakes", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_past_election", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unused_prizes", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "alternative": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "unfreeze_without_bonuses", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fdict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stakes", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequence": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "unfreeze_with_bonuses", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fdict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stakes", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unused_prizes", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_set_confirmed", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_std_addr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_addr", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_addr", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - { - "expr": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_elect", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unused_prizes", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_all", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unused_prizes", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "process_simple_transfer", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_std_addr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_past_election", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_past_election", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recover_stake", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_std_addr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4294967294n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_delete_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4294967294n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 24n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4184830756n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1666n, - }, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "after_code_upgrade", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1313042276n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3460525924n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "upgrade_code", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c_addr", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c_addr", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_addr", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c_addr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_std_addr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_addr", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "code", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "code", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_code", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_empty?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "bless", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "code", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_c3", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "after_code_upgrade", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "register_complaint", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_std_addr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_wc", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_depth", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -3n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -2n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_in", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_in", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -4n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "description", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "created_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "severity", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine_part", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_complaint", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward_addr", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "created_at", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "deposit", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bit_price", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cell_price", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_complaint_prices", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4096n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_compute_data_size", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pps", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1024n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bit_price", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cell_price", - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pps", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_in", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "deposit", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -5n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "description", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "created_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "severity", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine_part", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_complaint", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_past_election", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -6n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine_part", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldiv", - }, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_stake", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -7n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -8n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cstatus", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_complaint_status", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cpl_id", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "cell_hash", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_add_builder?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cpl_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cstatus", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -9n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_past_election", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "punish", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "description", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "created_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "severity", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine_part", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_complaint", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "banned", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "suggested_fine_part", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldiv", - }, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "banned", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": ">>", - }, - ], - }, - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "*", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "credit_to", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reward", - }, - "op": "-", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "register_vote", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "chash", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cstatus", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "chash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_vset", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_weight", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_current_vset", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_vset_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "cell_hash", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_vset", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cstatus", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_complaint_status", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_old?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_id", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_vset_id", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_old?", - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_old?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_id", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_vset_id", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_weight", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldiv", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_wr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_wr", - }, - "loc": FuncSrcInfo {}, - "op": "^=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "chash", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_complaint_status", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_wr", - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "proceed_register_vote", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "chash", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -2n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_past_election", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accepted_complaint", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "status", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "chash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "register_vote", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "status", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "status", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accepted_complaint", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine_unalloc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine_collected", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accepted_complaint", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "punish", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine_unalloc", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fine_collected", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_past_election", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "status", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg_cell", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_msg_addr", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_empty?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "process_simple_transfer", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "process_simple_transfer", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1316189259n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "process_new_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1197831204n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recover_stake", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1313042276n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "upgrade_code", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "alternative": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4294967295n, - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - "consequence": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3460525924n, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cfg_ok", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4000730955n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cfg_ok", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4000730991n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cfg_ok", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_set_confirmed", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1382499184n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "register_complaint", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ans_tag", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "price", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw_reserve", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ans_tag", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ans_tag", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4066861904n, - }, - "op": "+", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1450460016n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_body", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sign_tag", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "chash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 37n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sign_tag", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1450459984n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vdescr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_weight", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_validator_descr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val_pubkey", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vdescr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_validator_descr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_body", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val_pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_data_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "chash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idx", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "proceed_register_vote", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3597947456n, - }, - "op": "+", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 31n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4294967295n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_message_back", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "postpone_elections", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_total_stake", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m_stake", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "h", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "uncons", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "at", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "h", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "at", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "h", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_f", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m_stake", - }, - "op": "*", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "try_elect", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_stake", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_total_stake", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_stake_factor", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "calls": [ - { - "argument": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "config_param", - }, - }, - { - "argument": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - }, - ], - "kind": "expression_method", - "loc": FuncSrcInfo {}, - "object": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_validators", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_validators", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_validators", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_validators", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sdict", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_next?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "time", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "time", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "dict_set_builder", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "+", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_stake_factor", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sdict", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_validators", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_validators", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_dict", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_dict", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nil", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "dict::delete_get_min", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sdict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_f", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_f", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cons", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_validators", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l1", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l1", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l1", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cdr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "best_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "list_next", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "at", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l1", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_total_stake", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "best_stake", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "best_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "best_stake", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_total_stake", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_dict", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_dict", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l1", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l1", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l1", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cdr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m_stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l1", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "at", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "car", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_weight", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tuple_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_f", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "list_next", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 61n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true_stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_f", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m_stake", - }, - "op": "*", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true_stake", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true_stake", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 60n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "best_stake", - }, - "op": "/", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true_stake", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_weight", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vinfo", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "alternative": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 83n, - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - "consequence": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 115n, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2390828938n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vinfo", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vinfo", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pubkey", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true_stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "credit_to", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "src_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 49n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "best_stake", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_weight", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tot_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "conduct_elections", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_elect", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "postpone_elections", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 17n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_total_stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_stake_factor", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_total_stake", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "postpone_elections", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "postpone_elections", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vdict", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_weight", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stakes", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cnt", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_stake_factor", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "try_elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cnt", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cnt", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "postpone_elections", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_for", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_begin_before", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_end_before", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_validator_conf", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_end_before", - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 60n, - }, - "op": "-", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "main_validators", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 18n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_for", - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cnt", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cnt", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "main_validators", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_weight", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vdict", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_addr", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_validator_set_to_config", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_for", - }, - "op": "+", - }, - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - "op": "+", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "cell_hash", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stakes", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_past_election", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_active_vset_id", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_hash", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "cell_hash", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_hash", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_time", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs0", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 57n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_time", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_time", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs0", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_next?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tm", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_hash", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tm", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "alternative": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "condition": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - }, - "consequence": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_hash", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cell_hash_eq?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expected_vset_hash", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "alternative": { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cell_hash", - }, - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expected_vset_hash", - }, - }, - "condition": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset", - }, - }, - "consequence": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_set_installed", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_elect", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "cell_hash_eq?", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 36n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "cell_hash_eq?", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_active_vset_id", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_unfreeze", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_next?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unused_prizes", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_all", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unused_prizes", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "announce_new_elections", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "next_vset", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 36n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "next_vset", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elector_addr", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "my_wc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "my_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "parse_std_addr", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "my_address", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "my_wc", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "my_addr", - }, - "loc": FuncSrcInfo {}, - "op": "!=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elector_addr", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_vset", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_vset", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_for", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_begin_before", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_end_before", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_validator_conf", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_valid_until", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_vset", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t0", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_valid_until", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_begin_before", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t0", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t0", - }, - "op": "-", - }, - ], - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 60n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t0", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 17n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_begin_before", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_end_before", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_dict", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "false", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "run_ticktock", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "is_tock", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "announce_new_elections", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "conduct_elections", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_set_installed", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_active_vset_id", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_unfreeze", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_election_id", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "alternative": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - "condition": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - "consequence": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "participates_in", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_elect", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mem", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "validator_pubkey", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "alternative": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - "consequence": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mem", - }, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "participant_list", - }, - "parameters": [], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nil", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_elect", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nil", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_prev?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cons", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "participant_list_extended", - }, - "parameters": [], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "null?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nil", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_elect", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nil", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_prev?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "members", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "time", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "adnl_addr", - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cons", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect_close", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "failed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "finished", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_returned_stake", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "wallet_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "wallet_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "alternative": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "consequence": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "val", - }, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_election_ids", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_prev?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cons", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_prev?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_past_election", - }, - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cons", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections_list", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_prev?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_past_election", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cons", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complete_unpack_complaint", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_complaint_status", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters_list", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voter_id", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voter_id", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_prev?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voter_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters_list", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voter_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters_list", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cons", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "expressions": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_complaint", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint", - }, - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "voters_list", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "weight_remaining", - }, - ], - "kind": "expression_tuple", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_past_complaints", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elect", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "credits", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "grams", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "active_hash", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "past_elections", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unfreeze_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stake_held", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vset_hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "frozen_dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "total_stake", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bonuses", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_past_election", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "show_complaint", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "chash", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_past_complaints", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "chash", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "alternative": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - "consequence": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complete_unpack_complaint", - }, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list_complaints", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "election_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_past_complaints", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get_prev?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaints", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "id", - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complete_unpack_complaint", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pair", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cons", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "complaint_storage_price", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_in", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "deposit", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bit_price", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cell_price", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_complaint_prices", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pps", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1024n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bit_price", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "refs", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cell_price", - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pps", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_in", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "deposit", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "paid", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse expressions 1`] = ` -{ - "items": [], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse functions 1`] = ` -{ - "items": [ - { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "void", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "params", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p1", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p3", - }, - "ty": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p4", - }, - "ty": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - ], - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p5", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - ], - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "poly", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p1", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "poly'", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p1", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p2", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - }, - ], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "attr", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - }, - ], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "attr'", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "attr''", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "body", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "XXX", - }, - }, - ], - }, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "everything", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "XXX", - }, - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "XXX", - }, - }, - "statements": [], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse globals 1`] = ` -{ - "items": [ - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "glob1", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "glob2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "glob3", - }, - "ty": { - "kind": "type_mapped", - "loc": FuncSrcInfo {}, - "mapsTo": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "value": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "glob4", - }, - "ty": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_mapped", - "loc": FuncSrcInfo {}, - "mapsTo": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "value": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cont", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - ], - }, - }, - ], - }, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "glob5", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "glob6", - }, - "ty": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - ], - }, - }, - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "glob7", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse highload-wallet-code 1`] = ` -{ - "items": [ - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "idict_get_next?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse highload-wallet-v2-code 1`] = ` -{ - "items": [ - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bound", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bound", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "idict_get_next?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bound", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "queries", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries'", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_delete_get_min", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bound", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries'", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "i", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "processed?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "udict_get?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "old_queries", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "alternative": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query_id", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_cleaned", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - "consequence": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse identifiers 1`] = ` -{ - "items": [ - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query'", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "query''", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "CHECK", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "_internal_val", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "message_found?", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_pubkeys&signatures", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict::udict_set_builder", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "[semantics wrapper for FunC][semantics wrapper for FunC][semantics wrapper for FunC]", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fatal!", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "123validname", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "2+2=2*2", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "-alsovalidname", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "0xefefefhahaha", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "{hehehe}", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pa{--}in"\`aaa\`"", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "quoted_id", - "loc": FuncSrcInfo {}, - "value": "[semantics wrapper for FunC]I'm a function too[semantics wrapper for FunC]", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "quoted_id", - "loc": FuncSrcInfo {}, - "value": "[semantics wrapper for FunC]any symbols ; ~ () are allowed here...[semantics wrapper for FunC]", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "C4", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "C4g", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "4C", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "_0x0", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "_0", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "0x_", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "0x0_", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "0_", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash#256", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "💀💀💀0xDEADBEEF💀💀💀", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_verify_address", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "__tact_pow2", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "randomize_lt", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::asin", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::nrand_fast", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f261_inlined", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "f̷̨͈͚́͌̀i̵̩͔̭̐͐̊n̸̟̝̻̩̎̓͋̕e̸̝̙̒̿͒̾̕", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "❤️❤️❤️thanks❤️❤️❤️", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "intslice", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "globals": [ - { - "kind": "global_variable", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "int2", - }, - "ty": undefined, - }, - ], - "kind": "global_variables_declaration", - "loc": FuncSrcInfo {}, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "impure_touch", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict::delete_get_min", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_declaration", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "something", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse include_stdlib 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "../../../stdlib/stdlib.fc", - }, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse literals-and-comments 1`] = ` -{ - "items": [ - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "integers", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -42n, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -42n, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -42n, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "strings", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "slice", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "s", - "value": "2A", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "a", - "value": "EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "u", - "value": "int hex", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "h", - "value": "int 32 bits of sha256", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "H", - "value": "int 256 bits of sha256", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": "c", - "value": "int crc32", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": " - multi - line - ", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": "s", - "value": "2A", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": "a", - "value": "EQAFmjUoZUqKFEBGYFEMbv-m61sFStgAfUR8J6hJDwUU09iT", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": "u", - "value": " - ... - ", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": "h", - "value": " - ... - ", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": "H", - "value": " - ... - ", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "string_multiline", - "loc": FuncSrcInfo {}, - "ty": "c", - "value": " - ... - ", - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "comments!", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse mathlib 1`] = ` -{ - "items": [ - { - "kind": "include", - "loc": FuncSrcInfo {}, - "path": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "stdlib.fc", - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 4n, - "op": ">=", - "patch": 2n, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SGN", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sgn", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "UBITSIZE", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_floor_p1", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "MULRSHIFTR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "256 MULRSHIFTR#", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "256 MULRSHIFT#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshift256mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "256 MULRSHIFTR#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "255 MULRSHIFTR#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr255mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "248 MULRSHIFTR#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr248mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "5 MULRSHIFTR#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr5mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "6 MULRSHIFTR#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr6mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "7 MULRSHIFTR#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr7mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "256 LSHIFT#DIVR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "256 LSHIFT#DIVMODR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divmodr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "255 LSHIFT#DIVMODR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift255divmodr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "2 LSHIFT#DIVMODR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift2divmodr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "7 LSHIFT#DIVMODR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift7divmodr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "LSHIFTDIVMODR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshiftdivmodr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "256 RSHIFTR#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rshiftr256mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "248 RSHIFTR#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rshiftr248mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "4 RSHIFTR#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rshiftr4mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "3 RSHIFT#MOD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rshift3mod", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SUBR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sub_rev", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PUSHNAN", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nan", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "ISNAN", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "is_nan", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "geom_mean", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_floor_p1", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_floor_p1", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "alternative": { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "<<", - }, - ], - }, - "condition": { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - }, - "consequence": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "op": "+", - }, - ], - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivc", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sqrt", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "geom_mean", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::sqrt", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "geom_mean", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed255::sqrt", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "geom_mean", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::sqr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed255::sqr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "constants": [ - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::One", - }, - "ty": "int", - "value": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - ], - "kind": "constants_definition", - "loc": FuncSrcInfo {}, - }, - { - "constants": [ - { - "kind": "constant", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed255::One", - }, - "ty": "int", - "value": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - ], - "kind": "constants_definition", - "loc": FuncSrcInfo {}, - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_xconst_f256", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 80260960185991308862233904206310070533990667611589946606122867505419956976172n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -32272921378999278490133606779486332143n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_xconst_f254", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 90942894222941581070058735694432465663348344332098107489693037779484723616546n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 108051869516004014909778934258921521947n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Atan1_16_f260", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 115641670674223639132965820642403718536242645001775371762318060545014644837101n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Atan1_8_f259", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 115194597005316551477397594802136977648153890007566736408151129975021336532841n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Atan1_32_f261", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 115754418570128574501879331591757054405465733718902755858991306434399246026247n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_const_f256", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_xconst_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::log2_const", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_const_f256", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "~>>", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_const_f254", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_xconst_f254", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::Pi_const", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_const_f254", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - "op": "~>>", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tanh_f258", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_bitwise_shift", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 5n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 250n, - }, - "op": "<<", - }, - ], - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Two", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 251n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Two", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 239n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 254n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 243n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expm1_f257", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Two", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 251n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 39n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 250n, - }, - "op": "<<", - }, - ], - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 17n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Two", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 239n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 254n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 243n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "~/", - }, - ], - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "~/", - }, - ], - }, - "op": "-", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::exp", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l2c", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l2d", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_xconst_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l2c", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshiftdivmodr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l2d", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 127n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expm1_f257", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::exp2", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rshiftr248mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_const_f256", - }, - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 247n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expm1_f257", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_f260_inlined", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Two", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 251n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 250n, - }, - "op": "<<", - }, - ], - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 14n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Two", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 236n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 254n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 240n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 10n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_f260", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_f260_inlined", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_f258_inlined", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Two", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 251n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 41n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 250n, - }, - "op": "<<", - }, - ], - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 18n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Two", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 240n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 254n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 244n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 5n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_f258", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_f258_inlined", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sincosm1_f259_inlined", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_f260_inlined", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tt", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tt", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tt", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "~/", - }, - ], - }, - "op": "-", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tt", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tt", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tt", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "~/", - }, - ], - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sincosm1_f259", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sincosm1_f259_inlined", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sincosn_f256", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xe", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x1", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "abs", - }, - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Atan1_8_f259", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift2divmodr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x1", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xe", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sincosm1_f259", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 63n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "op": "*", - }, - ], - }, - "op": "-", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 63n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 65n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "op": "*", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "br", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divmodr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "br", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "br", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ar", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divmodr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ar", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ar", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sgn", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "br", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "*", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ar", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "~/", - }, - ], - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sincosm1_f256", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sincosm1_f259_inlined", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r", - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_aux_f256", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_f258_inlined", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tt", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tt", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tt", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::sincos", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pic", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pid", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_xconst_f254", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pic", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift7divmodr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pid", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 127n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sincosm1_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - "loc": FuncSrcInfo {}, - "op": "~>>=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::sin", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::sincos", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "si", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::cos", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::sincos", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "co", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::tan", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pic", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pid", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_xconst_f254", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pic", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift7divmodr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pid", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 127n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_aux_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::cot", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pic", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pid", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_xconst_f254", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pic", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift7divmodr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pid", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 127n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tan_aux_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atanh_f258", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 254n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - { - "expressions": [ - { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n1", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n1", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "/", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "~/", - }, - ], - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "~/", - }, - ], - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atanh_f261_inlined", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 254n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 242n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - { - "expressions": [ - { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n1", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n1", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4096n, - }, - "op": "~/", - }, - ], - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4096n, - }, - "op": "~/", - }, - ], - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atanh_f261", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atanh_f261_inlined", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log_aux_f257", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_floor_p1", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "<<=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 249n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 90n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": ">>=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "2x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "op": "*", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - }, - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 36n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atanh_f258", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow33", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": "*=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow33b", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mh", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ml", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "m", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 5n, - }, - "op": "/%", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ml", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": "*=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "iterations": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mh", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": "*=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - "op": "*", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - "op": "*", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - "op": "*", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - "op": "*", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log_auxx_f260", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_floor_p1", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "<<=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2873n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 244n, - }, - "op": "<<", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x1", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_bitwise_shift", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": ">>", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x1", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 65n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x1", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 11n, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow33b", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": "<<=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 51n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 5n, - }, - "op": "*", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 18n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atanh_f261", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log_aux_f256", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log_auxx_f260", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "yh", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "yl", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rshiftr4mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "yh", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "expression_bitwise_shift", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "yl", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -3769n, - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 13n, - }, - "op": "~>>", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Log33_32", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3563114646320977386603103333812068872452913448227778071188132859183498739150n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "yh", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Log33_32", - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_aux_f256", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log_auxx_f260", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_const_f256", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "~>>", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Log33_32", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 5140487830366106860412008603913034462883915832139695448455767612111363481357n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Log33_32", - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::log", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log_aux_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "-", - }, - ], - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_const_f256", - }, - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::log2", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_aux_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::pow", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bad", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_compare", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bad", - }, - "op": ">>", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_aux_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q1", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r1", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr248mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q2", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r2", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "l", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshift256mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r2", - }, - "loc": FuncSrcInfo {}, - "op": ">>=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 247n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q3", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r3", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q2", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rshiftr248mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ll", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r1", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r3", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rshiftr248mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ll", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ll", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r2", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q1", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q3", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sq", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sq", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sq", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ll", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "log2_const_f256", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expm1_f257", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sq", - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f259", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 254n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 246n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - { - "expressions": [ - { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n1", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n1", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "~/", - }, - ], - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "~/", - }, - ], - }, - "op": "-", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f261_inlined", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 254n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 242n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - { - "expressions": [ - { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n1", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "-", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "One", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n1", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x2", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4096n, - }, - "op": "~/", - }, - ], - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4096n, - }, - "op": "~/", - }, - ], - }, - "op": "-", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f261", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "n", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f261_inlined", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_aux_prereduce", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xu", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "abs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tc", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7214596n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t1", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xu", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tc", - }, - "op": "-", - }, - ], - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 88n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xu", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tc", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 48n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t1", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3073n, - }, - "op": "*", - }, - ], - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 59n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t1", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t1", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 13n, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pa", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pb", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33226912n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 5232641n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qh", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ql", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 5n, - }, - "op": "/%", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 5n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 51n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "*", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "<<", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ql", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "op": "*", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sub_rev", - }, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "iterations": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qh", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pa", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pb", - }, - "op": "*", - }, - ], - }, - "op": "-", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pb", - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pa", - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sgn", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xs", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - "op": "*", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xs", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "op": "*", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_aux_f256", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 232n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_aux_prereduce", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ul", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ul", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 250n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 18n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f261_inlined", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_auxx_f256", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 232n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_aux_prereduce", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ul", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ul", - }, - "loc": FuncSrcInfo {}, - "op": "/=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vl", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vl", - }, - "loc": FuncSrcInfo {}, - "op": "/=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift255divmodr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "yl", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ul", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r", - }, - "op": "+", - }, - ], - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "vl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "yl", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 249n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 18n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f261_inlined", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f255", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "*=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_aux_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_h", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_l", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_xconst_f254", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qh", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ql", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Atan1_32_f261", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr6mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qh", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_h", - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ql", - }, - "op": "+", - }, - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_l", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 122n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "~/", - }, - ], - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f256_small", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_aux_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qh", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ql", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Atan1_32_f261", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr5mod", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "qh", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ql", - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "~/", - }, - ], - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "asin_f255", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed255::One", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed255::sqr", - }, - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sgn", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_const_f254", - }, - }, - "op": "*", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed255::sqrt", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f256_small", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "acos_f255", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_const_f254", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi", - }, - "loc": FuncSrcInfo {}, - "op": "/=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed255::One", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed255::sqr", - }, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed255::sqrt", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_f256_small", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": "~/", - }, - ], - }, - "op": "+", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::asin", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "asin_f255", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "op": "~>>", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::acos", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "acos_f255", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - "op": "~>>", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::atan", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 249n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "<<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sgn", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_aux_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "~/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_const_f254", - }, - }, - "op": "*", - }, - ], - }, - "op": "+", - }, - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Atan1_32_f261", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "~/", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::acot", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 249n, - }, - "op": "~>>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "<<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sgn", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 248n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "lshift256divr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "atan_aux_f256", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Pi_const_f254", - }, - }, - "op": "*", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "~/", - }, - ], - }, - "op": "-", - }, - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "q", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Atan1_32_f261", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "~/", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nrand_f252", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r0", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nan", - }, - }, - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 29483n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 236n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -3167n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 239n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 12845n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16693n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9043n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "kind": "expression_unary", - "loc": FuncSrcInfo {}, - "op": "~", - "operand": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "is_nan", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "random", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "random", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "-", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7027n, - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "va", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "abs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u1", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v1", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "op": "-", - }, - ], - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "va", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "op": "-", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Q", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u1", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u1", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 252n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v1", - }, - { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v1", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u1", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "-", - }, - ], - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 252n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Qd", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Q", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 237n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "r0", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Qd", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9125n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9043n, - }, - "op": "-", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "va", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - "op": "/", - }, - ], - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "v", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 252n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Qd", - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xx", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mulrshiftr256", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "~/", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ex", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xx", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::exp", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "*", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "u", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ex", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nan", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nrand_fast_f252", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "touch", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 253n, - }, - "op": "<<", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "iterations": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 12n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "random", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "/", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::random", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "random", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": ">>", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::nrand", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nrand_f252", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "~>>", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fixed248::nrand_fast", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "nrand_fast_f252", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "~>>", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse payment-channel-code 1`] = ` -{ - "items": [ - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "31 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:wrong_a_signature", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "32 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:wrong_b_signature", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "33 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:msg_value_too_small", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "34 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:replay_protection", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "35 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:no_timeout", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "36 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:expected_init", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "37 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:expected_close", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "37 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:expected_payout", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "38 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:no_promise_signature", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "39 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:wrong_channel_id", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "40 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:unknown_op", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "41 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:not_enough_fee", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "0x912838d1 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op:pchan_cmd", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "0x27317822 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:init", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "0xf28ae183 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:close", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "0x43278a28 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:timeout", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "0x37fe7810 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:payout", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "0 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state:init", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "1 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state:close", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "2 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state:payout", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "1000000000 PUSHINT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_fee", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_data", - }, - "parameters": [], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_data", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_config", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "res", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unwrap_signatures", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_sig", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_sig", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b?", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_sig", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_sig", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_hash", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:wrong_a_signature", - }, - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_sig", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:wrong_b_signature", - }, - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_sig", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a?", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_state_init", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_state_init", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state:init", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_B", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_state_close", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_state_close", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state:close", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_payout", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:payout", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "do_payout", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "diff", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "diff", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "diff", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "loc": FuncSrcInfo {}, - "negateLeft": true, - "ops": [], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "diff", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "diff", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "diff", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "diff", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_payout", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_payout", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state:payout", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "with_init", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "init_timeout", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A_extra", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_state_init", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "init_timeout", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:timeout", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:no_timeout", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "do_payout", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:expected_init", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:init", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "upd_min_A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "upd_min_B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "got_channel_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:wrong_channel_id", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "got_channel_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:msg_value_too_small", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_A", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_B", - }, - "op": "+", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:replay_protection", - }, - }, - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_A", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "inc_B", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - "loc": FuncSrcInfo {}, - "op": "|=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "upd_min_A", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "upd_min_A", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - "loc": FuncSrcInfo {}, - "op": "|=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_B", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "upd_min_B", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_B", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "upd_min_B", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "loc": FuncSrcInfo {}, - "op": "-=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A_extra", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_B", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "do_payout", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_state_close", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_state_init", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "with_close", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_timeout", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_state_close", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_timeout", - }, - "op": "+", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:timeout", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:no_timeout", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "do_payout", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:expected_close", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:close", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:replay_protection", - }, - }, - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - "loc": FuncSrcInfo {}, - "op": "|=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - "loc": FuncSrcInfo {}, - "op": "|=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "extra_A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "extra_B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "has_sig", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:no_promise_signature", - }, - }, - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "extra_A", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "extra_B", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "has_sig", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sig", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_hash", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:wrong_a_signature", - }, - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sig", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "extra_A", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:wrong_b_signature", - }, - }, - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "sig", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "extra_B", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "got_channel_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_promise_A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_promise_B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:wrong_channel_id", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "got_channel_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_promise_A", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "extra_A", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_promise_A", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_promise_A", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_promise_B", - }, - "loc": FuncSrcInfo {}, - "op": "+=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "extra_B", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_promise_B", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "update_promise_B", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "do_payout", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_A?", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signed_B?", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "promise_B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_state_close", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "with_payout", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:expected_payout", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg:payout", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:not_enough_fee", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1000000000n, - }, - "op": "+", - }, - ], - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "pair_first", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_balance", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "B", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_payout", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "A", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_payout", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_any", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_empty?", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "err:unknown_op", - }, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op:pchan_cmd", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpack_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "init_timeout", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "close_timeout", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A_extra", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "unpack_config", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "unwrap_signatures", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state_type", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state_type", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state:init", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "init_timeout", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_A_extra", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "with_init", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state_type", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state:close", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_A?", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_signed_B?", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "close_timeout", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "with_close", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state_type", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state:payout", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "channel_id", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "with_payout", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "state", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pack_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg_cell", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_any", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_any", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse pow-testgiver-code 1`] = ` -{ - "items": [ - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "UFITSX", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ufits", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bits", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_proof_of_work", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno_sw", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 24n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "whom", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdata1", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rseed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdata2", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_int", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "op": "-", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 10n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ufits", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 25n, - }, - { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rseed", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seed", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdata1", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdata2", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "randomize_lt", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdata1", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "randomize", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_success", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xdata", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xdata", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "target_delta", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_cpl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_cpl", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "delta", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_success", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "delta", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "factor", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "delta", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "target_delta", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "factor", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "factor", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 7n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 125n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max", - }, - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 125n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "factor", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_cpl", - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max", - }, - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_cpl", - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno_sw", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "random", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": ">>", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xdata", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "commit", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 6n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 132n, - }, - "op": "|", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 9n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_int", - }, - { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - "op": ">>", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "whom", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_grams", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rescale_complexity", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "time", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 28n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "time", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "skipped_data", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_success", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xdata", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 29n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expire", - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_success", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xdata", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "target_delta", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "delta", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "time", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_success", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 30n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "delta", - }, - "loc": FuncSrcInfo {}, - "op": ">=", - "right": { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "target_delta", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 16n, - }, - "op": "*", - }, - ], - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min_cpl", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_cpl", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "factor", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "delta", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "target_delta", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_complexity", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_cpl", - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_complexity", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "<<", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldiv", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "alternative": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "factor", - }, - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "muldivr", - }, - }, - "condition": { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_factor", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "factor", - }, - }, - "consequence": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_complexity", - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_success", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "time", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "target_delta", - }, - "op": "-", - }, - ], - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "skipped_data", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_success", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xdata", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "update_params", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pref", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pref", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reset_cpl", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "last_success", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reset_cpl", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seed", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "randomize", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "reset_cpl", - }, - "op": "<<", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seed", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "kind": "expression_bitwise_shift", - "left": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "random", - }, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - "op": ">>", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seed", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_parse", - }, - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1298755173n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_proof_of_work", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "op", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1381196652n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rescale_complexity", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "kind": "expression_add_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "|", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ref", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": [ - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "update_params", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ref", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "loc": FuncSrcInfo {}, - "op": "<", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 255n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ref", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_slice", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_pow_params", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xdata", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 128n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "xdata", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seed", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pow_complexity", - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse pragmas 1`] = ` -{ - "items": [ - { - "kind": "pragma_literal", - "literal": "allow-post-modification", - "loc": FuncSrcInfo {}, - }, - { - "kind": "pragma_literal", - "literal": "compute-asm-ltr", - "loc": FuncSrcInfo {}, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": undefined, - "patch": undefined, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": undefined, - "patch": undefined, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": undefined, - "patch": 0n, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "=", - "patch": undefined, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": "=", - "patch": undefined, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": "=", - "patch": 0n, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "^", - "patch": undefined, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "<", - "patch": undefined, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": ">", - "patch": undefined, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "<=", - "patch": undefined, - }, - }, - { - "allow": true, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": ">=", - "patch": undefined, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": undefined, - "patch": undefined, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": undefined, - "patch": undefined, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": undefined, - "patch": 0n, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "=", - "patch": undefined, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": "=", - "patch": undefined, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": 0n, - "op": "=", - "patch": 0n, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "^", - "patch": undefined, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "<", - "patch": undefined, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": ">", - "patch": undefined, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": "<=", - "patch": undefined, - }, - }, - { - "allow": false, - "kind": "pragma_version_range", - "loc": FuncSrcInfo {}, - "range": { - "kind": "version_range", - "loc": FuncSrcInfo {}, - "major": 0n, - "minor": undefined, - "op": ">=", - "patch": undefined, - }, - }, - { - "kind": "pragma_version_string", - "loc": FuncSrcInfo {}, - "version": { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "0.4.4", - }, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse restricted-wallet-code 1`] = ` -{ - "items": [ - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "inline", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "restricted?", - }, - "parameters": [], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -13n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "alternative": { - "kind": "expression_compare", - "left": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_parse", - }, - }, - "loc": FuncSrcInfo {}, - "op": ">", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - "condition": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null?", - }, - }, - "consequence": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_destination", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": undefined, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dest", - }, - "ty": undefined, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 4n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "expression_mul_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "flags", - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - "op": "&", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s_addr", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "d_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_msg_addr", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_msg_addr", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dest_wc", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dest_addr", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "d_addr", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_std_addr", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_mul_bitwise", - "left": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dest_wc", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "ops": [ - { - "expr": { - "expressions": [ - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dest_addr", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dest", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "op": "&", - }, - ], - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "restrict", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "restricted?", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elector", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "true", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "restrict", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "elector", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_destination", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ok", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "alternative": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "pair_first", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_balance", - }, - }, - "condition": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "restricted?", - }, - }, - "consequence": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse restricted-wallet2-code 1`] = ` -{ - "items": [ - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seconds_passed", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -13n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "alternative": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_parse", - }, - }, - "condition": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null?", - }, - }, - "consequence": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "alternative": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - "consequence": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - "op": "-", - }, - ], - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ts", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seconds_passed", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "idict_get_preveq?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ts", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw_reserve", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_balance_at", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ts", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seconds_passed", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "pair_first", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_balance", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "idict_get_preveq?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ts", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - }, - "op": "-", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance_at", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_balance_at", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_balance_at", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse restricted-wallet3-code 1`] = ` -{ - "items": [ - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seconds_passed", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "statements": [ - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -13n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "alternative": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_parse", - }, - }, - "condition": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null?", - }, - }, - "consequence": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "alternative": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": -1n, - }, - "condition": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - "consequence": { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - "op": "-", - }, - ], - }, - "kind": "expression_conditional", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 36n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ts", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seconds_passed", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "idict_get_preveq?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ts", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw_reserve", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_dict", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "wallet_id", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "inline_ref", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_balance_at", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "skip_bits", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - "op": "+", - }, - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - "op": "+", - }, - ], - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_dict", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ts", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "start_at", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seconds_passed", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "pair_first", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_balance", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "idict_get_preveq?", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ts", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rdict", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "found", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_grams", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - }, - "op": "-", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance_at", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "utime", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_balance_at", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "balance", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_balance_at", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse simple-wallet-code 1`] = ` -{ - "items": [ - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs2", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_parse", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs2", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs2", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs2", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse simple-wallet-ext-code 1`] = ` -{ - "items": [ - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "create_state", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_state", - }, - "parameters": [], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs2", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_parse", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs2", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs2", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "save_state", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "create_state", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "do_verify_message", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "expressions": [ - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_state", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "do_verify_message", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "alternatives": undefined, - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "consequences": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "save_state", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_state", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "create_init_state", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "create_state", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prepare_send_message_with_seqno", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_ref", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prepare_send_message", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "prepare_send_message_with_seqno", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "verify_message", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_state", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "do_verify_message", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse statements 1`] = ` -{ - "items": [ - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "return_stmt'", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "block_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [ - { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "empty_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cond_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "alternatives": undefined, - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequences": [], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequences": [], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternatives": undefined, - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequences": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": undefined, - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequences": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternatives": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequences": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": true, - }, - { - "alternatives": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequences": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_if", - "loc": FuncSrcInfo {}, - "positive": false, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequencesElseif": [], - "consequencesIf": [], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": true, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequencesElseif": [], - "consequencesIf": [], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": true, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequencesElseif": [], - "consequencesIf": [], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": false, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequencesElseif": [], - "consequencesIf": [], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": false, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": true, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": true, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": false, - }, - { - "alternativesElseif": undefined, - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": false, - }, - { - "alternativesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": true, - "positiveIf": true, - }, - { - "alternativesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "conditionElseif": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "conditionIf": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "consequencesElseif": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "consequencesIf": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "statement_condition_elseif", - "loc": FuncSrcInfo {}, - "positiveElseif": false, - "positiveIf": false, - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "repeat_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "iterations": { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [], - }, - { - "iterations": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "until_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [], - }, - { - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_until", - "loc": FuncSrcInfo {}, - "statements": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [ - { - "iterations": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [], - }, - ], - }, - ], - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "while_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [], - }, - { - "condition": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [ - { - "iterations": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "kind": "statement_repeat", - "loc": FuncSrcInfo {}, - "statements": [], - }, - ], - }, - ], - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "try_catch_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "catchExceptionName": { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "catchExitCodeName": { - "kind": "unused_id", - "loc": FuncSrcInfo {}, - "value": "_", - }, - "kind": "statement_try_catch", - "loc": FuncSrcInfo {}, - "statementsCatch": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [], - }, - ], - "statementsTry": [ - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_empty", - "loc": FuncSrcInfo {}, - }, - { - "kind": "statement_block", - "loc": FuncSrcInfo {}, - "statements": [], - }, - ], - }, - { - "catchExceptionName": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exception", - }, - "catchExitCodeName": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "exit_code", - }, - "kind": "statement_try_catch", - "loc": FuncSrcInfo {}, - "statementsCatch": [], - "statementsTry": [], - }, - ], - }, - { - "attributes": [], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "expression_stmt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 42n, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse stdlib 1`] = ` -{ - "items": [ - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CONS", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cons", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "head", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tail", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "UNCONS", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "uncons", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "UNCONS", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list_next", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CAR", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "car", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CDR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cdr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "list", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NIL", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "empty_tuple", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "TPUSH", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tpush", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "TPUSH", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "tpush", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SINGLE", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "single", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - ], - "returnTy": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "UNSINGLE", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unsingle", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PAIR", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pair", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - }, - ], - "returnTy": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "UNPAIR", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "unpair", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "TRIPLE", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "triple", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - }, - ], - "returnTy": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "UNTRIPLE", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "untriple", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "4 TUPLE", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "W", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "tuple4", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "z", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "w", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "W", - }, - }, - }, - ], - "returnTy": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "W", - }, - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "4 UNTUPLE", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "W", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "untuple4", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "W", - }, - }, - ], - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "W", - }, - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "FIRST", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "first", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SECOND", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "second", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "THIRD", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "third", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "3 INDEX", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "fourth", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "t", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "FIRST", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pair_first", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SECOND", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pair_second", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - ], - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "FIRST", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "triple_first", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SECOND", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "triple_second", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "THIRD", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "triple_third", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "p", - }, - "ty": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Y", - }, - }, - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - ], - }, - }, - ], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "Z", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PUSHNULL", - }, - ], - "attributes": [], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "null", - }, - "parameters": [], - "returnTy": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NOP", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": { - "kind": "forall", - "loc": FuncSrcInfo {}, - "tyVars": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - ], - }, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "impure_touch", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "keyword": false, - "kind": "type_var", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "X", - }, - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NOW", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "MYADDR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "my_address", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "BALANCE", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_balance", - }, - "parameters": [], - "returnTy": { - "kind": "type_tuple", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "LTIME", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cur_lt", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "BLOCKLT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "block_lt", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "HASHCU", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cell_hash", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "HASHSU", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SHA256U", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "string_hash", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CHKSIGNU", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "hash", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CHKSIGNS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_data_signature", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "data", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CDATASIZE", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_data_size", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_cells", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDATASIZE", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_compute_data_size", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_cells", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "compute_data_size?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_cells", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_compute_data_size?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max_cells", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DUMPSTK", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dump_stack", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "c4 PUSH", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "c4 POP", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "c3 PUSH", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_c3", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cont", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "c3 POP", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_c3", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cont", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "BLESS", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "bless", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cont", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "ACCEPT", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SETGASLIMIT", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_gas_limit", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "limit", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "COMMIT", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "commit", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "BUYGAS", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "buy_gas", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "MIN", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "min", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "MAX", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "max", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "MINMAX", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "minmax", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "y", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "ABS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "abs", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CTOS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_parse", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "ENDS", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "end_parse", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "LDREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PLDREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "preload_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "LDGRAMS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_grams", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "LDGRAMS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_coins", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDSKIPFIRST", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "skip_bits", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDSKIPFIRST", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "skip_bits", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDCUTFIRST", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "first_bits", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDSKIPLAST", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "skip_last_bits", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDSKIPLAST", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "skip_last_bits", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDCUTLAST", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_last", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "LDDICT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_dict", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PLDDICT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "preload_dict", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SKIPDICT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "skip_dict", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "LDOPTREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_maybe_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PLDOPTREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "preload_maybe_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CDEPTH", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cell_depth", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SREFS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_refs", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SBITS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_bits", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SBITREFS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_bits_refs", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SEMPTY", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_empty?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDEMPTY", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_data_empty?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SREMPTY", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_refs_empty?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDEPTH", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_depth", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "BREFS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "builder_refs", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "BBITS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "builder_bits", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "BDEPTH", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "builder_depth", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NEWC", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "ENDC", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "end_cell", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STSLICER", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_slice", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STGRAMS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_grams", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STGRAMS", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_coins", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STDICT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_dict", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STOPTREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_maybe_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "LDMSGADDR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "load_msg_addr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PARSEMSGADDR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_addr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "tuple", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "REWRITESTDADDR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_std_addr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "REWRITEVARADDR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "parse_var_addr", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "s", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTISETREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_set_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTISETREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "idict_set_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUSETREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_set_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUSETREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIGETOPTREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIGETREF", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_ref?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUGETREF", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_ref?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTISETGETOPTREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_set_get_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUSETGETOPTREF", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_set_get_ref", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIDEL", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_delete?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUDEL", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_delete?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIGET", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUGET", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIDELGET", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_delete_get?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUDELGET", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_delete_get?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIDELGET", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "idict_delete_get?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUDELGET", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_delete_get?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUSET", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_set", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUSET", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTISET", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_set", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTISET", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "idict_set", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTSET", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict_set", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTSET", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "dict_set", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUADD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_add?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUREPLACE", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_replace?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIADD", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_add?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIREPLACE", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_replace?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUSETB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_set_builder", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUSETB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict_set_builder", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTISETB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_set_builder", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTISETB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "idict_set_builder", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTSETB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict_set_builder", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTSETB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "dict_set_builder", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUADDB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_add_builder?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUREPLACEB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_replace_builder?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIADDB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_add_builder?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIREPLACEB", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_replace_builder?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "index", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUREMMIN", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_delete_get_min", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUREMMIN", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict::delete_get_min", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIREMMIN", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_delete_get_min", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIREMMIN", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "idict::delete_get_min", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTREMMIN", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict_delete_get_min", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTREMMIN", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "dict::delete_get_min", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUREMMAX", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_delete_get_max", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUREMMAX", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "udict::delete_get_max", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIREMMAX", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_delete_get_max", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIREMMAX", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "idict::delete_get_max", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTREMMAX", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict_delete_get_max", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 3n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTREMMAX", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "dict::delete_get_max", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUMIN", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_min?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUMAX", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_max?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUMINREF", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_min_ref?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUMAXREF", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_max_ref?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIMIN", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_min?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIMAX", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_max?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIMINREF", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_min_ref?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": undefined, - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIMAXREF", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_max_ref?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUGETNEXT", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_next?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUGETNEXTEQ", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_nexteq?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUGETPREV", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_prev?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTUGETPREVEQ", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "udict_get_preveq?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIGETNEXT", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_next?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIGETNEXTEQ", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_nexteq?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIGETPREV", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_prev?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 0n, - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 2n, - }, - ], - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTIGETPREVEQ", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "idict_get_preveq?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pivot", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NEWDICT", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_dict", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "DICTEMPTY", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict_empty?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PFXDICTGETQ", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "NULLSWAPIFNOT2", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfxdict_get?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PFXDICTSET", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfxdict_set?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "value", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": { - "arguments": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - ], - "kind": "asm_arrangement", - "loc": FuncSrcInfo {}, - "returns": undefined, - }, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "PFXDICTDEL", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "pfxdict_delete?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "dict", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key_len", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "key", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_tensor", - "loc": FuncSrcInfo {}, - "types": [ - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - ], - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "CONFIGOPTPARAM", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "config_param", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "ISNULL", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cell_null?", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "c", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "RAWRESERVE", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw_reserve", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "RAWRESERVEX", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "raw_reserve_extra", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "amount", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "extra_amount", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SENDRAWMSG", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SETCODE", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_code", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "new_code", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "cell", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "RANDU256", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "random", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "RAND", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "rand", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "range", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "RANDSEED", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_seed", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SETRAND", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_seed", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": undefined, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "ADDRAND", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "randomize", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "x", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "LTIME", - }, - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "ADDRAND", - }, - ], - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "randomize_lt", - }, - "parameters": [], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "SDEQ", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "equal_slice_bits", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "a", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "b", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - }, - { - "arrangement": undefined, - "asmStrings": [ - { - "kind": "string_singleline", - "loc": FuncSrcInfo {}, - "ty": undefined, - "value": "STBR", - }, - ], - "attributes": [], - "forall": undefined, - "kind": "asm_function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "store_builder", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "to", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "from", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "builder", - }, - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse wallet-code 1`] = ` -{ - "items": [ - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; - -exports[`FunC grammar and parser should parse wallet3-code 1`] = ` -{ - "items": [ - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_internal", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [], - }, - { - "attributes": [ - { - "kind": "impure", - "loc": FuncSrcInfo {}, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "recv_external", - }, - "parameters": [ - { - "kind": "parameter", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - "ty": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "slice", - }, - }, - ], - "returnTy": { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_bits", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 512n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "valid_until", - }, - "loc": FuncSrcInfo {}, - "op": "<=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "now", - }, - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_if", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "expression_tensor_var_decl", - "loc": FuncSrcInfo {}, - "names": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "ds", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 33n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "msg_seqno", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 34n, - }, - { - "kind": "expression_compare", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "subwallet_id", - }, - "loc": FuncSrcInfo {}, - "op": "==", - "right": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 35n, - }, - { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "in_msg", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "slice_hash", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "signature", - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "check_signature", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "throw_unless", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "accept_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "touch", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "condition": { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "slice_refs", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - "kind": "statement_while", - "loc": FuncSrcInfo {}, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 8n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_ref", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "mode", - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "send_raw_message", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "expression": { - "arguments": [ - { - "expressions": [ - { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "expression_add_bitwise", - "left": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_seqno", - }, - "loc": FuncSrcInfo {}, - "negateLeft": false, - "ops": [ - { - "expr": { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 1n, - }, - "op": "+", - }, - ], - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "stored_subwallet", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "store_uint", - }, - { - "expressions": [ - { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "public_key", - }, - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "end_cell", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "begin_cell", - }, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "set_data", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "seqno", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 32n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - { - "attributes": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "value": undefined, - }, - ], - "forall": undefined, - "kind": "function_definition", - "loc": FuncSrcInfo {}, - "name": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_public_key", - }, - "parameters": [], - "returnTy": { - "kind": "type_primitive", - "loc": FuncSrcInfo {}, - "value": "int", - }, - "statements": [ - { - "expression": { - "kind": "expression_assign", - "left": { - "kind": "expression_var_decl", - "loc": FuncSrcInfo {}, - "names": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - "ty": { - "kind": "hole", - "loc": FuncSrcInfo {}, - "value": "var", - }, - }, - "loc": FuncSrcInfo {}, - "op": "=", - "right": { - "arguments": [ - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "begin_parse", - }, - { - "kind": "unit", - "loc": FuncSrcInfo {}, - "value": "()", - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "get_data", - }, - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": "~", - "value": "load_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 64n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_expression", - "loc": FuncSrcInfo {}, - }, - { - "expression": { - "arguments": [ - { - "kind": "method_id", - "loc": FuncSrcInfo {}, - "prefix": ".", - "value": "preload_uint", - }, - { - "expressions": [ - { - "kind": "integer_literal", - "loc": FuncSrcInfo {}, - "value": 256n, - }, - ], - "kind": "expression_tensor", - "loc": FuncSrcInfo {}, - }, - ], - "kind": "expression_fun_call", - "loc": FuncSrcInfo {}, - "object": { - "kind": "plain_id", - "loc": FuncSrcInfo {}, - "value": "cs", - }, - }, - "kind": "statement_return", - "loc": FuncSrcInfo {}, - }, - ], - }, - ], - "kind": "module", - "loc": FuncSrcInfo {}, -} -`; diff --git a/src/func/grammar.spec.ts b/src/func/grammar.spec.ts index 626e16f3b..3629a3ae4 100644 --- a/src/func/grammar.spec.ts +++ b/src/func/grammar.spec.ts @@ -1,4 +1,4 @@ -import { match, parseFile } from "./grammar"; +import { FuncParseError, FuncSyntaxError, match, parseFile } from "./grammar"; import { loadCases } from "../utils/loadCases"; describe("FunC grammar and parser", () => { @@ -28,7 +28,12 @@ describe("FunC grammar and parser", () => { // Checking that valid FunC files parse for (const r of loadCases(__dirname + "/grammar-test/", ext)) { it("should parse " + r.name, () => { - expect(parseFile(r.code, r.name + `.${ext}`)).toMatchSnapshot(); + let parsed: Object | undefined; + try { + parsed = parseFile(r.code, r.name + `.${ext}`); + } finally { + expect(parsed).not.toBe(undefined); + } }); } diff --git a/src/func/grammar.ts b/src/func/grammar.ts index c832a2c73..9c57aea50 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -525,17 +525,19 @@ export type FuncAstPragma = | FuncAstPragmaVersionRange | FuncAstPragmaVersionString; -export type FuncAstPragmaLiteralValue = "allow-post-modification" | "compute-asm-ltr"; - /** * #pragma something-something-something; */ export type FuncAstPragmaLiteral = { kind: "pragma_literal"; - literal: FuncAstPragmaLiteralValue; + literal: FuncPragmaLiteralValue; loc: FuncSrcInfo; }; +export type FuncPragmaLiteralValue = + | "allow-post-modification" + | "compute-asm-ltr"; + /** * `allow` — if set to `true` corresponds to version enforcement * `allow` — if set to `false` corresponds to version prohibiting (or not-version enforcement) @@ -1479,9 +1481,7 @@ semantics.addOperation("astOfModuleItem", { Pragma_literal(_pragmaKwd, literal, _semicolon) { return { kind: "pragma_literal", - literal: literal.sourceString as - | "allow-post-modification" - | "compute-asm-ltr", + literal: literal.sourceString as FuncPragmaLiteralValue, loc: createSrcInfo(this), }; }, From 79b2ad141d7ee4abab7996ebb2135febaabd9cfb Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 13 Aug 2024 03:52:00 +0000 Subject: [PATCH 111/162] feat(func/grammar): Separate hex literal Needed in the FunC codegen --- src/func/grammar.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 9c57aea50..5e7ae7adf 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -1347,6 +1347,7 @@ export type FuncAstVersionRange = { export type FuncAstIntegerLiteral = { kind: "integer_literal"; value: bigint; + isHex: boolean; loc: FuncSrcInfo; }; @@ -2009,6 +2010,7 @@ semantics.addOperation("astOfExpression", { return { kind: "integer_literal", value: value, + isHex: false, loc: createSrcInfo(this), }; }, @@ -2016,6 +2018,7 @@ semantics.addOperation("astOfExpression", { return { kind: "integer_literal", value: BigInt(nonNegNumLit.sourceString), + isHex: false, loc: createSrcInfo(this), }; }, @@ -2023,6 +2026,7 @@ semantics.addOperation("astOfExpression", { return { kind: "integer_literal", value: BigInt(nonNegNumLit.sourceString), + isHex: false, loc: createSrcInfo(this), }; }, @@ -2030,6 +2034,7 @@ semantics.addOperation("astOfExpression", { return { kind: "integer_literal", value: BigInt(hexPrefix.sourceString + nonNegNumLit.sourceString), + isHex: true, loc: createSrcInfo(this), }; }, From 56f39ea0b00705e357a0139c01b61a59511a2388 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 13 Aug 2024 07:31:47 +0000 Subject: [PATCH 112/162] fix(grammar): Set correct types for assignment' `lhs` and `rhs` --- src/func/grammar.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 5e7ae7adf..24241b5c5 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -924,9 +924,9 @@ export type FuncAstExpression = */ export type FuncAstExpressionAssign = { kind: "expression_assign"; - left: FuncAstExpressionConditional; + left: FuncAstExpression; op: FuncOpAssign; - right: FuncAstExpressionAssign; + right: FuncAstExpression; loc: FuncSrcInfo; }; From 6ebe7699c12c9231b565e07ab823e3f38cddd4b1 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 23 Aug 2024 14:13:58 +0000 Subject: [PATCH 113/162] feat(syntaxConstructors): Support new `grammar.ts` --- src/func/grammar.ts | 87 ++-- src/func/syntax.ts | 420 ---------------- src/func/syntaxConstructors.ts | 884 ++++++++++++++++++++------------- 3 files changed, 578 insertions(+), 813 deletions(-) delete mode 100644 src/func/syntax.ts diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 24241b5c5..e9f14f177 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -617,12 +617,14 @@ export type FuncAstConstantsDefinition = { */ export type FuncAstConstant = { kind: "constant"; - ty: "slice" | "int" | undefined; + ty: FuncConstantType | undefined; name: FuncAstQuotedId | FuncAstPlainId; value: FuncAstExpression; loc: FuncSrcInfo; }; +export type FuncConstantType = "slice" | "int"; + /** * Note, that name cannot be an unusedId * @@ -761,7 +763,7 @@ export type FuncAstStatement = */ export type FuncAstStatementReturn = { kind: "statement_return"; - expression: FuncAstExpression; + expression: FuncAstExpression | undefined; loc: FuncSrcInfo; }; @@ -954,9 +956,9 @@ export type FuncOpAssign = */ export type FuncAstExpressionConditional = { kind: "expression_conditional"; - condition: FuncAstExpressionCompare; + condition: FuncAstExpression; consequence: FuncAstExpression; - alternative: FuncAstExpressionConditional; + alternative: FuncAstExpression; loc: FuncSrcInfo; }; @@ -965,30 +967,32 @@ export type FuncAstExpressionConditional = { */ export type FuncAstExpressionCompare = { kind: "expression_compare"; - left: FuncAstExpressionBitwiseShift; + left: FuncAstExpression; op: FuncOpCompare; - right: FuncAstExpressionBitwiseShift; + right: FuncAstExpression; loc: FuncSrcInfo; }; -export type FuncOpCompare = "==" | "<=>" | "<=" | "<" | ">=" | ">" | "!="; +export const funcOpCompare = ["==", "<=>", "<=", "<", ">=", ">", "!="] as const; +export type FuncOpCompare = (typeof funcOpCompare)[number]; /** * parse_expr17 */ export type FuncAstExpressionBitwiseShift = { kind: "expression_bitwise_shift"; - left: FuncAstExpressionAddBitwise; + left: FuncAstExpression; ops: FuncExpressionBitwiseShiftPart[]; loc: FuncSrcInfo; }; export type FuncExpressionBitwiseShiftPart = { op: FuncOpBitwiseShift; - expr: FuncAstExpressionAddBitwise; + expr: FuncAstExpression; }; -export type FuncOpBitwiseShift = "<<" | ">>" | "~>>" | "^>>"; +export const funcOpBitwiseShift = ["<<", ">>", "~>>", "^>>"] as const; +export type FuncOpBitwiseShift = (typeof funcOpBitwiseShift)[number]; /** * Note, that sometimes `ops` can be an empty array, due to the unary minus (`negateLeft`) @@ -998,43 +1002,46 @@ export type FuncOpBitwiseShift = "<<" | ">>" | "~>>" | "^>>"; export type FuncAstExpressionAddBitwise = { kind: "expression_add_bitwise"; negateLeft: boolean; - left: FuncAstExpressionMulBitwise; + left: FuncAstExpression; ops: FuncExpressionAddBitwisePart[]; loc: FuncSrcInfo; }; export type FuncExpressionAddBitwisePart = { op: FuncOpAddBitwise; - expr: FuncAstExpressionMulBitwise; + expr: FuncAstExpression; }; -export type FuncOpAddBitwise = "+" | "-" | "|" | "^"; +export const funcOpAddBitwise = ["+", "-", "|", "^"] as const; +export type FuncOpAddBitwise = (typeof funcOpAddBitwise)[number]; /** * parse_expr30 */ export type FuncAstExpressionMulBitwise = { kind: "expression_mul_bitwise"; - left: FuncAstExpressionUnary; - ops: FuncExpressionMulBitwiseOp[]; + left: FuncAstExpression; + ops: FuncBitwiseExpressionPart[]; loc: FuncSrcInfo; }; -export type FuncExpressionMulBitwiseOp = { +export type FuncBitwiseExpressionPart = { op: FuncOpMulBitwise; - expr: FuncAstExpressionUnary; + expr: FuncAstExpression; }; -export type FuncOpMulBitwise = - | "*" - | "/%" - | "/" - | "%" - | "~/" - | "~%" - | "^/" - | "^%" - | "&"; +export const funcOpMulBitwise = [ + "*", + "/%", + "/", + "%", + "~/", + "~%", + "^/", + "^%", + "&" +] as const; +export type FuncOpMulBitwise = (typeof funcOpMulBitwise)[number]; /** * parse_expr75 @@ -1042,7 +1049,7 @@ export type FuncOpMulBitwise = export type FuncAstExpressionUnary = { kind: "expression_unary"; op: FuncOpUnary; - operand: FuncAstExpressionMethod; + operand: FuncAstExpression; loc: FuncSrcInfo; }; @@ -1168,13 +1175,13 @@ export type FuncAstTernaryExpression = FuncAstExpressionConditional; * Expression op Expression */ export type FuncAstBinaryExpression = - | FuncAstExpressionAssign - | FuncAstExpressionConditional | FuncAstExpressionCompare | FuncAstExpressionBitwiseShift | FuncAstExpressionAddBitwise | FuncAstExpressionMulBitwise; +export type FuncBinaryOp = FuncOpCompare | FuncOpBitwiseShift | FuncOpAddBitwise | FuncOpMulBitwise + /** * op Expression * @@ -1407,23 +1414,33 @@ export type FuncAstComment = FuncAstCommentSingleLine | FuncAstCommentMultiLine; export type FuncAstCommentSingleLine = { kind: "comment_singleline"; line: string; + style: ";" | ";;"; loc: FuncSrcInfo; }; /** * {- ...can be nested... -} + * or + * ;; line1 + * ;; line2 * - * Doesn't include the leftmost {- and rightmost -} + * Doesn't include the leftmost {- and rightmost -} or leading ;; * * @field skipCR If set to true, skips CR before the next line */ export type FuncAstCommentMultiLine = { kind: "comment_multiline"; - contents: string; + lines: string[]; skipCR: boolean; + style: "{-" | ";" | ";;"; loc: FuncSrcInfo; }; +export type FuncAstCR = { + kind: "cr", + lines: number, +}; + // // AST generation through syntax analysis // @@ -1445,6 +1462,7 @@ semantics.addOperation("astOfModule", { return { kind: "comment_singleline", line: lineContents.sourceString, + style: ";;", loc: createSrcInfo(this), }; }, @@ -1460,12 +1478,13 @@ semantics.addOperation("astOfModule", { ) { return { kind: "comment_multiline", - contents: [ + lines: [ preInnerComment.sourceString, innerComment.children.map((x) => x.astOfModule()).join("") ?? "", postInnerComment.sourceString, - ].join(""), + ], + style: "{-", skipCR: false, loc: createSrcInfo(this), }; diff --git a/src/func/syntax.ts b/src/func/syntax.ts deleted file mode 100644 index d8cf79527..000000000 --- a/src/func/syntax.ts +++ /dev/null @@ -1,420 +0,0 @@ -/** - * The supported version of the Func compiler: - * https://github.com/ton-blockchain/ton/blob/6897b5624566a2ab9126596d8bc4980dfbcaff2d/crypto/func/func.h#L48 - */ -export const FUNC_VERSION: string = "0.4.4"; - -/** - * Represents an ordered collection of values. - * NOTE: Unit type `()` is a special case of the tensor type. - */ -export type FuncTensorType = FuncType[]; - -// TODO: move it to syntaxConstructors -export const UNIT_TYPE: FuncType = { - kind: "tensor", - value: [] as FuncTensorType, -}; - -/** - * Type annotations available within the syntax tree. - */ -export type FuncType = - | { kind: "int" } - | { kind: "cell" } - | { kind: "slice" } - | { kind: "builder" } - | { kind: "cont" } - | { kind: "tuple" } - | { kind: "tensor"; value: FuncTensorType } - | { kind: "hole" } // hole type (`_`) filled in local type inference - | { kind: "type" }; - -// FIXME: there's no unary plus, and unary minus is handled separately from ~ -export type FuncAstUnaryOp = "-" | "~" | "+"; - -export type FuncAstBinaryOp = - | "+" - | "-" - | "*" - | "/" - | "%" - | "<" - | ">" - | "&" - | "|" - | "^" - | "==" - | "!=" - | "<=" - | ">=" - | "<=>" - | "<<" - | ">>" - | "~>>" - | "^>>" - | "~/" - | "^/" - | "~%" - | "^%" - | "/%"; - -export type FuncAstAugmentedAssignOp = - | "+=" - | "-=" - | "*=" - | "/=" - | "~/=" - | "^/=" - | "%=" - | "~%=" - | "^%=" - | "<<=" - | ">>=" - | "~>>=" - | "^>>=" - | "&=" - | "|=" - | "^="; - -export type FuncAstTmpVarClass = "In" | "Named" | "Tmp" | "UniqueName"; - -interface FuncAstVarDescrFlags { - Last: boolean; - Unused: boolean; - Const: boolean; - Int: boolean; - Zero: boolean; - NonZero: boolean; - Pos: boolean; - Neg: boolean; - Bool: boolean; - Bit: boolean; - Finite: boolean; - Nan: boolean; - Even: boolean; - Odd: boolean; - Null: boolean; - NotNull: boolean; -} - -// -// Expressions -// - -export type FuncAstLiteralExpr = - | FuncAstNumberExpr - | FuncAstHexNumberExpr - | FuncAstBoolExpr - | FuncAstStringExpr - | FuncAstNilExpr; -export type FuncAstSimpleExpr = - | FuncAstIdExpr - | FuncAstTupleExpr - | FuncAstTensorExpr - | FuncAstUnitExpr - | FuncAstHoleExpr - | FuncAstPrimitiveTypeExpr; -export type FuncAstCompositeExpr = - | FuncAstCallExpr - | FuncAstAssignExpr - | FuncAstAugmentedAssignExpr - | FuncAstTernaryExpr - | FuncAstBinaryExpr - | FuncAstUnaryExpr - | FuncAstApplyExpr; -export type FuncAstExpr = - | FuncAstLiteralExpr - | FuncAstSimpleExpr - | FuncAstCompositeExpr; - -export type FuncAstIdExpr = { - kind: "id_expr"; - value: string; -}; - -export type FuncAstCallExpr = { - kind: "call_expr"; - // Returns the function object, e.g. get_value().load_int() - // ^^^^^^^^^^^ - receiver: FuncAstExpr | undefined; - fun: FuncAstExpr; // function name - args: FuncAstExpr[]; -}; - -export type FuncAstAssignExpr = { - kind: "assign_expr"; - lhs: FuncAstExpr; - rhs: FuncAstExpr; -}; - -// Augmented assignment: a += 42; -export type FuncAstAugmentedAssignExpr = { - kind: "augmented_assign_expr"; - lhs: FuncAstExpr; - op: FuncAstAugmentedAssignOp; - rhs: FuncAstExpr; -}; - -export type FuncAstTernaryExpr = { - kind: "ternary_expr"; - cond: FuncAstExpr; - trueExpr: FuncAstExpr; - falseExpr: FuncAstExpr; -}; - -export type FuncAstBinaryExpr = { - kind: "binary_expr"; - lhs: FuncAstExpr; - op: FuncAstBinaryOp; - rhs: FuncAstExpr; -}; - -export type FuncAstUnaryExpr = { - kind: "unary_expr"; - op: FuncAstUnaryOp; - value: FuncAstExpr; -}; - -export type FuncAstNumberExpr = { - kind: "number_expr"; - value: bigint; -}; - -export type FuncAstHexNumberExpr = { - kind: "hex_number_expr"; - value: string; -}; - -export type FuncAstBoolExpr = { - kind: "bool_expr"; - value: boolean; -}; - -/** - * An additional modifier. See: https://docs.ton.org/develop/func/literals_identifiers#string-literals - */ -export type FuncStringLiteralType = "s" | "a" | "u" | "h" | "H" | "c"; - -export type FuncAstStringExpr = { - kind: "string_expr"; - value: string; - ty: FuncStringLiteralType | undefined; -}; - -export type FuncAstNilExpr = { - kind: "nil_expr"; -}; - -export type FuncAstApplyExpr = { - kind: "apply_expr"; - lhs: FuncAstExpr; - rhs: FuncAstExpr; -}; - -export type FuncAstTupleExpr = { - kind: "tuple_expr"; - values: FuncAstExpr[]; -}; - -export type FuncAstTensorExpr = { - kind: "tensor_expr"; - values: FuncAstExpr[]; -}; - -export type FuncAstUnitExpr = { - kind: "unit_expr"; -}; - -// Defines a variable applying the local type inference rules: -// var x = 2; -// _ = 2; -export type FuncAstHoleExpr = { - kind: "hole_expr"; - id: string | undefined; - init: FuncAstExpr; -}; - -// Primitive types are used in the syntax tree to express polymorphism. -export type FuncAstPrimitiveTypeExpr = { - kind: "primitive_type_expr"; - ty: FuncType; -}; - -// -// Statements -// - -export type FuncAstStmt = - | FuncAstComment // A comment appearing among statements - | FuncAstCR // An extra newline separating block of statements - | FuncAstBlockStmt - | FuncAstVarDefStmt - | FuncAstReturnStmt - | FuncAstRepeatStmt - | FuncAstConditionStmt - | FuncAstDoUntilStmt - | FuncAstWhileStmt - | FuncAstExprStmt - | FuncAstTryCatchStmt; - -// Local variable definition: -// int x = 2; // ty = int -// var x = 2; // ty is undefined -// var (x, y) = 2; // ty is undefined; names = ["x", "y"] -export type FuncAstVarDefStmt = { - kind: "var_def_stmt"; - names: FuncAstIdExpr[]; - ty: FuncType | undefined; - init: FuncAstExpr | undefined; -}; - -export type FuncAstReturnStmt = { - kind: "return_stmt"; - value: FuncAstExpr | undefined; -}; - -export type FuncAstBlockStmt = { - kind: "block_stmt"; - body: FuncAstStmt[]; -}; - -export type FuncAstRepeatStmt = { - kind: "repeat_stmt"; - condition: FuncAstExpr; - body: FuncAstStmt[]; -}; - -export type FuncAstConditionStmt = { - kind: "condition_stmt"; - condition?: FuncAstExpr; - ifnot: boolean; // negation: ifnot or elseifnot attribute - body: FuncAstStmt[]; - else?: FuncAstConditionStmt; -}; - -export type FuncAstDoUntilStmt = { - kind: "do_until_stmt"; - body: FuncAstStmt[]; - condition: FuncAstExpr; -}; - -export type FuncAstWhileStmt = { - kind: "while_stmt"; - condition: FuncAstExpr; - body: FuncAstStmt[]; -}; - -export type FuncAstExprStmt = { - kind: "expr_stmt"; - expr: FuncAstExpr; -}; - -export type FuncAstTryCatchStmt = { - kind: "try_catch_stmt"; - tryBlock: FuncAstStmt[]; - catchBlock: FuncAstStmt[]; - catchVar: FuncAstIdExpr | undefined; -}; - -// -// Other and top-level elements -// - -export type FuncAstConstant = { - kind: "constant"; - ty: FuncType; - init: FuncAstExpr; -}; - -export type FuncAstFunctionAttribute = - | { kind: "impure" } - | { kind: "inline" } - | { kind: "inline_ref" } - | { kind: "method_id"; value: number | undefined }; - -export type FuncAstFormalFunctionParam = { - kind: "function_param"; - name: FuncAstIdExpr; - ty: FuncType; -}; - -export type FuncAstFunctionDeclaration = { - kind: "function_declaration"; - name: FuncAstIdExpr; - attrs: FuncAstFunctionAttribute[]; - params: FuncAstFormalFunctionParam[]; - returnTy: FuncType; -}; - -export type FuncAstFunctionDefinition = { - kind: "function_definition"; - name: FuncAstIdExpr; - attrs: FuncAstFunctionAttribute[]; - params: FuncAstFormalFunctionParam[]; - returnTy: FuncType; - body: FuncAstStmt[]; -}; - -// e.g.: int preload_uint(slice s, int len) asm "PLDUX"; -export type FuncAstAsmFunction = { - kind: "asm_function_definition"; - name: FuncAstIdExpr; - attrs: FuncAstFunctionAttribute[]; - params: FuncAstFormalFunctionParam[]; - returnTy: FuncType; - rawAsm: FuncAstStringExpr; // Raw TVM assembly -}; - -export type FuncAstComment = { - kind: "comment"; - values: string[]; // Represents multiline comments - skipCR: boolean; // Skips CR before the next line - style: ";" | ";;"; -}; - -export type FuncAstCR = { - kind: "cr"; - lines: number; // Number of newline symbols -}; - -export type FuncAstInclude = { - kind: "include"; - value: string; -}; - -export type FuncAstPragma = { - kind: "pragma"; - value: string; -}; - -export type FuncAstGlobalVariable = { - kind: "global_variable"; - name: FuncAstIdExpr; - ty: FuncType; -}; - -export type FuncAstModuleEntry = - | FuncAstInclude - | FuncAstPragma - | FuncAstFunctionDeclaration - | FuncAstFunctionDefinition - | FuncAstAsmFunction - | FuncAstComment - | FuncAstConstant - | FuncAstGlobalVariable; - -/** - * Represents a single Func file. - */ -export type FuncAstModule = { - kind: "module"; - entries: FuncAstModuleEntry[]; -}; - -export type FuncAstNode = - | FuncAstStmt - | FuncAstExpr - | FuncAstModule - | FuncAstModuleEntry - | FuncType; diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index f25c6b67d..cfbd79dcd 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -1,56 +1,63 @@ import { - FuncAstNumberExpr, - FuncAstHexNumberExpr, - FuncAstBoolExpr, - FuncAstStringExpr, - FuncAstNilExpr, - FuncAstIdExpr, - FuncAstCallExpr, - FuncAstAssignExpr, - FuncAstAugmentedAssignExpr, - FuncAstTernaryExpr, - FuncAstBinaryExpr, - FuncAstUnaryExpr, - FuncAstApplyExpr, - FuncAstTupleExpr, - FuncAstTensorExpr, - FuncAstUnitExpr, - FuncAstHoleExpr, - FuncAstPrimitiveTypeExpr, - FuncStringLiteralType, - FuncAstAugmentedAssignOp, - FuncAstBinaryOp, - FuncAstUnaryOp, - FuncAstVarDefStmt, - FuncAstReturnStmt, - FuncAstBlockStmt, - FuncAstRepeatStmt, - FuncAstConditionStmt, - FuncAstStmt, - FuncAstDoUntilStmt, - FuncAstWhileStmt, - FuncAstExprStmt, - FuncAstTryCatchStmt, - FuncAstExpr, - FuncType, - FuncAstConstant, - FuncAstFormalFunctionParam, + funcOpCompare, + funcOpBitwiseShift, + funcOpAddBitwise, + funcOpMulBitwise, + FuncAstStatementExpression, + FuncPragmaLiteralValue, + FuncAstConstantsDefinition, + FuncConstantType, + FuncAstParameter, + FuncAstCR, + FuncAstCommentSingleLine, + FuncAstCommentMultiLine, + FuncAstExpressionVarDecl, + FuncAstUnit, + FuncAstExpressionTensor, + FuncAstExpressionTuple, + FuncAstIntegerLiteral, + FuncOpUnary, + FuncAstExpressionUnary, + FuncAstExpressionFunCall, + FuncAstBinaryExpression, + FuncStringType, + FuncBinaryOp, + FuncAstExpressionAssign, + FuncAstExpressionConditional, + FuncOpAssign, + FuncAstId, + FuncAstStringLiteral, + FuncArgument, + FuncAstPlainId, + FuncAstStatementReturn, + FuncAstStatementBlock, + FuncAstStatementRepeat, + FuncAstStatementCondition, + FuncAstStatement, + FuncAstStatementUntil, + FuncAstStatementWhile, + FuncAstExpression, + FuncAstStatementTryCatch, + FuncAstType, FuncAstFunctionAttribute, FuncAstFunctionDeclaration, FuncAstFunctionDefinition, - FuncAstAsmFunction, + FuncAstAsmFunctionDefinition, FuncAstComment, - FuncAstCR, FuncAstInclude, FuncAstPragma, FuncAstGlobalVariable, - FuncAstModuleEntry, + FuncAstModuleItem, FuncAstModule, -} from "./syntax"; + FuncAstGlobalVariablesDeclaration, + dummySrcInfo, +} from "./grammar"; +import { dummySrcInfo as tactDummySrcInfo } from "../grammar/grammar"; +import { throwInternalCompilerError } from "../errors"; import JSONbig from "json-bigint"; -function wrapToId(v: T | string): T { +function wrapToId(v: T | string): T { if (typeof v === "string" && v.includes("[object")) { throw new Error(`Incorrect input: ${JSONbig.stringify(v, null, 2)}`); } @@ -61,58 +68,60 @@ function wrapToId(v: T | string): T { // Types // export class Type { - public static int(): FuncType { - return { kind: "int" }; + public static int(): FuncAstType { + return { kind: "type_primitive", value: "int", loc: dummySrcInfo }; } - public static cell(): FuncType { - return { kind: "cell" }; + public static cell(): FuncAstType { + return { kind: "type_primitive", value: "cell", loc: dummySrcInfo }; } - public static slice(): FuncType { - return { kind: "slice" }; + public static slice(): FuncAstType { + return { kind: "type_primitive", value: "slice", loc: dummySrcInfo }; } - public static builder(): FuncType { - return { kind: "builder" }; + public static builder(): FuncAstType { + return { kind: "type_primitive", value: "builder", loc: dummySrcInfo }; } - public static cont(): FuncType { - return { kind: "cont" }; + public static cont(): FuncAstType { + return { kind: "type_primitive", value: "cont", loc: dummySrcInfo }; } - public static tuple(): FuncType { - return { kind: "tuple" }; + public static tuple(): FuncAstType { + return { kind: "type_primitive", value: "tuple", loc: dummySrcInfo }; } - public static tensor(...value: FuncType[]): FuncType { - return { kind: "tensor", value }; + public static tensor(...types: FuncAstType[]): FuncAstType { + return { kind: "type_tensor", types, loc: dummySrcInfo }; } - public static hole(): FuncType { - return { kind: "hole" }; - } - - public static type(): FuncType { - return { kind: "type" }; + public static tuple_values(...types: FuncAstType[]): FuncAstType { + return { kind: "type_tuple", types, loc: dummySrcInfo }; } } export class FunAttr { public static impure(): FuncAstFunctionAttribute { - return { kind: "impure" }; + return { kind: "impure", loc: dummySrcInfo }; } public static inline(): FuncAstFunctionAttribute { - return { kind: "inline" }; + return { kind: "inline", loc: dummySrcInfo }; } public static inline_ref(): FuncAstFunctionAttribute { - return { kind: "inline_ref" }; + return { kind: "inline_ref", loc: dummySrcInfo }; } - public static method_id(value?: number): FuncAstFunctionAttribute { - return { kind: "method_id", value }; + public static method_id( + value?: bigint | number | string, + ): FuncAstFunctionAttribute { + const literal = + typeof value === "string" + ? string(value) + : int(value as bigint | number); + return { kind: "method_id", value: literal, loc: dummySrcInfo }; } } @@ -120,231 +129,330 @@ export class FunAttr { // Expressions // -export const number = (num: bigint | number): FuncAstNumberExpr => ({ - kind: "number_expr", - value: typeof num === "bigint" ? num : BigInt(num), -}); +function integerLiteral( + num: bigint | number, + isHex: boolean, +): FuncAstIntegerLiteral { + return { + kind: "integer_literal", + value: typeof num === "bigint" ? num : BigInt(num), + isHex, + loc: dummySrcInfo, + }; +} -export const hexnumber = (value: string): FuncAstHexNumberExpr => ({ - kind: "hex_number_expr", - value, -}); +export function int(num: bigint | number): FuncAstIntegerLiteral { + return integerLiteral(num, false); +} -export const bool = (value: boolean): FuncAstBoolExpr => ({ - kind: "bool_expr", - value, -}); +export function hex(num: bigint | number): FuncAstIntegerLiteral { + return integerLiteral(num, true); +} -export const string = ( +export function bool(value: boolean): FuncAstPlainId { + return id(`${value}`) as FuncAstPlainId; +} + +export function string( value: string, - ty?: FuncStringLiteralType, -): FuncAstStringExpr => ({ - kind: "string_expr", - value, - ty, -}); - -export const nil = (): FuncAstNilExpr => ({ - kind: "nil_expr", -}); - -export const id = (value: string): FuncAstIdExpr => ({ - kind: "id_expr", - value, -}); + ty?: FuncStringType, +): FuncAstStringLiteral { + return { + kind: "string_singleline", + value, + ty, + loc: dummySrcInfo, + }; +} + +export function nil(): FuncAstPlainId { + return id("nil") as FuncAstPlainId; +} + +export function id(value: string): FuncAstId { + if (value.length > 1 && (value.startsWith(".") || value.startsWith("~"))) { + return { + kind: "method_id", + value: value.slice(1), + prefix: value[0]! as "." | "~", + loc: dummySrcInfo, + }; + } else { + return { + kind: "plain_id", + value, + loc: dummySrcInfo, + }; + } +} export function call( - fun: FuncAstExpr | string, - args: FuncAstExpr[], - params: Partial<{ receiver: FuncAstExpr }> = {}, -): FuncAstCallExpr { - const { receiver = undefined } = params; + fun: FuncAstExpression | string, + args: FuncArgument[], + // TODO: doesn't support method calls + params: Partial<{ receiver: FuncAstExpression }> = {}, +): FuncAstExpressionFunCall { + return { + kind: "expression_fun_call", + object: wrapToId(fun) as FuncAstId, + arguments: args, + loc: dummySrcInfo, + }; +} + +export function assign( + left: FuncAstExpression, + right: FuncAstExpression, +): FuncAstExpressionAssign { + return augassign(left, "=", right); +} + +export function augassign( + left: FuncAstExpression, + op: FuncOpAssign, + right: FuncAstExpression, +): FuncAstExpressionAssign { + return { + kind: "expression_assign", + left, + op, + right, + loc: dummySrcInfo, + }; +} + +export function ternary( + cond: FuncAstExpression, + trueExpr: FuncAstExpression, + falseExpr: FuncAstExpression, +): FuncAstExpressionConditional { + return { + kind: "expression_conditional", + condition: cond, + consequence: trueExpr, + alternative: falseExpr, + loc: dummySrcInfo, + }; +} + +function isFuncOp( + str: string, + ops: T, +): str is T[number] { + return (ops as readonly string[]).includes(str); +} + +export function binop( + left: FuncAstExpression, + op: FuncBinaryOp, + right: FuncAstExpression, +): FuncAstBinaryExpression { + if (isFuncOp(op, funcOpCompare)) { + return { + kind: "expression_compare", + left, + op, + right, + loc: dummySrcInfo, + }; + } + if (isFuncOp(op, funcOpBitwiseShift)) { + return { + kind: "expression_bitwise_shift", + left, + ops: [{ op, expr: right }], + loc: dummySrcInfo, + }; + } + if (isFuncOp(op, funcOpAddBitwise)) { + return { + kind: "expression_add_bitwise", + negateLeft: false, + left, + ops: [{ op, expr: right }], + loc: dummySrcInfo, + }; + } + if (isFuncOp(op, funcOpMulBitwise)) { + return { + kind: "expression_mul_bitwise", + left, + ops: [{ op, expr: right }], + loc: dummySrcInfo, + }; + } + + throwInternalCompilerError( + `Unsupported binary operation: ${op}`, + tactDummySrcInfo, + ); +} + +export function unop( + op: FuncOpUnary, + operand: FuncAstExpression, +): FuncAstExpressionUnary { return { - kind: "call_expr", - receiver, - fun: wrapToId(fun), - args, + kind: "expression_unary", + op, + operand, + loc: dummySrcInfo, }; } -export const assign = ( - lhs: FuncAstExpr, - rhs: FuncAstExpr, -): FuncAstAssignExpr => ({ - kind: "assign_expr", - lhs, - rhs, -}); - -export const augmentedAssign = ( - lhs: FuncAstExpr, - op: FuncAstAugmentedAssignOp, - rhs: FuncAstExpr, -): FuncAstAugmentedAssignExpr => ({ - kind: "augmented_assign_expr", - lhs, - op, - rhs, -}); - -export const ternary = ( - cond: FuncAstExpr, - trueExpr: FuncAstExpr, - falseExpr: FuncAstExpr, -): FuncAstTernaryExpr => ({ - kind: "ternary_expr", - cond, - trueExpr, - falseExpr, -}); - -export const binop = ( - lhs: FuncAstExpr, - op: FuncAstBinaryOp, - rhs: FuncAstExpr, -): FuncAstBinaryExpr => ({ - kind: "binary_expr", - lhs, - op, - rhs, -}); - -export const unop = ( - op: FuncAstUnaryOp, - value: FuncAstExpr, -): FuncAstUnaryExpr => ({ - kind: "unary_expr", - op, - value, -}); - -export const apply = ( - lhs: FuncAstExpr, - rhs: FuncAstExpr, -): FuncAstApplyExpr => ({ - kind: "apply_expr", - lhs, - rhs, -}); - -export const tuple = (values: FuncAstExpr[]): FuncAstTupleExpr => ({ - kind: "tuple_expr", - values, -}); - -export const tensor = (...values: FuncAstExpr[]): FuncAstTensorExpr => ({ - kind: "tensor_expr", - values, -}); - -export const unit = (): FuncAstUnitExpr => ({ - kind: "unit_expr", -}); - -export const hole = ( - id: string | undefined, - init: FuncAstExpr, -): FuncAstHoleExpr => ({ - kind: "hole_expr", - id, - init, -}); - -export const primitiveType = (ty: FuncType): FuncAstPrimitiveTypeExpr => ({ - kind: "primitive_type_expr", - ty, -}); +export function tuple( + expressions: FuncAstExpression[], +): FuncAstExpressionTuple { + return { + kind: "expression_tuple", + expressions, + loc: dummySrcInfo, + }; +} + +export function tensor( + ...expressions: FuncAstExpression[] +): FuncAstExpressionTensor { + return { + kind: "expression_tensor", + expressions, + loc: dummySrcInfo, + }; +} + +export function unit(): FuncAstUnit { + return { kind: "unit", value: "()", loc: dummySrcInfo }; +} + +export function hole(value: "_" | "var"): FuncAstType { + return { kind: "hole", value, loc: dummySrcInfo }; +} // // Statements // export function vardef( - // TODO: replace w/ `FuncType | '_'` - ty: FuncType | undefined, - names: string | string[] | FuncAstIdExpr | FuncAstIdExpr[], - init?: FuncAstExpr, -): FuncAstVarDefStmt { + ty: FuncAstType | "_", + names: string | string[], + init?: FuncAstExpression, +): FuncAstStatement { if (Array.isArray(names) && names.length === 0) { - throw new Error( + throwInternalCompilerError( `Variable definition cannot have an empty set of names`, + tactDummySrcInfo, ); } + const varDecl: FuncAstExpressionVarDecl = { + kind: "expression_var_decl", + ty: ty === "_" ? hole("_") : ty, + names: + typeof names === "string" + ? (id(names) as FuncAstId) + : { + kind: "expression_tensor_var_decl", + names: names.map(id), + loc: dummySrcInfo, + }, + loc: dummySrcInfo, + }; + return expr(init === undefined ? varDecl : assign(varDecl, init)); +} + +export function ret(expression?: FuncAstExpression): FuncAstStatementReturn { return { - kind: "var_def_stmt", - names: Array.isArray(names) - ? names.map((v) => wrapToId(v)) - : [wrapToId(names)], - ty, - init, + kind: "statement_return", + expression, + loc: dummySrcInfo, + }; +} + +export function block(statements: FuncAstStatement[]): FuncAstStatementBlock { + return { + kind: "statement_block", + statements, + loc: dummySrcInfo, + }; +} + +export function repeat( + iterations: FuncAstExpression, + statements: FuncAstStatement[], +): FuncAstStatementRepeat { + return { + kind: "statement_repeat", + iterations, + statements, + loc: dummySrcInfo, }; } -export const ret = (value?: FuncAstExpr): FuncAstReturnStmt => ({ - kind: "return_stmt", - value, -}); - -export const block = (body: FuncAstStmt[]): FuncAstBlockStmt => ({ - kind: "block_stmt", - body, -}); - -export const repeat = ( - condition: FuncAstExpr, - body: FuncAstStmt[], -): FuncAstRepeatStmt => ({ - kind: "repeat_stmt", - condition, - body, -}); - -export const condition = ( - condition: FuncAstExpr | undefined, - body: FuncAstStmt[], - ifnot: boolean = false, - elseStmt?: FuncAstConditionStmt, -): FuncAstConditionStmt => ({ - kind: "condition_stmt", - condition, - ifnot, - body, - else: elseStmt, -}); - -export const doUntil = ( - body: FuncAstStmt[], - condition: FuncAstExpr, -): FuncAstDoUntilStmt => ({ - kind: "do_until_stmt", - body, - condition, -}); - -export const while_ = ( - condition: FuncAstExpr, - body: FuncAstStmt[], -): FuncAstWhileStmt => ({ - kind: "while_stmt", - condition, - body, -}); - -export const expr = (expr: FuncAstExpr): FuncAstExprStmt => ({ - kind: "expr_stmt", - expr, -}); - -export const tryCatch = ( - tryBlock: FuncAstStmt[], - catchBlock: FuncAstStmt[], - catchVar?: string | FuncAstIdExpr, -): FuncAstTryCatchStmt => ({ - kind: "try_catch_stmt", - tryBlock, - catchBlock, - catchVar: catchVar === undefined ? undefined : wrapToId(catchVar), -}); +export function condition( + condition: FuncAstExpression, + body: FuncAstStatement[], + elseStmts?: FuncAstStatement[], + params: Partial<{ positive: boolean }> = {}, +): FuncAstStatementCondition { + const { positive = false } = params; + return { + kind: "statement_condition_if", + condition, + positive, + consequences: body, + alternatives: elseStmts, + loc: dummySrcInfo, + }; +} + +export function doUntil( + condition: FuncAstExpression, + statements: FuncAstStatement[], +): FuncAstStatementUntil { + return { + kind: "statement_until", + statements, + condition, + loc: dummySrcInfo, + }; +} + +export function while_( + condition: FuncAstExpression, + statements: FuncAstStatement[], +): FuncAstStatementWhile { + return { + kind: "statement_while", + condition, + statements, + loc: dummySrcInfo, + }; +} + +export function expr( + expression: FuncAstExpression, +): FuncAstStatementExpression { + return { + kind: "statement_expression", + expression, + loc: dummySrcInfo, + }; +} + +export function tryCatch( + statementsTry: FuncAstStatement[], + catchExceptionName: string | FuncAstId, + catchExitCodeName: string | FuncAstId, + statementsCatch: FuncAstStatement[], +): FuncAstStatementTryCatch { + return { + kind: "statement_try_catch", + statementsTry, + catchExceptionName: wrapToId(catchExceptionName), + catchExitCodeName: wrapToId(catchExitCodeName), + statementsCatch, + loc: dummySrcInfo, + }; +} // Other top-level elements @@ -359,131 +467,189 @@ export function comment( } values = args as string[]; const { skipCR = false, style = ";;" } = params; + return values.length === 1 + ? ({ + kind: "comment_singleline", + line: values[0], + style, + loc: dummySrcInfo, + } as FuncAstCommentSingleLine) + : ({ + kind: "comment_multiline", + lines: values, + skipCR, + style, + loc: dummySrcInfo, + } as FuncAstCommentMultiLine); +} + +export function cr(lines: number = 1): FuncAstCR { + return { + kind: "cr", + lines, + }; +} + +export function constant( + name: string | FuncAstId, + init: FuncAstExpression, + ty?: FuncConstantType, +): FuncAstConstantsDefinition { + return { + kind: "constants_definition", + constants: [ + { + kind: "constant", + ty, + name: wrapToId(name) as FuncAstPlainId, + value: init, + loc: dummySrcInfo, + }, + ], + loc: dummySrcInfo, + }; +} + +export function functionParam( + name: string | FuncAstPlainId, + ty: FuncAstType | undefined, +): FuncAstParameter { + return { + kind: "parameter", + name: wrapToId(name), + ty, + loc: dummySrcInfo, + }; +} + +export function functionDeclaration( + name: string | FuncAstPlainId, + parameters: FuncAstParameter[], + attributes: FuncAstFunctionAttribute[], + returnTy: FuncAstType, +): FuncAstFunctionDeclaration { return { - kind: "comment", - values, - skipCR, - style, + kind: "function_declaration", + forall: undefined, + name: wrapToId(name), + parameters, + attributes, + returnTy, + loc: dummySrcInfo, }; } -export const cr = (lines: number = 1): FuncAstCR => ({ - kind: "cr", - lines, -}); - -export const constant = (ty: FuncType, init: FuncAstExpr): FuncAstConstant => ({ - kind: "constant", - ty, - init, -}); - -export const functionParam = ( - name: string | FuncAstIdExpr, - ty: FuncType, -): FuncAstFormalFunctionParam => ({ - kind: "function_param", - name: wrapToId(name), - ty, -}); - -export const functionDeclaration = ( - name: string | FuncAstIdExpr, - attrs: FuncAstFunctionAttribute[], - params: FuncAstFormalFunctionParam[], - returnTy: FuncType, -): FuncAstFunctionDeclaration => ({ - kind: "function_declaration", - name: wrapToId(name), - attrs, - params, - returnTy, -}); - -export type FunParamValue = [string, FuncType]; +export type FunParamValue = [string, FuncAstType]; function transformFunctionParams( paramValues: FunParamValue[], -): FuncAstFormalFunctionParam[] { +): FuncAstParameter[] { return paramValues.map( ([name, ty]) => ({ - kind: "function_param", + kind: "parameter", name: wrapToId(name), ty, - }) as FuncAstFormalFunctionParam, + loc: dummySrcInfo, + }) as FuncAstParameter, ); } -export const fun = ( - attrs: FuncAstFunctionAttribute[], - name: string | FuncAstIdExpr, +export function fun( + name: string | FuncAstId, paramValues: FunParamValue[], - returnTy: FuncType, - body: FuncAstStmt[], -): FuncAstFunctionDefinition => { + attributes: FuncAstFunctionAttribute[], + returnTy: FuncAstType, + statements: FuncAstStatement[], +): FuncAstFunctionDefinition { return { kind: "function_definition", - name: wrapToId(name), - attrs, - params: transformFunctionParams(paramValues), + forall: undefined, + name: wrapToId(name) as FuncAstPlainId, + attributes, + parameters: transformFunctionParams(paramValues), returnTy, - body, + statements, + loc: dummySrcInfo, }; -}; +} -export const asmfun = ( - attrs: FuncAstFunctionAttribute[], - name: string | FuncAstIdExpr, +export function asmfun( + name: string | FuncAstId, paramValues: FunParamValue[], - returnTy: FuncType, - asm: string, -): FuncAstAsmFunction => { + attributes: FuncAstFunctionAttribute[], + returnTy: FuncAstType, + asmStrings: string[], +): FuncAstAsmFunctionDefinition { return { kind: "asm_function_definition", - name: wrapToId(name), - attrs, - params: transformFunctionParams(paramValues), + forall: undefined, + name: wrapToId(name) as FuncAstPlainId, + attributes, + parameters: transformFunctionParams(paramValues), returnTy, - rawAsm: string(asm), + arrangement: undefined, + asmStrings: asmStrings.map((a) => string(a)), + loc: dummySrcInfo, }; -}; +} export function toDeclaration( def: FuncAstFunctionDefinition, ): FuncAstFunctionDeclaration { return { kind: "function_declaration", - attrs: def.attrs, - name: def.name, - params: def.params, + forall: def.forall, returnTy: def.returnTy, + attributes: def.attributes, + name: def.name, + parameters: def.parameters, + loc: dummySrcInfo, }; } -export const include = (value: string): FuncAstInclude => ({ - kind: "include", - value, -}); - -export const pragma = (value: string): FuncAstPragma => ({ - kind: "pragma", - value, -}); - -export const global = ( - ty: FuncType, - name: string | FuncAstIdExpr, -): FuncAstGlobalVariable => ({ - kind: "global_variable", - name: wrapToId(name), - ty, -}); - -export const moduleEntry = (entry: FuncAstModuleEntry): FuncAstModuleEntry => - entry; - -export const mod = (...entries: FuncAstModuleEntry[]): FuncAstModule => ({ - kind: "module", - entries, -}); +export function include(path: string): FuncAstInclude { + return { + kind: "include", + path: string(path), + loc: dummySrcInfo, + }; +} + +export function pragma(value: FuncPragmaLiteralValue): FuncAstPragma { + return { + kind: "pragma_literal", + literal: value, + loc: dummySrcInfo, + }; +} + +export function global( + ty: FuncAstType, + name: string | FuncAstId, +): FuncAstGlobalVariablesDeclaration { + return { + kind: "global_variables_declaration", + globals: [ + { + kind: "global_variable", + name: wrapToId(name), + ty, + loc: dummySrcInfo, + } as FuncAstGlobalVariable, + ], + loc: dummySrcInfo, + }; +} + +export function moduleEntry(entry: FuncAstModuleItem): FuncAstModuleItem { + return entry; +} + +export function mod(...items: FuncAstModuleItem[]): FuncAstModule { + return { + kind: "module", + items, + loc: dummySrcInfo, + }; +} From 8d1d508ab0a2977dc4271184e9117813d50392a2 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 26 Aug 2024 12:19:16 +0000 Subject: [PATCH 114/162] feat(codegen): Adapted the codegen --- src/codegen/abi.ts | 4 +- src/codegen/context.ts | 34 +- src/codegen/expression.ts | 21 +- src/codegen/function.ts | 25 +- src/codegen/generator.ts | 41 +- src/codegen/literal.ts | 23 +- src/codegen/module.ts | 222 ++-- src/codegen/statement.ts | 22 +- src/codegen/stdlib.ts | 2168 -------------------------------- src/codegen/type.ts | 10 +- src/codegen/util.ts | 6 +- src/func/grammar.ts | 10 +- src/func/syntaxConstructors.ts | 47 +- 13 files changed, 246 insertions(+), 2387 deletions(-) diff --git a/src/codegen/abi.ts b/src/codegen/abi.ts index 55ec6a956..0c30789db 100644 --- a/src/codegen/abi.ts +++ b/src/codegen/abi.ts @@ -1,7 +1,7 @@ import { AstExpression, SrcInfo } from "../grammar/ast"; import { CompilerContext } from "../context"; import { TypeRef } from "../types/types"; -import { FuncAstExpr } from "../func/syntax"; +import { FuncAstExpression } from "../func/grammar"; /** * A static map of functions defining Func expressions for Tact ABI functions and methods. @@ -13,7 +13,7 @@ export type AbiFunction = { args: TypeRef[], resolved: AstExpression[], loc: SrcInfo, - ) => FuncAstExpr; + ) => FuncAstExpression; }; // TODO diff --git a/src/codegen/context.ts b/src/codegen/context.ts index 461fe2db7..48842d086 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -2,12 +2,12 @@ import { CompilerContext } from "../context"; import { topologicalSort } from "../utils/utils"; import { FuncAstFunctionDefinition, - FuncAstAsmFunction, + FuncAstAsmFunctionDefinition , FuncAstFunctionAttribute, - FuncAstIdExpr, - FuncType, - FuncAstStmt, -} from "../func/syntax"; + FuncAstId, + FuncAstType, + FuncAstStatement, +} from "../func/grammar"; import { asmfun, fun, FunParamValue } from "../func/syntaxConstructors"; import { forEachExpression } from "../func/iterators"; @@ -70,7 +70,7 @@ export class Location { export type WrittenFunction = { name: string; - definition: FuncAstFunctionDefinition | FuncAstAsmFunction | undefined; + definition: FuncAstFunctionDefinition | FuncAstAsmFunctionDefinition | undefined; kind: BodyKind; context: LocationContext | undefined; depends: Set; @@ -116,7 +116,7 @@ export class WriterContext { public save( value: | FuncAstFunctionDefinition - | FuncAstAsmFunction + | FuncAstAsmFunctionDefinition | { name: string; kind: "name_only" }, params: Partial = {}, ): void { @@ -128,7 +128,7 @@ export class WriterContext { let name: string; let definition: | FuncAstFunctionDefinition - | FuncAstAsmFunction + | FuncAstAsmFunctionDefinition | undefined; if (value.kind === "name_only") { name = value.name; @@ -136,7 +136,7 @@ export class WriterContext { } else { const defValue = value as | FuncAstFunctionDefinition - | FuncAstAsmFunction; + | FuncAstAsmFunctionDefinition; name = defValue.name.value; definition = defValue; } @@ -160,13 +160,13 @@ export class WriterContext { */ public fun( attrs: FuncAstFunctionAttribute[], - name: string | FuncAstIdExpr, + name: string | FuncAstId, paramValues: FunParamValue[], - returnTy: FuncType, - body: FuncAstStmt[], + returnTy: FuncAstType, + body: FuncAstStatement[], params: Partial = {}, ): FuncAstFunctionDefinition { - const f = fun(attrs, name, paramValues, returnTy, body); + const f = fun(name, paramValues, attrs, returnTy, body); this.save(f, params); return f; } @@ -185,13 +185,13 @@ export class WriterContext { */ public asm( attrs: FuncAstFunctionAttribute[], - name: string | FuncAstIdExpr, + name: string | FuncAstId, paramValues: FunParamValue[], - returnTy: FuncType, + returnTy: FuncAstType, rawAsm: string, params: Partial = {}, - ): FuncAstAsmFunction { - const f = asmfun(attrs, name, paramValues, returnTy, rawAsm); + ): FuncAstAsmFunctionDefinition { + const f = asmfun(name, paramValues, attrs, returnTy, [rawAsm]); this.save(f, params); return f; } diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts index 04a6458e8..d4f91a2a9 100644 --- a/src/codegen/expression.ts +++ b/src/codegen/expression.ts @@ -23,7 +23,7 @@ import { eqNames, tryExtractPath, } from "../grammar/ast"; -import { FuncAstExpr, FuncAstUnaryOp, FuncAstIdExpr } from "../func/syntax"; +import { FuncAstExpression, FuncOpUnary, FuncAstId } from "../func/grammar"; import { id, call, @@ -37,11 +37,11 @@ function isNull(f: AstExpression): boolean { return f.kind === "null"; } -function addUnary(op: FuncAstUnaryOp, expr: FuncAstExpr): FuncAstExpr { +function addUnary(op: FuncOpUnary, expr: FuncAstExpression): FuncAstExpression { return unop(op, expr); } -function negate(expr: FuncAstExpr): FuncAstExpr { +function negate(expr: FuncAstExpression): FuncAstExpression { return addUnary("~", expr); } @@ -49,7 +49,7 @@ function negate(expr: FuncAstExpr): FuncAstExpr { * Creates a Func identifier in the following format: a'b'c. * TODO: make it a static method */ -export function writePathExpression(path: AstId[]): FuncAstIdExpr { +export function writePathExpression(path: AstId[]): FuncAstId { return id( [funcIdOf(idText(path[0]!)), ...path.slice(1).map(idText)].join(`'`), ); @@ -74,7 +74,7 @@ export class ExpressionGen { return new ExpressionGen(ctx, tactExpr); } - public writeExpression(): FuncAstExpr { + public writeExpression(): FuncAstExpression { // literals and constant expressions are covered here try { const value = evalConstantExpression(this.tactExpr, this.ctx.ctx); @@ -106,6 +106,7 @@ export class ExpressionGen { if (t.kind === "ref_bounced") { const tt = getType(this.ctx.ctx, t.name); if (tt.kind === "struct") { + // TODO: ? const value = resolveFuncTypeUnpack( this.ctx.ctx, t, @@ -593,7 +594,7 @@ export class ExpressionGen { this.tactExpr.self.kind === "id" || this.tactExpr.self.kind === "field_access" ) { - if (selfExpr.kind !== "id_expr") { + if (selfExpr.kind !== "plain_id") { throw new Error( `Impossible self kind: ${selfExpr.kind}`, ); @@ -671,20 +672,20 @@ export class ExpressionGen { throw Error(`Unknown expression: ${this.tactExpr.kind}`); } - private makeValue(val: Value): FuncAstExpr { + private makeValue(val: Value): FuncAstExpression { return LiteralGen.fromTact(this.ctx, val).writeValue(); } - private makeExpr(src: AstExpression): FuncAstExpr { + private makeExpr(src: AstExpression): FuncAstExpression { return ExpressionGen.fromTact(this.ctx, src).writeExpression(); } - public writeCastedExpression(to: TypeRef): FuncAstExpr { + public writeCastedExpression(to: TypeRef): FuncAstExpression { const expr = getExpType(this.ctx.ctx, this.tactExpr); return cast(this.ctx.ctx, expr, to, this.writeExpression()); } - private makeCastedExpr(src: AstExpression, to: TypeRef): FuncAstExpr { + private makeCastedExpr(src: AstExpression, to: TypeRef): FuncAstExpression { return ExpressionGen.fromTact(this.ctx, src).writeCastedExpression(to); } } diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 2a610896d..1da22be23 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -4,17 +4,16 @@ import { ops, funcIdOf } from "./util"; import { TypeDescription, FunctionDescription, TypeRef } from "../types/types"; import { FuncAstFunctionDefinition, - FuncAstStmt, + FuncAstStatement, FuncAstFunctionAttribute, - FuncAstExpr, - FuncType, -} from "../func/syntax"; + FuncAstExpression, + FuncAstType, +} from "../func/grammar"; import { id, call, ret, FunAttr, - fun, vardef, Type, tensor, @@ -112,7 +111,7 @@ export class FunctionGen { // returnsStr = resolveFuncTypeUnpack(ctx, self, funcIdOf("self")); } - const params: [string, FuncType][] = tactFun.params.reduce( + const params: [string, FuncAstType][] = tactFun.params.reduce( (acc, a) => { acc.push([ funcIdOf(a.name), @@ -142,7 +141,7 @@ export class FunctionGen { // } // Write function body - const body: FuncAstStmt[] = []; + const body: FuncAstStatement[] = []; // Add arguments if (self) { @@ -151,8 +150,8 @@ export class FunctionGen { self, funcIdOf("self"), ); - const init: FuncAstExpr = id(funcIdOf("self")); - body.push(vardef(undefined, varName, init)); + const init: FuncAstExpression = id(funcIdOf("self")); + body.push(vardef('_', varName, init)); } for (const a of tactFun.ast.params) { if ( @@ -163,8 +162,8 @@ export class FunctionGen { resolveTypeRef(this.ctx.ctx, a.type), funcIdOf(a.name), ); - const init: FuncAstExpr = id(funcIdOf(a.name)); - body.push(vardef(undefined, name, init)); + const init: FuncAstExpression = id(funcIdOf(a.name)); + body.push(vardef('_', name, init)); } } @@ -214,7 +213,7 @@ export class FunctionGen { // is a perfectly fine Tact structure, but its constructor would // have the wrong parameter name: `$Foo$_constructor_type(int type)` const avoidFunCKeywordNameClash = (p: string) => `$${p}`; - const params: [string, FuncType][] = args.map((arg: string) => [ + const params: [string, FuncAstType][] = args.map((arg: string) => [ avoidFunCKeywordNameClash(arg), resolveFuncType( this.ctx.ctx, @@ -222,7 +221,7 @@ export class FunctionGen { ), ]); // Create expressions used in actual arguments - const values: FuncAstExpr[] = type.fields.map((v) => { + const values: FuncAstExpression[] = type.fields.map((v) => { const arg = args.find((v2) => v2 === v.name); if (arg) { return id(avoidFunCKeywordNameClash(arg)); diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 1d0c0c32a..75ffd51fb 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -10,13 +10,14 @@ import { FuncFormatter } from "../func/formatter"; import { FuncAstModule, FuncAstFunctionDefinition, - FuncAstAsmFunction, -} from "../func/syntax"; + FuncAstAsmFunctionDefinition, +} from "../func/grammar"; import { deepCopy } from "../func/syntaxUtils"; import { comment, mod, pragma, +version, Type, include, global, @@ -116,14 +117,10 @@ export class FuncGenerator { // TODO // Finalize and dump the main contract, as we have just obtained the structure of the project - m.entries.unshift(...generated.files.map((f) => include(f.name))); - m.entries.unshift( - ...[ - `version =${CODEGEN_FUNC_VERSION}`, - "allow-post-modification", - "compute-asm-ltr", - ].map(pragma), - ); + m.items.unshift(...generated.files.map((f) => include(f.name))); + m.items.push(version("=", CODEGEN_FUNC_VERSION)); + m.items.push(pragma("allow-post-modification")); + m.items.push(pragma("compute-asm-ltr")); generated.files.push({ name: `${this.basename}.code.fc`, code: new FuncFormatter().dump(m), @@ -159,7 +156,7 @@ export class FuncGenerator { ): void { // FIXME: We should add only contract methods and special methods here => add attribute and register them in the context const m = mod(); - m.entries.push( + m.items.push( comment( "", `Header files for ${this.abiSrc.name}`, @@ -173,19 +170,19 @@ export class FuncGenerator { f.definition !== undefined && f.definition.kind === "function_definition" ) { - m.entries.push( + m.items.push( comment(f.definition.name.value, { skipCR: true }), ); const copiedDefinition = deepCopy(f.definition); if ( - copiedDefinition.attrs.find( + copiedDefinition.attributes.find( (attr) => attr.kind !== "impure" && attr.kind !== "inline", ) ) { - copiedDefinition.attrs.push(FunAttr.inline_ref()); + copiedDefinition.attributes.push(FunAttr.inline_ref()); } - m.entries.push(toDeclaration(copiedDefinition)); + m.items.push(toDeclaration(copiedDefinition)); } }); generated.files.push({ @@ -199,15 +196,15 @@ export class FuncGenerator { functions: WrittenFunction[], ): void { const m = mod(); - m.entries.push( + m.items.push( global( Type.tensor(Type.int(), Type.slice(), Type.int(), Type.slice()), "__tact_context", ), ); - m.entries.push(global(Type.slice(), "__tact_context_sender")); - m.entries.push(global(Type.cell(), "__tact_context_sys")); - m.entries.push(global(Type.int(), "__tact_randomized")); + m.items.push(global(Type.slice(), "__tact_context_sender")); + m.items.push(global(Type.cell(), "__tact_context_sys")); + m.items.push(global(Type.int(), "__tact_randomized")); const stdlibFunctions = this.tryExtractModule( functions, @@ -218,7 +215,7 @@ export class FuncGenerator { generated.imported.push("stdlib"); } stdlibFunctions.forEach((f) => { - if (f.definition !== undefined) m.entries.push(f.definition); + if (f.definition !== undefined) m.items.push(f.definition); }); generated.files.push({ name: `${this.basename}.stdlib.fc`, @@ -260,7 +257,7 @@ export class FuncGenerator { }, [] as ( | FuncAstFunctionDefinition - | FuncAstAsmFunction + | FuncAstAsmFunctionDefinition )[], ), ), @@ -327,7 +324,7 @@ export class FuncGenerator { }, [] as ( | FuncAstFunctionDefinition - | FuncAstAsmFunction + | FuncAstAsmFunctionDefinition )[], ), ], diff --git a/src/codegen/literal.ts b/src/codegen/literal.ts index 6d258b1f8..fb839793f 100644 --- a/src/codegen/literal.ts +++ b/src/codegen/literal.ts @@ -1,13 +1,12 @@ import { WriterContext, FunctionGen, Location } from "."; -import { FuncAstExpr } from "../func/syntax"; +import { FuncAstExpression } from "../func/grammar"; import { Address, beginCell, Cell } from "@ton/core"; import { Value, CommentValue } from "../types/types"; import { call, Type, - number, + int, id, - asmfun, nil, bool, } from "../func/syntaxConstructors"; @@ -38,7 +37,7 @@ export class LiteralGen { prefix: string, comment: string, cell: Cell, - ): FuncAstExpr { + ): FuncAstExpression { const h = cell.hash().toString("hex"); const t = cell.toBoc({ idx: false }).toString("hex"); const funName = `__gen_slice_${prefix}_${h}`; @@ -62,12 +61,12 @@ export class LiteralGen { /** * Returns a function name used to access the string value. */ - private writeString(str: string): FuncAstExpr { + private writeString(str: string): FuncAstExpression { const cell = beginCell().storeStringTail(str).endCell(); return this.writeRawSlice("string", `String "${str}"`, cell); } - private writeComment(str: string): FuncAstExpr { + private writeComment(str: string): FuncAstExpression { const cell = beginCell() .storeUint(0, 32) .storeStringTail(str) @@ -78,7 +77,7 @@ export class LiteralGen { /** * Returns a function name used to access the address value. */ - private writeAddress(address: Address): FuncAstExpr { + private writeAddress(address: Address): FuncAstExpression { return this.writeRawSlice( "address", address.toString(), @@ -89,7 +88,7 @@ export class LiteralGen { /** * Returns a function name used to access the cell value. */ - private writeCell(cell: Cell): FuncAstExpr { + private writeCell(cell: Cell): FuncAstExpression { return this.writeRawCell( "cell", `Cell ${cell.hash().toString("base64")}`, @@ -104,7 +103,7 @@ export class LiteralGen { prefix: string, comment: string, cell: Cell, - ): FuncAstExpr { + ): FuncAstExpression { const h = cell.hash().toString("hex"); const t = cell.toBoc({ idx: false }).toString("hex"); const funName = `__gen_cell_${prefix}_${h}`; @@ -128,10 +127,10 @@ export class LiteralGen { /** * Generates FunC literals from Tact ones. */ - public writeValue(): FuncAstExpr { + public writeValue(): FuncAstExpression { const val = this.tactValue; if (typeof val === "bigint") { - return number(val); + return int(val); } if (typeof val === "string") { return call(this.writeString(val), []); @@ -176,7 +175,7 @@ export class LiteralGen { throw Error(`Invalid value: ${JSONbig.stringify(val, null, 2)}`); } - private makeValue(val: Value): FuncAstExpr { + private makeValue(val: Value): FuncAstExpression { return LiteralGen.fromTact(this.ctx, val).writeValue(); } } diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 3eeeece69..da511c9fb 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,5 +1,5 @@ import { getAllTypes, getType } from "../types/resolveDescriptors"; -import { enabledInline, enabledMasterchain } from "../config/features"; +import { enabledInline } from "../config/features"; import { LiteralGen, Location } from "."; import { ReceiverDescription, @@ -23,15 +23,13 @@ import { resolveFuncPrimitive } from "./primitive"; import { getSupportedInterfaces } from "../types/getSupportedInterfaces"; import { funcIdOf, funcInitIdOf, ops } from "./util"; import { - UNIT_TYPE, FuncAstModule, - FuncAstStmt, + FuncAstStatement, + FuncAstExpression, FuncAstFunctionAttribute, - FuncType, - FuncAstVarDefStmt, + FuncAstType, FuncAstFunctionDefinition, - FuncAstExpr, -} from "../func/syntax"; +} from "../func/grammar"; import { cr, unop, @@ -43,10 +41,9 @@ import { call, binop, bool, - number, - hexnumber, + int, + hex, string, - fun, ret, tensor, Type, @@ -76,7 +73,7 @@ export function unwrapExternal( targetName: string, sourceName: string, type: TypeRef, -): FuncAstVarDefStmt { +): FuncAstStatement { if (type.kind === "ref") { const t = getType(ctx, type.name); if (t.kind === "struct") { @@ -180,8 +177,8 @@ export class ModuleGen { const supported: string[] = []; supported.push("org.ton.introspection.v0"); supported.push(...getSupportedInterfaces(type, this.ctx.ctx)); - const shiftExprs: FuncAstExpr[] = supported.map((item) => - binop(string(item, "H"), ">>", number(128)), + const shiftExprs: FuncAstExpression[] = supported.map((item) => + binop(string(item, "H"), ">>", int(128)), ); return this.ctx.fun( [FunAttr.method_id()], @@ -207,14 +204,14 @@ export class ModuleGen { resolveFuncType(this.ctx.ctx, v.type), ]); const attrs = [FunAttr.impure()]; - const body: FuncAstStmt[] = []; + const body: FuncAstStatement[] = []; // Unpack parameters for (const a of init.params) { if (!resolveFuncPrimitive(this.ctx.ctx, a.type)) { body.push( vardef( - undefined, + "_", resolveFuncTypeUnpack( this.ctx.ctx, a.type, @@ -227,7 +224,7 @@ export class ModuleGen { } // Generate self initial tensor - const initValues: FuncAstExpr[] = t.fields.map((tField) => + const initValues: FuncAstExpression[] = t.fields.map((tField) => tField.default === undefined ? call("null", []) : LiteralGen.fromTact( @@ -239,7 +236,7 @@ export class ModuleGen { // Special case for empty contracts body.push( vardef( - undefined, + "_", resolveFuncTypeUnpack( this.ctx.ctx, t, @@ -298,7 +295,7 @@ export class ModuleGen { const attrs = [ ...(enabledInline(this.ctx.ctx) ? [FunAttr.inline()] : []), ]; - const body: FuncAstStmt[] = []; + const body: FuncAstStatement[] = []; // slice sc' = sys'.begin_parse(); // cell source = sc'~load_dict(); @@ -322,7 +319,7 @@ export class ModuleGen { vardef( Type.cell(), "mine", - call("__tact_dict_get_code", [id("source"), number(t.uid)]), + call("__tact_dict_get_code", [id("source"), int(t.uid)]), ), ); body.push( @@ -331,7 +328,7 @@ export class ModuleGen { id("contracts"), call("__tact_dict_set_code", [ id("contracts"), - number(t.uid), + int(t.uid), id("mine"), ]), ), @@ -351,7 +348,7 @@ export class ModuleGen { `code_${c.uid}`, call("__tact_dict_get_code", [ id("source"), - number(c.uid), + int(c.uid), ]), ), ); @@ -361,7 +358,7 @@ export class ModuleGen { id("contracts"), call("__tact_dict_set_code", [ id("contracts"), - number(c.uid), + int(c.uid), id(`code_${c.uid}`), ]), ), @@ -399,7 +396,7 @@ export class ModuleGen { expr( assign( id("b"), - call("store_int", [bool(false), number(1)], { + call("store_int", [bool(false), int(1)], { receiver: id("b"), }), ), @@ -442,7 +439,7 @@ export class ModuleGen { * TODO: Why do we need function from *all* the contracts? */ private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { - m.entries.push(comment("", `Contract ${c.name} functions`, "")); + m.items.push(comment("", `Contract ${c.name} functions`, "")); if (c.init) { this.writeInit(c, c.init); @@ -453,7 +450,7 @@ export class ModuleGen { tactFun, ); // TODO: Should we really put them here? - m.entries.push(funcFun); + m.items.push(funcFun); } } @@ -484,7 +481,7 @@ export class ModuleGen { resolveFuncType(this.ctx.ctx, type), Type.int(), ); - const paramValues: [string, FuncType][] = internal + const paramValues: [string, FuncAstType][] = internal ? [ ["self", resolveFuncType(this.ctx.ctx, type)], ["msg_bounced", Type.int()], @@ -494,7 +491,7 @@ export class ModuleGen { ["self", resolveFuncType(this.ctx.ctx, type)], ["in_msg", Type.slice()], ]; - const functionBody: FuncAstStmt[] = []; + const functionBody: FuncAstStatement[] = []; // ;; Handle bounced messages // if (msg_bounced) { @@ -502,7 +499,7 @@ export class ModuleGen { // } if (internal) { functionBody.push(comment("Handle bounced messages")); - const body: FuncAstStmt[] = []; + const body: FuncAstStatement[] = []; const bounceReceivers = type.receivers.filter((r) => { return r.selector.kind === "bounce-binary"; }); @@ -511,12 +508,12 @@ export class ModuleGen { return r.selector.kind === "bounce-fallback"; }); - const condBody: FuncAstStmt[] = []; + const condBody: FuncAstStatement[] = []; if (fallbackReceiver ?? bounceReceivers.length > 0) { // ;; Skip 0xFFFFFFFF // in_msg~skip_bits(32); condBody.push(comment("Skip 0xFFFFFFFF")); - condBody.push(expr(call("in_msg~skip_bits", [number(32)]))); + condBody.push(expr(call("in_msg~skip_bits", [int(32)]))); } if (bounceReceivers.length > 0) { @@ -526,21 +523,19 @@ export class ModuleGen { // op = in_msg.preload_uint(32); // } condBody.push(comment("Parse op")); - condBody.push(vardef(Type.int(), "op", number(0))); + condBody.push(vardef(Type.int(), "op", int(0))); condBody.push( condition( binop( call("slice_bits", [id("in_msg")]), ">=", - number(30), + int(30), ), [ expr( assign( id("op"), - call(id("in_msg.preload_uint"), [ - number(32), - ]), + call(id("in_msg.preload_uint"), [int(32)]), ), ), ], @@ -561,13 +556,11 @@ export class ModuleGen { binop( id("op"), "==", - number( - getType(this.ctx.ctx, selector.type).header!, - ), + int(getType(this.ctx.ctx, selector.type).header!), ), [ vardef( - undefined, + "_", "msg", call( id( @@ -617,15 +610,15 @@ export class ModuleGen { // op = in_msg.preload_uint(32); // } functionBody.push(comment("Parse incoming message")); - functionBody.push(vardef(Type.int(), "op", number(0))); + functionBody.push(vardef(Type.int(), "op", int(0))); functionBody.push( condition( - binop(call(id("slice_bits"), [id("in_msg")]), ">=", number(32)), + binop(call(id("slice_bits"), [id("in_msg")]), ">=", int(32)), [ expr( assign( id("op"), - call("in_msg.preload_uint", [number(32)]), + call("in_msg.preload_uint", [int(32)]), ), ), ], @@ -648,22 +641,19 @@ export class ModuleGen { } functionBody.push(comment(`Receive ${selector.type} message`)); functionBody.push( - condition( - binop(id("op"), "==", number(allocation.header)), - [ - vardef( - undefined, - "msg", - call(`in_msg~${ops.reader(selector.type)}`, []), - ), - expr( - call( - `self~${ops.receiveType(type.name, kind, selector.type)}`, - [id("msg")], - ), + condition(binop(id("op"), "==", int(allocation.header)), [ + vardef( + "_", + "msg", + call(`in_msg~${ops.reader(selector.type)}`, []), + ), + expr( + call( + `self~${ops.receiveType(type.name, kind, selector.type)}`, + [id("msg")], ), - ], - ), + ), + ]), ); } @@ -680,12 +670,12 @@ export class ModuleGen { functionBody.push( condition( binop( - binop(id("op"), "==", number(0)), + binop(id("op"), "==", int(0)), "&", binop( call("slice_bits", [id("in_msg")]), "<=", - number(32), + int(32), ), ), [ @@ -717,8 +707,8 @@ export class ModuleGen { // ... // } functionBody.push(comment("Text Receivers")); - const cond = binop(id("op"), "==", number(0)); - const condBody: FuncAstStmt[] = []; + const cond = binop(id("op"), "==", int(0)); + const condBody: FuncAstStatement[] = []; if ( type.receivers.find( (v) => @@ -729,7 +719,7 @@ export class ModuleGen { // var text_op = slice_hash(in_msg); condBody.push( vardef( - undefined, + "_", "text_op", call("slice_hash", [id("in_msg")]), ), @@ -752,11 +742,7 @@ export class ModuleGen { ); condBody.push( condition( - binop( - id("text_op"), - "==", - hexnumber(`0x${hash}`), - ), + binop(id("text_op"), "==", hex(hash)), [ expr( call( @@ -786,7 +772,7 @@ export class ModuleGen { binop( call("slice_bits", [id("in_msg")]), ">=", - number(32), + int(32), ), [ expr( @@ -794,7 +780,7 @@ export class ModuleGen { id( `self~${ops.receiveAnyText(type.name, kind)}`, ), - [call("in_msg.skip_bits", [number(32)])], + [call("in_msg.skip_bits", [int(32)])], ), ), ret(tensor(id("self"), bool(true))), @@ -847,7 +833,7 @@ export class ModuleGen { ); const selfType = resolveFuncType(this.ctx.ctx, self); const selfUnpack = vardef( - undefined, + '_', resolveFuncTypeUnpack(this.ctx.ctx, self, funcIdOf("self")), id(funcIdOf("self")), ); @@ -857,7 +843,7 @@ export class ModuleGen { selector.kind === "internal-binary" || selector.kind === "external-binary" ) { - const returnTy = Type.tensor(selfType, UNIT_TYPE); + const returnTy = Type.tensor(selfType, unit()); const funName = ops.receiveType( self.name, selector.kind === "internal-binary" ? "internal" : "external", @@ -874,10 +860,10 @@ export class ModuleGen { FunAttr.impure(), FunAttr.inline(), ]; - const body: FuncAstStmt[] = [selfUnpack]; + const body: FuncAstStatement[] = [selfUnpack]; body.push( vardef( - undefined, + '_', resolveFuncTypeUnpack( this.ctx.ctx, selector.type, @@ -912,7 +898,7 @@ export class ModuleGen { selector.kind === "internal-empty" || selector.kind === "external-empty" ) { - const returnTy = Type.tensor(selfType, UNIT_TYPE); + const returnTy = Type.tensor(selfType, unit()); const funName = ops.receiveEmpty( self.name, selector.kind === "internal-empty" ? "internal" : "external", @@ -922,7 +908,7 @@ export class ModuleGen { FunAttr.impure(), FunAttr.inline(), ]; - const body: FuncAstStmt[] = [selfUnpack]; + const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( StatementGen.fromTact( @@ -950,7 +936,7 @@ export class ModuleGen { selector.kind === "external-comment" ) { const hash = commentPseudoOpcode(selector.comment); - const returnTy = Type.tensor(selfType, UNIT_TYPE); + const returnTy = Type.tensor(selfType, unit()); const funName = ops.receiveText( self.name, selector.kind === "internal-comment" ? "internal" : "external", @@ -961,7 +947,7 @@ export class ModuleGen { FunAttr.impure(), FunAttr.inline(), ]; - const body: FuncAstStmt[] = [selfUnpack]; + const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( StatementGen.fromTact( @@ -988,7 +974,7 @@ export class ModuleGen { selector.kind === "internal-comment-fallback" || selector.kind === "external-comment-fallback" ) { - const returnTy = Type.tensor(selfType, UNIT_TYPE); + const returnTy = Type.tensor(selfType, unit()); const funName = ops.receiveAnyText( self.name, selector.kind === "internal-comment-fallback" @@ -1003,7 +989,7 @@ export class ModuleGen { FunAttr.impure(), FunAttr.inline(), ]; - const body: FuncAstStmt[] = [selfUnpack]; + const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( StatementGen.fromTact( @@ -1027,7 +1013,7 @@ export class ModuleGen { // Fallback if (selector.kind === "internal-fallback") { - const returnTy = Type.tensor(selfType, UNIT_TYPE); + const returnTy = Type.tensor(selfType, unit()); const funName = ops.receiveAny(self.name, "internal"); const paramValues: FunParamValue[] = [ [funcIdOf("self"), selfType], @@ -1037,7 +1023,7 @@ export class ModuleGen { FunAttr.impure(), FunAttr.inline(), ]; - const body: FuncAstStmt[] = [selfUnpack]; + const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( StatementGen.fromTact( @@ -1061,7 +1047,7 @@ export class ModuleGen { // Bounced if (selector.kind === "bounce-fallback") { - const returnTy = Type.tensor(selfType, UNIT_TYPE); + const returnTy = Type.tensor(selfType, unit()); const funName = ops.receiveBounceAny(self.name); const paramValues: FunParamValue[] = [ [funcIdOf("self"), selfType], @@ -1071,7 +1057,7 @@ export class ModuleGen { FunAttr.impure(), FunAttr.inline(), ]; - const body: FuncAstStmt[] = [selfUnpack]; + const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( StatementGen.fromTact( @@ -1094,7 +1080,7 @@ export class ModuleGen { } if (selector.kind === "bounce-binary") { - const returnTy = Type.tensor(selfType, UNIT_TYPE); + const returnTy = Type.tensor(selfType, unit()); const funName = ops.receiveTypeBounce(self.name, selector.type); const paramValues: FunParamValue[] = [ [funcIdOf("self"), selfType], @@ -1112,10 +1098,10 @@ export class ModuleGen { FunAttr.impure(), FunAttr.inline(), ]; - const body: FuncAstStmt[] = [selfUnpack]; + const body: FuncAstStatement[] = [selfUnpack]; body.push( vardef( - undefined, + '_', resolveFuncTypeUnpack( this.ctx.ctx, selector.type, @@ -1166,7 +1152,7 @@ export class ModuleGen { ]); const attrs = [FunAttr.method_id(getMethodId(f.name))]; - const body: FuncAstStmt[] = []; + const body: FuncAstStatement[] = []; // Unpack parameters for (const param of f.params) { unwrapExternal( @@ -1178,12 +1164,12 @@ export class ModuleGen { } // Load contract state body.push( - vardef(undefined, "self", call(ops.contractLoad(self.name), [])), + vardef('_', "self", call(ops.contractLoad(self.name), [])), ); // Execute get method body.push( vardef( - undefined, + '_', "res", call( `self~${ops.extension(self.name, f.name)}`, @@ -1225,7 +1211,7 @@ export class ModuleGen { type: TypeDescription, ): FuncAstFunctionDefinition { // () recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure - const returnTy = UNIT_TYPE; + const returnTy = unit(); const funName = "recv_internal"; const paramValues: FunParamValue[] = [ ["msg_value", Type.int()], @@ -1233,31 +1219,31 @@ export class ModuleGen { ["in_msg", Type.slice()], ]; const attrs = [FunAttr.impure()]; - const body: FuncAstStmt[] = []; + const body: FuncAstStatement[] = []; // Load context body.push(comment("Context")); body.push( vardef( - undefined, + '_', "cs", call("begin_parse", [], { receiver: id("in_msg_cell") }), ), ); body.push( - vardef(undefined, "msg_flags", call("cs~load_uint", [number(4)])), + vardef('_', "msg_flags", call("cs~load_uint", [int(4)])), ); // int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool body.push( vardef( - undefined, + '_', "msg_bounced", - unop("-", binop(id("msg_flags"), "&", number(1))), + unop("-", binop(id("msg_flags"), "&", int(1))), ), ); body.push( vardef( Type.slice(), - id("msg_sender_addr"), + "msg_sender_addr", call("__tact_verify_address", [call("cs~load_msg_addr", [])]), ), ); @@ -1282,7 +1268,7 @@ export class ModuleGen { // Load self body.push(comment("Load contract data")); body.push( - vardef(undefined, "self", call(ops.contractLoad(type.name), [])), + vardef('_', "self", call(ops.contractLoad(type.name), [])), ); body.push(cr()); @@ -1291,7 +1277,7 @@ export class ModuleGen { body.push( vardef( Type.int(), - id("handled"), + "handled", call(`self~${ops.contractRouter(type.name, "internal")}`, [ id("msg_bounced"), id("in_msg"), @@ -1305,7 +1291,7 @@ export class ModuleGen { body.push( expr( call("throw_unless", [ - number(contractErrors.invalidMessage.id), + int(contractErrors.invalidMessage.id), id("handled"), ]), ), @@ -1325,7 +1311,7 @@ export class ModuleGen { type: TypeDescription, ): FuncAstFunctionDefinition { // () recv_external(slice in_msg) impure - const returnTy = UNIT_TYPE; + const returnTy = unit(); const funName = "recv_internal"; const paramValues: FunParamValue[] = [ ["msg_value", Type.int()], @@ -1333,12 +1319,12 @@ export class ModuleGen { ["in_msg", Type.slice()], ]; const attrs = [FunAttr.impure()]; - const body: FuncAstStmt[] = []; + const body: FuncAstStatement[] = []; // Load self body.push(comment("Load contract data")); body.push( - vardef(undefined, "self", call(ops.contractLoad(type.name), [])), + vardef('_', "self", call(ops.contractLoad(type.name), [])), ); body.push(cr()); @@ -1347,7 +1333,7 @@ export class ModuleGen { body.push( vardef( Type.int(), - id("handled"), + "handled", call(`self~${ops.contractRouter(type.name, "external")}`, [ id("in_msg"), ]), @@ -1360,7 +1346,7 @@ export class ModuleGen { body.push( expr( call("throw_unless", [ - number(contractErrors.invalidMessage.id), + int(contractErrors.invalidMessage.id), id("handled"), ]), ), @@ -1377,7 +1363,7 @@ export class ModuleGen { } /** - * Adds entries from the main Tact contract creating a program containing the entrypoint. + * Adds items from the main Tact contract creating a program containing the entrypoint. * * XXX: In the old backend, they simply push multiply functions here, creating an entry * for a non-existent `$main` function. @@ -1386,34 +1372,34 @@ export class ModuleGen { m: FuncAstModule, contractTy: TypeDescription, ): void { - m.entries.push( + m.items.push( comment("", `Receivers of a Contract ${contractTy.name}`, ""), ); // Write receivers for (const r of Object.values(contractTy.receivers)) { - m.entries.push(this.writeReceiver(contractTy, r)); + m.items.push(this.writeReceiver(contractTy, r)); } - m.entries.push( + m.items.push( comment("", `Get methods of a Contract ${contractTy.name}`, ""), ); // Getters for (const f of contractTy.functions.values()) { if (f.isGetter) { - m.entries.push(this.writeGetter(f)); + m.items.push(this.writeGetter(f)); } } // Interfaces - m.entries.push(this.writeInterfaces(contractTy)); + m.items.push(this.writeInterfaces(contractTy)); // ABI: // _ get_abi_ipfs() method_id { // return "${abiLink}"; // } - m.entries.push( + m.items.push( this.ctx.fun( [FunAttr.method_id()], "get_abi_ipfs", @@ -1428,7 +1414,7 @@ export class ModuleGen { //_ lazy_deployment_completed() method_id { // return get_data().begin_parse().load_int(1); // } - m.entries.push( + m.items.push( this.ctx.fun( [FunAttr.method_id()], "lazy_deployment_completed", @@ -1436,7 +1422,7 @@ export class ModuleGen { Type.hole(), [ ret( - call("load_int", [number(1)], { + call("load_int", [int(1)], { receiver: call("begin_parse", [], { receiver: call("get_data", []), }), @@ -1447,22 +1433,22 @@ export class ModuleGen { ), ); - m.entries.push( + m.items.push( comment("", `Routing of a Contract ${contractTy.name}`, ""), ); const hasExternal = contractTy.receivers.find((v) => v.selector.kind.startsWith("external-"), ); - m.entries.push(this.writeRouter(contractTy, "internal")); + m.items.push(this.writeRouter(contractTy, "internal")); if (hasExternal) { - m.entries.push(this.writeRouter(contractTy, "external")); + m.items.push(this.writeRouter(contractTy, "external")); } // Render internal receiver - m.entries.push(this.makeInternalReceiver(contractTy)); + m.items.push(this.makeInternalReceiver(contractTy)); if (hasExternal) { // Render external receiver - m.entries.push(this.makeExternalReceiver(contractTy)); + m.items.push(this.makeExternalReceiver(contractTy)); } } diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index 7a843882d..b133b9fe1 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -13,10 +13,10 @@ import { import { ExpressionGen, writePathExpression, WriterContext } from "."; import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; import { - FuncAstStmt, - FuncAstConditionStmt, - FuncAstExpr, -} from "../func/syntax"; + FuncAstStatement, + FuncAstStatementCondition, + FuncAstExpression, +} from "../func/grammar"; import { id, expr, @@ -57,18 +57,18 @@ export class StatementGen { /** * Translates an expression in the current context. */ - private makeExpr(expr: AstExpression): FuncAstExpr { + private makeExpr(expr: AstExpression): FuncAstExpression { return ExpressionGen.fromTact(this.ctx, expr).writeExpression(); } - private makeCastedExpr(expr: AstExpression, to: TypeRef): FuncAstExpr { + private makeCastedExpr(expr: AstExpression, to: TypeRef): FuncAstExpression { return ExpressionGen.fromTact(this.ctx, expr).writeCastedExpression(to); } /** * Tranforms the Tact conditional statement to the Func one. */ - private writeCondition(f: AstCondition): FuncAstConditionStmt { + private writeCondition(f: AstCondition): FuncAstStatementCondition { const writeStmt = (stmt: AstStatement) => StatementGen.fromTact( this.ctx, @@ -78,7 +78,7 @@ export class StatementGen { ).writeStatement(); const cond = this.makeExpr(f.condition); const thenBlock = f.trueStatements.map(writeStmt); - const elseStmt: FuncAstConditionStmt | undefined = + const elseStmt: FuncAstStatementCondition | undefined = f.falseStatements !== null && f.falseStatements.length > 0 ? condition(undefined, f.falseStatements.map(writeStmt)) : f.elseif @@ -87,11 +87,11 @@ export class StatementGen { return condition(cond, thenBlock, false, elseStmt); } - public writeStatement(): FuncAstStmt { + public writeStatement(): FuncAstStatement { switch (this.tactStmt.kind) { case "statement_return": { const selfVar = this.selfName ? id(this.selfName) : undefined; - const getValue = (expr: FuncAstExpr): FuncAstExpr => + const getValue = (expr: FuncAstExpression): FuncAstExpression => this.selfName ? tensor(selfVar!, expr) : expr; if (this.tactStmt.expression) { const castedReturns = this.makeCastedExpr( @@ -135,7 +135,7 @@ export class StatementGen { this.tactStmt.expression, t, ); - return vardef(undefined, name, init); + return vardef("_", name, init); } } } diff --git a/src/codegen/stdlib.ts b/src/codegen/stdlib.ts index 2ba6acf00..15910435f 100644 --- a/src/codegen/stdlib.ts +++ b/src/codegen/stdlib.ts @@ -1,2172 +1,4 @@ -import { contractErrors } from "../abi/errors"; -import { enabledMasterchain } from "../config/features"; import { WriterContext, Location } from "./context"; -import { - UNIT_TYPE, - FuncAstModule, - FuncAstStmt, - FuncAstFunctionAttribute, - FuncType, - FuncAstVarDefStmt, - FuncAstFunctionDefinition, - FuncAstExpr, -} from "../func/syntax"; -import { - cr, - unop, - comment, - FunParamValue, - nil, - assign, - while_, - expr, - unit, - call, - binop, - bool, - number, - hexnumber, - string, - fun, - ret, - tensor, - Type, - ternary, - FunAttr, - vardef, - mod, - condition, - id, -} from "../func/syntaxConstructors"; export function writeStdlib(ctx: WriterContext) { - // - // stdlib extension functions - // - - ctx.skip("__tact_set", { context: Location.stdlib() }); - ctx.skip("__tact_nop", { context: Location.stdlib() }); - ctx.skip("__tact_str_to_slice", { context: Location.stdlib() }); - ctx.skip("__tact_slice_to_str", { context: Location.stdlib() }); - ctx.skip("__tact_address_to_slice", { context: Location.stdlib() }); - - // - // Addresses - // - - // ctx.fun("__tact_verify_address", () => ); - - // ctx.fun("__tact_load_bool", () => ); - - // ctx.fun("__tact_load_address", () => ); - - // __tact_load_address - { - const returnTy = Type.tensor(Type.slice(), Type.slice()); - const funName = "__tact_load_address"; - const paramValues: FunParamValue[] = [["cs", Type.slice()]]; - const attrs = [FunAttr.inline()]; - const body: FuncAstStmt[] = []; - - body.push(vardef(Type.slice(), "raw", call("cs~load_msg_addr", []))); - body.push( - ret(tensor(id("cs"), call("__tact_verify_address", [id("raw")]))), - ); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // __tact_load_address_opt - { - const returnTy = Type.tensor(Type.slice(), Type.slice()); - const funName = "__tact_load_address_opt"; - const paramValues: FunParamValue[] = [["cs", Type.slice()]]; - const attrs = [FunAttr.inline()]; - const body: FuncAstStmt[] = []; - - // if (cs.preload_uint(2) != 0) - const cond = binop( - call(id("cs~preload_uint"), [number(2)]), - "!=", - number(0), - ); - - // if branch - const ifBody: FuncAstStmt[] = []; - ifBody.push(vardef(Type.slice(), "raw", call("cs~load_msg_addr", []))); - ifBody.push( - ret(tensor(id("cs"), call("__tact_verify_address", [id("raw")]))), - ); - - // else branch - const elseBody: FuncAstStmt[] = []; - elseBody.push(expr(call(id("cs~skip_bits"), [number(2)]))); - elseBody.push(ret(tensor(id("cs"), call("null", [])))); - - body.push( - condition(cond, ifBody, false, condition(undefined, elseBody)), - ); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // __tact_store_address - { - const returnTy = Type.builder(); - const funName = "__tact_store_address"; - const paramValues: FunParamValue[] = [ - ["b", Type.builder()], - ["address", Type.slice()], - ]; - const attrs = [FunAttr.inline()]; - const body: FuncAstStmt[] = []; - - body.push( - ret( - call(id("b~store_slice"), [ - call("__tact_verify_address", [id("address")]), - ]), - ), - ); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // __tact_store_address_opt - { - const returnTy = Type.builder(); - const funName = "__tact_store_address_opt"; - const paramValues: FunParamValue[] = [ - ["b", Type.builder()], - ["address", Type.slice()], - ]; - const attrs = [FunAttr.inline()]; - const body: FuncAstStmt[] = []; - - // if (null?(address)) - const cond = call("null?", [id("address")]); - - // if branch - const ifBody: FuncAstStmt[] = []; - ifBody.push( - expr( - assign( - id("b"), - call("store_uint", [number(0), number(2)], { - receiver: id("b"), - }), - ), - ), - ); - ifBody.push(ret(id("b"))); - - // else branch - const elseBody: FuncAstStmt[] = []; - elseBody.push( - ret(call("__tact_store_address", [id("b"), id("address")])), - ); - - body.push( - condition(cond, ifBody, false, condition(undefined, elseBody)), - ); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // __tact_create_address - { - const returnTy = Type.slice(); - const funName = "__tact_create_address"; - const paramValues: FunParamValue[] = [ - ["chain", Type.int()], - ["hash", Type.int()], - ]; - const attrs = [FunAttr.inline()]; - const body: FuncAstStmt[] = []; - - body.push(vardef(Type.builder(), "b", call("begin_cell", []))); - body.push( - expr( - assign( - id("b"), - call("store_uint", [number(2), number(2)], { - receiver: id("b"), - }), - ), - ), - ); - body.push( - expr( - assign( - id("b"), - call("store_uint", [number(0), number(1)], { - receiver: id("b"), - }), - ), - ), - ); - body.push( - expr( - assign( - id("b"), - call("store_int", [id("chain"), number(8)], { - receiver: id("b"), - }), - ), - ), - ); - body.push( - expr( - assign( - id("b"), - call("store_uint", [id("hash"), number(256)], { - receiver: id("b"), - }), - ), - ), - ); - body.push( - vardef( - Type.slice(), - "addr", - call("begin_parse", [], { - receiver: call("end_cell", [], { receiver: id("b") }), - }), - ), - ); - body.push(ret(call("__tact_verify_address", [id("addr")]))); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // __tact_compute_contract_address - { - const returnTy = Type.slice(); - const funName = "__tact_compute_contract_address"; - const paramValues: FunParamValue[] = [ - ["chain", Type.int()], - ["code", Type.cell()], - ["data", Type.cell()], - ]; - const attrs = [FunAttr.inline()]; - const body: FuncAstStmt[] = []; - - body.push(vardef(Type.builder(), "b", call("begin_cell", []))); - body.push( - expr( - assign( - id("b"), - call("store_uint", [number(0), number(2)], { - receiver: id("b"), - }), - ), - ), - ); - body.push( - expr( - assign( - id("b"), - call("store_uint", [number(3), number(2)], { - receiver: id("b"), - }), - ), - ), - ); - body.push( - expr( - assign( - id("b"), - call("store_uint", [number(0), number(1)], { - receiver: id("b"), - }), - ), - ), - ); - body.push( - expr( - assign( - id("b"), - call("store_ref", [id("code")], { receiver: id("b") }), - ), - ), - ); - body.push( - expr( - assign( - id("b"), - call("store_ref", [id("data")], { receiver: id("b") }), - ), - ), - ); - body.push( - vardef( - Type.slice(), - "hash", - call("cell_hash", [ - call("end_cell", [], { receiver: id("b") }), - ]), - ), - ); - body.push( - ret(call("__tact_create_address", [id("chain"), id("hash")])), - ); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // __tact_my_balance - { - const returnTy = Type.int(); - const funName = "__tact_my_balance"; - const paramValues: FunParamValue[] = []; - const attrs = [FunAttr.inline()]; - const body: FuncAstStmt[] = []; - - body.push(ret(call("pair_first", [call("get_balance", [])]))); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // TODO: we don't have forall yet - // ctx.fun("__tact_not_null", () => ); - - // ctx.fun("__tact_dict_delete", () => ); - - // ctx.fun("__tact_dict_delete_int", () => ); - - // ctx.fun("__tact_dict_delete_uint", () => ); - - // ctx.fun("__tact_dict_set_ref", () => ); - - // ctx.fun("__tact_dict_get", () => ); - - // ctx.fun("__tact_dict_get_ref", () => ); - - // ctx.fun("__tact_dict_min", () => ); - - // ctx.fun("__tact_dict_min_ref", () => ); - - // ctx.fun("__tact_dict_next", () => ); - - // __tact_dict_next_ref - { - const returnTy = Type.tensor(Type.slice(), Type.cell(), Type.int()); - const funName = "__tact_dict_next_ref"; - const paramValues: FunParamValue[] = [ - ["dict", Type.cell()], - ["key_len", Type.int()], - ["pivot", Type.slice()], - ]; - const attrs: FuncAstFunctionAttribute[] = []; - const body: FuncAstStmt[] = []; - - body.push( - vardef( - undefined, - ["key", "value", "flag"], - call("__tact_dict_next", [ - id("dict"), - id("key_len"), - id("pivot"), - ]), - ), - ); - - // if branch - const ifBody: FuncAstStmt[] = []; - ifBody.push( - ret(tensor(id("key"), call("value~load_ref", []), id("flag"))), - ); - - // else branch - const elseBody: FuncAstStmt[] = []; - elseBody.push( - ret(tensor(call("null", []), call("null", []), id("flag"))), - ); - - body.push( - condition( - id("flag"), - ifBody, - false, - condition(undefined, elseBody), - ), - ); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // ctx.fun("__tact_debug", () => ); - - // ctx.fun("__tact_debug_str", () => ); - - // __tact_debug_bool - { - const returnTy = UNIT_TYPE; - const funName = "__tact_debug_bool"; - const paramValues: FunParamValue[] = [ - ["value", Type.int()], - ["debug_print", Type.slice()], - ]; - const attrs = [FunAttr.impure()]; - const body: FuncAstStmt[] = []; - - // if branch - const ifBody: FuncAstStmt[] = []; - ifBody.push( - expr(call("__tact_debug_str", [string("true"), id("debug_print")])), - ); - - // else branch - const elseBody: FuncAstStmt[] = []; - elseBody.push( - expr( - call("__tact_debug_str", [string("false"), id("debug_print")]), - ), - ); - - body.push( - condition( - id("value"), - ifBody, - false, - condition(undefined, elseBody), - ), - ); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // ctx.fun("__tact_preload_offset", () => ); - - // __tact_crc16 - { - const returnTy = Type.slice(); - const funName = "__tact_crc16"; - const paramValues: FunParamValue[] = [["data", Type.slice()]]; - const attrs = [FunAttr.inline_ref()]; - const body: FuncAstStmt[] = []; - - body.push( - vardef( - Type.slice(), - "new_data", - call("begin_parse", [], { - receiver: call("end_cell", [], { - receiver: call("store_slice", [string("0000", "s")], { - receiver: call("store_slice", [id("data")], { - receiver: call("begin_cell", []), - }), - }), - }), - }), - ), - ); - - body.push(vardef(Type.int(), "reg", number(0))); - - const cond = unop( - "~", - call("slice_data_empty?", [], { receiver: id("new_data") }), - ); - - // while loop - const whileBody: FuncAstStmt[] = []; - whileBody.push( - vardef( - Type.int(), - "byte", - call("load_uint", [number(8)], { receiver: id("new_data") }), - ), - ); - whileBody.push(vardef(Type.int(), "mask", hexnumber("0x80"))); - - const innerCond = binop(id("mask"), ">", number(0)); - - // inner while loop - const innerWhileBody: FuncAstStmt[] = []; - innerWhileBody.push( - expr(assign(id("reg"), binop(id("reg"), "<<", number(1)))), - ); - innerWhileBody.push( - condition( - binop(id("byte"), "&", id("mask")), - [expr(assign(id("reg"), binop(id("reg"), "+", number(1))))], - false, - ), - ); - innerWhileBody.push( - expr(assign(id("mask"), binop(id("mask"), ">>", number(1)))), - ); - innerWhileBody.push( - condition( - binop(id("reg"), ">", number(0xffff)), - [ - expr( - assign( - id("reg"), - binop(id("reg"), "&", number(0xffff)), - ), - ), - expr( - assign( - id("reg"), - binop(id("reg"), "^", hexnumber("0x1021")), - ), - ), - ], - false, - ), - ); - - whileBody.push(while_(innerCond, innerWhileBody)); - body.push(while_(cond, whileBody)); - - body.push( - vardef( - undefined, - ["q", "r"], - call("divmod", [id("reg"), number(256)]), - ), - ); - - body.push( - ret( - call("begin_parse", [], { - receiver: call("end_cell", [], { - receiver: call("store_uint", [id("r"), number(8)], { - receiver: call("store_uint", [id("q"), number(8)], { - receiver: call("begin_cell", []), - }), - }), - }), - }), - ), - ); - - ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.stdlib(), - }); - } - - // ctx.fun("__tact_base64_encode", () => { - // ctx.signature(`(slice) __tact_base64_encode(slice data)`); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; - // builder res = begin_cell(); - // - // while (data.slice_bits() >= 24) { - // (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); - // - // int n = (bs1 << 16) | (bs2 << 8) | bs3; - // - // res = res - // .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 18) & 63) * 8, 8)) - // .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 12) & 63) * 8, 8)) - // .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 6) & 63) * 8, 8)) - // .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n ) & 63) * 8, 8)); - // } - // - // return res.end_cell().begin_parse(); - // `); - // }); - // }); - - // ctx.fun("__tact_address_to_user_friendly", () => { - // ctx.signature(`(slice) __tact_address_to_user_friendly(slice address)`); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // (int wc, int hash) = address.parse_std_addr(); - - // slice user_friendly_address = begin_cell() - // .store_slice("11"s) - // .store_uint((wc + 0x100) % 0x100, 8) - // .store_uint(hash, 256) - // .end_cell().begin_parse(); - // - // slice checksum = ${ctx.used("__tact_crc16")}(user_friendly_address); - // slice user_friendly_address_with_checksum = begin_cell() - // .store_slice(user_friendly_address) - // .store_slice(checksum) - // .end_cell().begin_parse(); - // - // return ${ctx.used("__tact_base64_encode")}(user_friendly_address_with_checksum); - // `); - // }); - // }); - - // ctx.fun("__tact_debug_address", () => { - // ctx.signature( - // `() __tact_debug_address(slice address, slice debug_print)`, - // ); - // ctx.flag("impure"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // ${ctx.used("__tact_debug_str")}(${ctx.used("__tact_address_to_user_friendly")}(address), debug_print); - // `); - // }); - // }); - - // ctx.fun("__tact_debug_stack", () => { - // ctx.signature(`() __tact_debug_stack(slice debug_print)`); - // ctx.flag("impure"); - // ctx.context("stdlib"); - // ctx.asm(`asm "STRDUMP" "DROP" "DUMPSTK"`); - // }); - - // ctx.fun("__tact_context_get", () => { - // ctx.signature(`(int, slice, int, slice) __tact_context_get()`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(`return __tact_context;`); - // }); - // }); - - // ctx.fun("__tact_context_get_sender", () => { - // ctx.signature(`slice __tact_context_get_sender()`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(`return __tact_context_sender;`); - // }); - // }); - - // ctx.fun("__tact_prepare_random", () => { - // ctx.signature(`() __tact_prepare_random()`); - // ctx.flag("impure"); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(__tact_randomized)) { - // randomize_lt(); - // __tact_randomized = true; - // } - // `); - // }); - // }); - - // ctx.fun("__tact_store_bool", () => { - // ctx.signature(`builder __tact_store_bool(builder b, int v)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return b.store_int(v, 1); - // `); - // }); - // }); - - // ctx.fun("__tact_to_tuple", () => { - // ctx.signature(`forall X -> tuple __tact_to_tuple(X x)`); - // ctx.context("stdlib"); - // ctx.asm(`asm "NOP"`); - // }); - - // ctx.fun("__tact_from_tuple", () => { - // ctx.signature(`forall X -> X __tact_from_tuple(tuple x)`); - // ctx.context("stdlib"); - // ctx.asm(`asm "NOP"`); - // }); - - // Dict Int -> Int - // - // - // ctx.fun("__tact_dict_set_int_int", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = idict_delete?(d, kl, k); - // return (r, ()); - // } else { - // return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_int_int", () => { - // ctx.signature( - // `int __tact_dict_get_int_int(cell d, int kl, int k, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = idict_get?(d, kl, k); - // if (ok) { - // return r~load_int(vl); - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_int_int", () => { - // ctx.signature( - // `(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = idict_get_min?(d, kl); - // if (flag) { - // return (key, value~load_int(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_int_int", () => { - // ctx.signature( - // `(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = idict_get_next?(d, kl, pivot); - // if (flag) { - // return (key, value~load_int(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Int -> Int - // - // - // ctx.fun("__tact_dict_set_int_uint", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_int_uint(cell d, int kl, int k, int v, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = idict_delete?(d, kl, k); - // return (r, ()); - // } else { - // return (idict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_int_uint", () => { - // ctx.signature( - // `int __tact_dict_get_int_uint(cell d, int kl, int k, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = idict_get?(d, kl, k); - // if (ok) { - // return r~load_uint(vl); - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_int_uint", () => { - // ctx.signature( - // `(int, int, int) __tact_dict_min_int_uint(cell d, int kl, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = idict_get_min?(d, kl); - // if (flag) { - // return (key, value~load_uint(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_int_uint", () => { - // ctx.signature( - // `(int, int, int) __tact_dict_next_int_uint(cell d, int kl, int pivot, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = idict_get_next?(d, kl, pivot); - // if (flag) { - // return (key, value~load_uint(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Uint -> Int - // - // - // ctx.fun("__tact_dict_set_uint_int", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = udict_delete?(d, kl, k); - // return (r, ()); - // } else { - // return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_uint_int", () => { - // ctx.signature( - // `int __tact_dict_get_uint_int(cell d, int kl, int k, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = udict_get?(d, kl, k); - // if (ok) { - // return r~load_int(vl); - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_uint_int", () => { - // ctx.signature( - // `(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = udict_get_min?(d, kl); - // if (flag) { - // return (key, value~load_int(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_uint_int", () => { - // ctx.signature( - // `(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = udict_get_next?(d, kl, pivot); - // if (flag) { - // return (key, value~load_int(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Uint -> Uint - // - // - // ctx.fun("__tact_dict_set_uint_uint", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = udict_delete?(d, kl, k); - // return (r, ()); - // } else { - // return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_uint_uint", () => { - // ctx.signature( - // `int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = udict_get?(d, kl, k); - // if (ok) { - // return r~load_uint(vl); - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_uint_uint", () => { - // ctx.signature( - // `(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = udict_get_min?(d, kl); - // if (flag) { - // return (key, value~load_uint(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_uint_uint", () => { - // ctx.signature( - // `(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = udict_get_next?(d, kl, pivot); - // if (flag) { - // return (key, value~load_uint(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Int -> Cell - // - // - // ctx.fun("__tact_dict_set_int_cell", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = idict_delete?(d, kl, k); - // return (r, ()); - // } else { - // return (idict_set_ref(d, kl, k, v), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_int_cell", () => { - // ctx.signature(`cell __tact_dict_get_int_cell(cell d, int kl, int k)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = idict_get_ref?(d, kl, k); - // if (ok) { - // return r; - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_int_cell", () => { - // ctx.signature( - // `(int, cell, int) __tact_dict_min_int_cell(cell d, int kl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = idict_get_min_ref?(d, kl); - // if (flag) { - // return (key, value, flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_int_cell", () => { - // ctx.signature( - // `(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = idict_get_next?(d, kl, pivot); - // if (flag) { - // return (key, value~load_ref(), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Uint -> Cell - // - // - // ctx.fun("__tact_dict_set_uint_cell", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = udict_delete?(d, kl, k); - // return (r, ()); - // } else { - // return (udict_set_ref(d, kl, k, v), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_uint_cell", () => { - // ctx.signature(`cell __tact_dict_get_uint_cell(cell d, int kl, int k)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = udict_get_ref?(d, kl, k); - // if (ok) { - // return r; - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_uint_cell", () => { - // ctx.signature( - // `(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = udict_get_min_ref?(d, kl); - // if (flag) { - // return (key, value, flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_uint_cell", () => { - // ctx.signature( - // `(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = udict_get_next?(d, kl, pivot); - // if (flag) { - // return (key, value~load_ref(), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Int -> Slice - // - // - // ctx.fun("__tact_dict_set_int_slice", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = idict_delete?(d, kl, k); - // return (r, ()); - // } else { - // return (idict_set(d, kl, k, v), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_int_slice", () => { - // ctx.signature(`slice __tact_dict_get_int_slice(cell d, int kl, int k)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = idict_get?(d, kl, k); - // if (ok) { - // return r; - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_int_slice", () => { - // ctx.signature( - // `(int, slice, int) __tact_dict_min_int_slice(cell d, int kl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = idict_get_min?(d, kl); - // if (flag) { - // return (key, value, flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_int_slice", () => { - // ctx.signature( - // `(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = idict_get_next?(d, kl, pivot); - // if (flag) { - // return (key, value, flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Uint -> Slice - // - // - // ctx.fun("__tact_dict_set_uint_slice", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = udict_delete?(d, kl, k); - // return (r, ()); - // } else { - // return (udict_set(d, kl, k, v), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_uint_slice", () => { - // ctx.signature( - // `slice __tact_dict_get_uint_slice(cell d, int kl, int k)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = udict_get?(d, kl, k); - // if (ok) { - // return r; - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_uint_slice", () => { - // ctx.signature( - // `(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = udict_get_min?(d, kl); - // if (flag) { - // return (key, value, flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_uint_slice", () => { - // ctx.signature( - // `(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = udict_get_next?(d, kl, pivot); - // if (flag) { - // return (key, value, flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Slice -> Int - // - // - // ctx.fun("__tact_dict_set_slice_int", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); - // return (r, ()); - // } else { - // return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_slice_int", () => { - // ctx.signature( - // `int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); - // if (ok) { - // return r~load_int(vl); - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_slice_int", () => { - // ctx.signature( - // `(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); - // if (flag) { - // return (key, value~load_int(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_slice_int", () => { - // ctx.signature( - // `(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); - // if (flag) { - // return (key, value~load_int(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Slice -> UInt - // - // - // ctx.fun("__tact_dict_set_slice_uint", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); - // return (r, ()); - // } else { - // return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_get_slice_uint", () => { - // ctx.signature( - // `int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); - // if (ok) { - // return r~load_uint(vl); - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_min_slice_uint", () => { - // ctx.signature( - // `(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); - // if (flag) { - // return (key, value~load_uint(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun("__tact_dict_next_slice_uint", () => { - // ctx.signature( - // `(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); - // if (flag) { - // return (key, value~load_uint(vl), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Slice -> Cell - // - // - // ctx.fun("__tact_dict_set_slice_cell", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); - // return (r, ()); - // } else { - // return ${ctx.used(`__tact_dict_set_ref`)}(d, kl, k, v); - // } - // `); - // }); - // }); - - // ctx.fun(`__tact_dict_get_slice_cell`, () => { - // ctx.signature( - // `cell __tact_dict_get_slice_cell(cell d, int kl, slice k)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = ${ctx.used(`__tact_dict_get_ref`)}(d, kl, k); - // if (ok) { - // return r; - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun(`__tact_dict_min_slice_cell`, () => { - // ctx.signature( - // `(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = ${ctx.used(`__tact_dict_min_ref`)}(d, kl); - // if (flag) { - // return (key, value, flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun(`__tact_dict_next_slice_cell`, () => { - // ctx.signature( - // `(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); - // if (flag) { - // return (key, value~load_ref(), flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // Dict Slice -> Slice - // - // - // ctx.fun("__tact_dict_set_slice_slice", () => { - // ctx.signature( - // `(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // if (null?(v)) { - // var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); - // return (r, ()); - // } else { - // return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); - // } - // `); - // }); - // }); - - // ctx.fun(`__tact_dict_get_slice_slice`, () => { - // ctx.signature( - // `slice __tact_dict_get_slice_slice(cell d, int kl, slice k)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); - // if (ok) { - // return r; - // } else { - // return null(); - // } - // `); - // }); - // }); - - // ctx.fun(`__tact_dict_min_slice_slice`, () => { - // ctx.signature( - // `(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); - // if (flag) { - // return (key, value, flag); - // } else { - // return (null(), null(), flag); - // } - // `); - // }); - // }); - - // ctx.fun(`__tact_dict_next_slice_slice`, () => { - // ctx.signature( - // `(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); - // `); - // }); - // }); - - // Address - // - // - // ctx.fun(`__tact_slice_eq_bits`, () => { - // ctx.signature(`int __tact_slice_eq_bits(slice a, slice b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return equal_slice_bits(a, b); - // `); - // }); - // }); - - // ctx.fun(`__tact_slice_eq_bits_nullable_one`, () => { - // ctx.signature( - // `int __tact_slice_eq_bits_nullable_one(slice a, slice b)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (null?(a)) ? (false) : (equal_slice_bits(a, b)); - // `); - // }); - // }); - - // ctx.fun(`__tact_slice_eq_bits_nullable`, () => { - // ctx.signature(`int __tact_slice_eq_bits_nullable(slice a, slice b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var a_is_null = null?(a); - // var b_is_null = null?(b); - // return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( equal_slice_bits(a, b) ) : ( false ) ); - // `); - // }); - // }); - - // Int Eq - // - // - // ctx.fun(`__tact_int_eq_nullable_one`, () => { - // ctx.signature(`int __tact_int_eq_nullable_one(int a, int b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (null?(a)) ? (false) : (a == b); - // `); - // }); - // }); - - // ctx.fun(`__tact_int_neq_nullable_one`, () => { - // ctx.signature(`int __tact_int_neq_nullable_one(int a, int b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (null?(a)) ? (true) : (a != b); - // `); - // }); - // }); - - // ctx.fun(`__tact_int_eq_nullable`, () => { - // ctx.signature(`int __tact_int_eq_nullable(int a, int b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var a_is_null = null?(a); - // var b_is_null = null?(b); - // return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a == b ) : ( false ) ); - // `); - // }); - // }); - - // ctx.fun(`__tact_int_neq_nullable`, () => { - // ctx.signature(`int __tact_int_neq_nullable(int a, int b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var a_is_null = null?(a); - // var b_is_null = null?(b); - // return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a != b ) : ( true ) ); - // `); - // }); - // }); - - // Cell Eq - // - // - // ctx.fun(`__tact_cell_eq`, () => { - // ctx.signature(`int __tact_cell_eq(cell a, cell b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (a.cell_hash() == b.cell_hash()); - // `); - // }); - // }); - - // ctx.fun(`__tact_cell_neq`, () => { - // ctx.signature(`int __tact_cell_neq(cell a, cell b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (a.cell_hash() != b.cell_hash()); - // `); - // }); - // }); - - // ctx.fun(`__tact_cell_eq_nullable_one`, () => { - // ctx.signature(`int __tact_cell_eq_nullable_one(cell a, cell b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash()); - // `); - // }); - // }); - - // ctx.fun(`__tact_cell_neq_nullable_one`, () => { - // ctx.signature(`int __tact_cell_neq_nullable_one(cell a, cell b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash()); - // `); - // }); - // }); - - // ctx.fun(`__tact_cell_eq_nullable`, () => { - // ctx.signature(`int __tact_cell_eq_nullable(cell a, cell b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var a_is_null = null?(a); - // var b_is_null = null?(b); - // return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() == b.cell_hash() ) : ( false ) ); - // `); - // }); - // }); - - // ctx.fun(`__tact_cell_neq_nullable`, () => { - // ctx.signature(`int __tact_cell_neq_nullable(cell a, cell b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var a_is_null = null?(a); - // var b_is_null = null?(b); - // return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() != b.cell_hash() ) : ( true ) ); - // `); - // }); - // }); - - // Slice Eq - // - // - // ctx.fun(`__tact_slice_eq`, () => { - // ctx.signature(`int __tact_slice_eq(slice a, slice b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (a.slice_hash() == b.slice_hash()); - // `); - // }); - // }); - - // ctx.fun(`__tact_slice_neq`, () => { - // ctx.signature(`int __tact_slice_neq(slice a, slice b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (a.slice_hash() != b.slice_hash()); - // `); - // }); - // }); - - // ctx.fun(`__tact_slice_eq_nullable_one`, () => { - // ctx.signature(`int __tact_slice_eq_nullable_one(slice a, slice b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash()); - // `); - // }); - // }); - - // ctx.fun(`__tact_slice_neq_nullable_one`, () => { - // ctx.signature(`int __tact_slice_neq_nullable_one(slice a, slice b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash()); - // `); - // }); - // }); - - // ctx.fun(`__tact_slice_eq_nullable`, () => { - // ctx.signature(`int __tact_slice_eq_nullable(slice a, slice b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var a_is_null = null?(a); - // var b_is_null = null?(b); - // return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() == b.slice_hash() ) : ( false ) ); - // `); - // }); - // }); - - // ctx.fun(`__tact_slice_neq_nullable`, () => { - // ctx.signature(`int __tact_slice_neq_nullable(slice a, slice b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var a_is_null = null?(a); - // var b_is_null = null?(b); - // return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() != b.slice_hash() ) : ( true ) ); - // `); - // }); - // }); - - // Sys Dict - // - // - // ctx.fun(`__tact_dict_set_code`, () => { - // ctx.signature( - // `cell __tact_dict_set_code(cell dict, int id, cell code)`, - // ); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return udict_set_ref(dict, 16, id, code); - // `); - // }); - // }); - - // ctx.fun(`__tact_dict_get_code`, () => { - // ctx.signature(`cell __tact_dict_get_code(cell dict, int id)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var (data, ok) = udict_get_ref?(dict, 16, id); - // throw_unless(${contractErrors.codeNotFound.id}, ok); - // return data; - // `); - // }); - // }); - - // Tuples - // - // - // ctx.fun(`__tact_tuple_create_0`, () => { - // ctx.signature(`tuple __tact_tuple_create_0()`); - // ctx.context("stdlib"); - // ctx.asm(`asm "NIL"`); - // }); - // ctx.fun(`__tact_tuple_destroy_0`, () => { - // ctx.signature(`() __tact_tuple_destroy_0()`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.append(`return ();`); - // }); - // }); - - // for (let i = 1; i < 64; i++) { - // ctx.fun(`__tact_tuple_create_${i}`, () => { - // const args: string[] = []; - // for (let j = 0; j < i; j++) { - // args.push(`X${j}`); - // } - // ctx.signature( - // `forall ${args.join(", ")} -> tuple __tact_tuple_create_${i}((${args.join(", ")}) v)`, - // ); - // ctx.context("stdlib"); - // ctx.asm(`asm "${i} TUPLE"`); - // }); - // ctx.fun(`__tact_tuple_destroy_${i}`, () => { - // const args: string[] = []; - // for (let j = 0; j < i; j++) { - // args.push(`X${j}`); - // } - // ctx.signature( - // `forall ${args.join(", ")} -> (${args.join(", ")}) __tact_tuple_destroy_${i}(tuple v)`, - // ); - // ctx.context("stdlib"); - // ctx.asm(`asm "${i} UNTUPLE"`); - // }); - // } - - // Strings - // - // - // ctx.fun(`__tact_string_builder_start_comment`, () => { - // ctx.signature(`tuple __tact_string_builder_start_comment()`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return ${ctx.used("__tact_string_builder_start")}(begin_cell().store_uint(0, 32)); - // `); - // }); - // }); - - // ctx.fun(`__tact_string_builder_start_tail_string`, () => { - // ctx.signature(`tuple __tact_string_builder_start_tail_string()`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return ${ctx.used("__tact_string_builder_start")}(begin_cell().store_uint(0, 8)); - // `); - // }); - // }); - - // ctx.fun(`__tact_string_builder_start_string`, () => { - // ctx.signature(`tuple __tact_string_builder_start_string()`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return ${ctx.used("__tact_string_builder_start")}(begin_cell()); - // `); - // }); - // }); - - // ctx.fun(`__tact_string_builder_start`, () => { - // ctx.signature(`tuple __tact_string_builder_start(builder b)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return tpush(tpush(empty_tuple(), b), null()); - // `); - // }); - // }); - - // ctx.fun(`__tact_string_builder_end`, () => { - // ctx.signature(`cell __tact_string_builder_end(tuple builders)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // (builder b, tuple tail) = uncons(builders); - // cell c = b.end_cell(); - // while(~ null?(tail)) { - // (b, tail) = uncons(tail); - // c = b.store_ref(c).end_cell(); - // } - // return c; - // `); - // }); - // }); - - // ctx.fun(`__tact_string_builder_end_slice`, () => { - // ctx.signature(`slice __tact_string_builder_end_slice(tuple builders)`); - // ctx.flag("inline"); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // return ${ctx.used("__tact_string_builder_end")}(builders).begin_parse(); - // `); - // }); - // }); - - // ctx.fun(`__tact_string_builder_append`, () => { - // ctx.signature( - // `((tuple), ()) __tact_string_builder_append(tuple builders, slice sc)`, - // ); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // int sliceRefs = slice_refs(sc); - // int sliceBits = slice_bits(sc); - - // while((sliceBits > 0) | (sliceRefs > 0)) { - - // ;; Load the current builder - // (builder b, tuple tail) = uncons(builders); - // int remBytes = 127 - (builder_bits(b) / 8); - // int exBytes = sliceBits / 8; - - // ;; Append bits - // int amount = min(remBytes, exBytes); - // if (amount > 0) { - // slice read = sc~load_bits(amount * 8); - // b = b.store_slice(read); - // } - - // ;; Update builders - // builders = cons(b, tail); - - // ;; Check if we need to add a new cell and continue - // if (exBytes - amount > 0) { - // var bb = begin_cell(); - // builders = cons(bb, builders); - // sliceBits = (exBytes - amount) * 8; - // } elseif (sliceRefs > 0) { - // sc = sc~load_ref().begin_parse(); - // sliceRefs = slice_refs(sc); - // sliceBits = slice_bits(sc); - // } else { - // sliceBits = 0; - // sliceRefs = 0; - // } - // } - - // return ((builders), ()); - // `); - // }); - // }); - - // ctx.fun(`__tact_string_builder_append_not_mut`, () => { - // ctx.signature( - // `(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc)`, - // ); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // builders~${ctx.used("__tact_string_builder_append")}(sc); - // return builders; - // `); - // }); - // }); - - // ctx.fun(`__tact_int_to_string`, () => { - // ctx.signature(`slice __tact_int_to_string(int src)`); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // var b = begin_cell(); - // if (src < 0) { - // b = b.store_uint(45, 8); - // src = - src; - // } - - // if (src < ${(10n ** 30n).toString(10)}) { - // int len = 0; - // int value = 0; - // int mult = 1; - // do { - // (src, int res) = src.divmod(10); - // value = value + (res + 48) * mult; - // mult = mult * 256; - // len = len + 1; - // } until (src == 0); - - // b = b.store_uint(value, len * 8); - // } else { - // tuple t = empty_tuple(); - // int len = 0; - // do { - // int digit = src % 10; - // t~tpush(digit); - // len = len + 1; - // src = src / 10; - // } until (src == 0); - - // int c = len - 1; - // repeat(len) { - // int v = t.at(c); - // b = b.store_uint(v + 48, 8); - // c = c - 1; - // } - // } - // return b.end_cell().begin_parse(); - // `); - // }); - // }); - - // ctx.fun(`__tact_float_to_string`, () => { - // ctx.signature(`slice __tact_float_to_string(int src, int digits)`); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // throw_if(${contractErrors.invalidArgument.id}, (digits <= 0) | (digits > 77)); - // builder b = begin_cell(); - - // if (src < 0) { - // b = b.store_uint(45, 8); - // src = - src; - // } - - // ;; Process rem part - // int skip = true; - // int len = 0; - // int rem = 0; - // tuple t = empty_tuple(); - // repeat(digits) { - // (src, rem) = src.divmod(10); - // if ( ~ ( skip & ( rem == 0 ) ) ) { - // skip = false; - // t~tpush(rem + 48); - // len = len + 1; - // } - // } - - // ;; Process dot - // if (~ skip) { - // t~tpush(46); - // len = len + 1; - // } - - // ;; Main - // do { - // (src, rem) = src.divmod(10); - // t~tpush(rem + 48); - // len = len + 1; - // } until (src == 0); - - // ;; Assemble - // int c = len - 1; - // repeat(len) { - // int v = t.at(c); - // b = b.store_uint(v, 8); - // c = c - 1; - // } - - // ;; Result - // return b.end_cell().begin_parse(); - // `); - // }); - // }); - - // ctx.fun(`__tact_log2`, () => { - // ctx.signature(`int __tact_log2(int num)`); - // ctx.context("stdlib"); - // ctx.asm(`asm "DUP 5 THROWIFNOT UBITSIZE DEC"`); - // }); - - // ctx.fun(`__tact_log`, () => { - // ctx.signature(`int __tact_log(int num, int base)`); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // throw_unless(5, num > 0); - // throw_unless(5, base > 1); - // if (num < base) { - // return 0; - // } - // int result = 0; - // while (num >= base) { - // num /= base; - // result += 1; - // } - // return result; - // `); - // }); - // }); - - // ctx.fun(`__tact_pow`, () => { - // ctx.signature(`int __tact_pow(int base, int exp)`); - // ctx.context("stdlib"); - // ctx.body(() => { - // ctx.write(` - // throw_unless(5, exp >= 0); - // int result = 1; - // repeat (exp) { - // result *= base; - // } - // return result; - // `); - // }); - // }); - - // ctx.fun(`__tact_pow2`, () => { - // ctx.signature(`int __tact_pow2(int exp)`); - // ctx.context("stdlib"); - // ctx.asm(`asm "POW2"`); - // }); } diff --git a/src/codegen/type.ts b/src/codegen/type.ts index 5a02ae6a8..6a380da78 100644 --- a/src/codegen/type.ts +++ b/src/codegen/type.ts @@ -1,8 +1,8 @@ import { CompilerContext } from "../context"; import { TypeDescription, TypeRef } from "../types/types"; import { getType } from "../types/resolveDescriptors"; -import { FuncType, UNIT_TYPE } from "../func/syntax"; -import { Type } from "../func/syntaxConstructors"; +import { FuncAstType } from "../func/grammar"; +import { Type, unit } from "../func/syntaxConstructors"; /** * Unpacks string representation of a user-defined Tact type from its type description. @@ -112,7 +112,7 @@ export function resolveFuncType( descriptor: TypeRef | TypeDescription | string, optional: boolean = false, usePartialFields: boolean = false, -): FuncType { +): FuncAstType { // String if (typeof descriptor === "string") { return resolveFuncType( @@ -139,7 +139,7 @@ export function resolveFuncType( return resolveFuncType(ctx, getType(ctx, descriptor.name), false, true); } if (descriptor.kind === "void") { - return UNIT_TYPE; + return unit(); } // TypeDescription @@ -195,7 +195,7 @@ export function resolveFuncType( export function resolveFuncTupleType( ctx: CompilerContext, descriptor: TypeRef | TypeDescription | string, -): FuncType { +): FuncAstType { // String if (typeof descriptor === "string") { return resolveFuncTupleType(ctx, getType(ctx, descriptor)); diff --git a/src/codegen/util.ts b/src/codegen/util.ts index 8b209cca2..10c104805 100644 --- a/src/codegen/util.ts +++ b/src/codegen/util.ts @@ -1,7 +1,7 @@ import { getType } from "../types/resolveDescriptors"; import { CompilerContext } from "../context"; import { TypeRef } from "../types/types"; -import { FuncAstExpr } from "../func/syntax"; +import { FuncAstExpression } from "../func/grammar"; import { id, call } from "../func/syntaxConstructors"; import { AstId, idText } from "../grammar/ast"; @@ -66,8 +66,8 @@ export function cast( ctx: CompilerContext, from: TypeRef, to: TypeRef, - expr: FuncAstExpr, -): FuncAstExpr { + expr: FuncAstExpression, +): FuncAstExpression { if (from.kind === "ref" && to.kind === "ref") { if (from.name !== to.name) { throw Error(`Impossible: ${from.name} != ${to.name}`); diff --git a/src/func/grammar.ts b/src/func/grammar.ts index e9f14f177..c27911464 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -574,6 +574,7 @@ export type FuncAstInclude = { // export type FuncAstModuleItem = + | FuncAstComment | FuncAstPragma | FuncAstInclude | FuncAstGlobalVariablesDeclaration @@ -756,7 +757,9 @@ export type FuncAstStatement = | FuncAstStatementUntil | FuncAstStatementWhile | FuncAstStatementTryCatch - | FuncAstStatementExpression; + | FuncAstStatementExpression + | FuncAstCR + | FuncAstComment; /** * return Expression; @@ -1053,7 +1056,7 @@ export type FuncAstExpressionUnary = { loc: FuncSrcInfo; }; -export type FuncOpUnary = "~"; +export type FuncOpUnary = "~" | "-" | "+"; /** * parse_expr80 @@ -1071,8 +1074,9 @@ export type FuncExpressionMethodCall = { }; export type FuncArgument = - | FuncAstMethodId + | FuncAstId | FuncAstUnit + | FuncAstExpression | FuncAstExpressionTensor | FuncAstExpressionTuple; diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index cfbd79dcd..e95a5a0c6 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -3,6 +3,9 @@ import { funcOpBitwiseShift, funcOpAddBitwise, funcOpMulBitwise, + FuncAstHole, + FuncAstVersionRange, + FuncAstPragmaVersionRange, FuncAstStatementExpression, FuncPragmaLiteralValue, FuncAstConstantsDefinition, @@ -27,7 +30,6 @@ import { FuncOpAssign, FuncAstId, FuncAstStringLiteral, - FuncArgument, FuncAstPlainId, FuncAstStatementReturn, FuncAstStatementBlock, @@ -99,6 +101,10 @@ export class Type { public static tuple_values(...types: FuncAstType[]): FuncAstType { return { kind: "type_tuple", types, loc: dummySrcInfo }; } + + public static hole(): FuncAstHole { + return { kind: "hole", value: "_", loc: dummySrcInfo }; + } } export class FunAttr { @@ -145,7 +151,15 @@ export function int(num: bigint | number): FuncAstIntegerLiteral { return integerLiteral(num, false); } -export function hex(num: bigint | number): FuncAstIntegerLiteral { +function hexToBigInt(hexString: string): bigint { + if (hexString.startsWith("0x")) { + hexString = hexString.slice(2); + } + return BigInt(`0x${hexString}`); +} + +export function hex(value: string | bigint | number): FuncAstIntegerLiteral { + const num = typeof value === "string" ? hexToBigInt(value) : value; return integerLiteral(num, true); } @@ -188,7 +202,7 @@ export function id(value: string): FuncAstId { export function call( fun: FuncAstExpression | string, - args: FuncArgument[], + args: FuncAstExpression[], // TODO: doesn't support method calls params: Partial<{ receiver: FuncAstExpression }> = {}, ): FuncAstExpressionFunCall { @@ -616,6 +630,33 @@ export function include(path: string): FuncAstInclude { }; } +export function version( + op: FuncAstVersionRange["op"], + versionString: string, +): FuncAstPragmaVersionRange { + const versionNumbers = versionString.split(".").map(BigInt); + if (versionNumbers.length < 1) { + throwInternalCompilerError( + `Incorrect version: ${versionString}. Expected format: "1.2.3"`, + tactDummySrcInfo, + ); + } + const range: FuncAstVersionRange = { + kind: "version_range", + op, + major: versionNumbers[0]!, + minor: versionNumbers[1], + patch: versionNumbers[2], + loc: dummySrcInfo, + }; + return { + kind: "pragma_version_range", + allow: true, + range, + loc: dummySrcInfo, + }; +} + export function pragma(value: FuncPragmaLiteralValue): FuncAstPragma { return { kind: "pragma_literal", From ed2c9820c8b29b4bf30f4d1f05911e199d06c97a Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 29 Aug 2024 02:57:19 +0000 Subject: [PATCH 115/162] feat(iterators): Support new grammar --- src/func/iterators.ts | 293 +++++++++++++++++++++++------------------- 1 file changed, 163 insertions(+), 130 deletions(-) diff --git a/src/func/iterators.ts b/src/func/iterators.ts index 27775c3c8..2f7828898 100644 --- a/src/func/iterators.ts +++ b/src/func/iterators.ts @@ -1,4 +1,4 @@ -import { FuncAstNode, FuncAstExpr } from "./syntax"; +import { FuncAstNode, FuncAstExpression } from "./grammar"; import JSONbig from "json-bigint"; @@ -10,142 +10,175 @@ import JSONbig from "json-bigint"; */ export function forEachExpression( node: FuncAstNode, - callback: (expr: FuncAstExpr) => void, + callback: (expr: FuncAstExpression) => void, ): void { - if ("kind" in node) { - switch (node.kind) { - // Expressions - case "id_expr": - case "number_expr": - case "hex_number_expr": - case "bool_expr": - case "string_expr": - case "nil_expr": - case "unit_expr": - case "primitive_type_expr": - callback(node); - break; - case "call_expr": - if (node.receiver) forEachExpression(node.receiver, callback); - forEachExpression(node.fun, callback); - node.args.forEach((arg) => forEachExpression(arg, callback)); - callback(node); - break; - case "assign_expr": - case "augmented_assign_expr": - forEachExpression(node.lhs, callback); - forEachExpression(node.rhs, callback); - callback(node); - break; - case "ternary_expr": - forEachExpression(node.cond, callback); - forEachExpression(node.trueExpr, callback); - forEachExpression(node.falseExpr, callback); - callback(node); - break; - case "binary_expr": - forEachExpression(node.lhs, callback); - forEachExpression(node.rhs, callback); - callback(node); - break; - case "unary_expr": - forEachExpression(node.value, callback); - callback(node); - break; - case "apply_expr": - forEachExpression(node.lhs, callback); - forEachExpression(node.rhs, callback); - callback(node); - break; - case "tuple_expr": - case "tensor_expr": - node.values.forEach((value) => - forEachExpression(value, callback), + switch (node.kind) { + case "expression_assign": + callback(node); + forEachExpression(node.left, callback); + forEachExpression(node.right, callback); + break; + case "expression_conditional": + callback(node); + forEachExpression(node.condition, callback); + forEachExpression(node.consequence, callback); + forEachExpression(node.alternative, callback); + break; + case "expression_compare": + callback(node); + forEachExpression(node.left, callback); + forEachExpression(node.right, callback); + break; + case "expression_bitwise_shift": + case "expression_add_bitwise": + case "expression_mul_bitwise": + callback(node); + forEachExpression(node.left, callback); + node.ops.forEach((part) => forEachExpression(part.expr, callback)); + break; + case "expression_unary": + callback(node); + forEachExpression(node.operand, callback); + break; + case "expression_method": + callback(node); + forEachExpression(node.object, callback); + node.calls.forEach((call) => + forEachExpression(call.argument, callback), + ); + break; + case "expression_var_decl": + callback(node); + if ( + node.names.kind === "expression_tensor_var_decl" || + node.names.kind === "expression_tuple_var_decl" + ) { + node.names.names.forEach((name) => + forEachExpression(name, callback), ); - callback(node); - break; - case "hole_expr": - forEachExpression(node.init, callback); - callback(node); - break; - - // Statements - case "var_def_stmt": - if (node.init) forEachExpression(node.init, callback); - break; - case "return_stmt": - if (node.value) forEachExpression(node.value, callback); - break; - case "block_stmt": - node.body.forEach((stmt) => forEachExpression(stmt, callback)); - break; - case "repeat_stmt": - forEachExpression(node.condition, callback); - node.body.forEach((stmt) => forEachExpression(stmt, callback)); - break; - case "condition_stmt": - if (node.condition) forEachExpression(node.condition, callback); - node.body.forEach((stmt) => forEachExpression(stmt, callback)); - if (node.else) forEachExpression(node.else, callback); - break; - case "do_until_stmt": - node.body.forEach((stmt) => forEachExpression(stmt, callback)); - forEachExpression(node.condition, callback); - break; - case "while_stmt": - forEachExpression(node.condition, callback); - node.body.forEach((stmt) => forEachExpression(stmt, callback)); - break; - case "expr_stmt": - forEachExpression(node.expr, callback); - break; - case "try_catch_stmt": - node.tryBlock.forEach((stmt) => + } else { + forEachExpression(node.names, callback); + } + break; + case "expression_fun_call": + callback(node); + forEachExpression(node.object, callback); + node.arguments.forEach((arg) => forEachExpression(arg, callback)); + break; + case "expression_tensor": + case "expression_tuple": + callback(node); + node.expressions.forEach((expr) => + forEachExpression(expr, callback), + ); + break; + case "module": + node.items.forEach((item) => forEachExpression(item, callback)); + break; + case "pragma_literal": + case "pragma_version_range": + case "pragma_version_string": + case "include": + break; + case "global_variables_declaration": + // Do nothing; global variables don't contain initializers + break; + case "constants_definition": + node.constants.forEach((c) => forEachExpression(c.value, callback)); + break; + case "asm_function_definition": + break; + case "function_declaration": + case "function_definition": + forEachExpression(node.name, callback); + node.attributes.forEach((attr) => { + if (attr.kind === "method_id" && attr.value) { + forEachExpression(attr.value, callback); + } + }); + if (node.kind === "function_definition") { + node.statements.forEach((stmt) => forEachExpression(stmt, callback), ); - node.catchBlock.forEach((stmt) => + } + break; + case "unit": + break; + case "statement_return": + if (node.expression) forEachExpression(node.expression, callback); + break; + case "statement_block": + node.statements.forEach((stmt) => + forEachExpression(stmt, callback), + ); + break; + case "statement_empty": + break; + case "statement_condition_if": + forEachExpression(node.condition, callback); + node.consequences.forEach((stmt) => + forEachExpression(stmt, callback), + ); + if (node.alternatives) { + node.alternatives.forEach((stmt) => forEachExpression(stmt, callback), ); - break; - - // Other and top-level elements - case "constant": - forEachExpression(node.init, callback); - break; - case "function_definition": - node.body.forEach((stmt) => forEachExpression(stmt, callback)); - break; - case "asm_function_definition": - // Do nothing; we don't iterate raw asm - break; - case "comment": - case "cr": - case "include": - case "pragma": - case "global_variable": - case "function_declaration": - // These nodes don't contain expressions, so we don't need to do anything - break; - case "module": - node.entries.forEach((entry) => - forEachExpression(entry, callback), + } + break; + case "statement_condition_elseif": + forEachExpression(node.conditionIf, callback); + node.consequencesIf.forEach((stmt) => + forEachExpression(stmt, callback), + ); + forEachExpression(node.conditionElseif, callback); + node.consequencesElseif.forEach((stmt) => + forEachExpression(stmt, callback), + ); + if (node.alternativesElseif) { + node.alternativesElseif.forEach((stmt) => + forEachExpression(stmt, callback), ); - break; - - // FuncType cases - case "int": - case "cell": - case "slice": - case "builder": - case "cont": - case "tuple": - case "tensor": - case "hole": - case "type": - break; + } + break; + case "statement_repeat": + forEachExpression(node.iterations, callback); + node.statements.forEach((stmt) => + forEachExpression(stmt, callback), + ); + break; + case "statement_until": + case "statement_while": + forEachExpression(node.condition, callback); + node.statements.forEach((stmt) => + forEachExpression(stmt, callback), + ); + break; + case "statement_try_catch": + node.statementsTry.forEach((stmt) => + forEachExpression(stmt, callback), + ); + node.statementsCatch.forEach((stmt) => + forEachExpression(stmt, callback), + ); + break; + case "statement_expression": + forEachExpression(node.expression, callback); + break; + // No nested nodes for these cases + case "method_id": + case "quoted_id": + case "operator_id": + case "plain_id": + case "unused_id": + case "integer_literal": + case "string_singleline": + case "string_multiline": + case "cr": + case "comment_singleline": + case "comment_multiline": + break; - default: - throw new Error(`Unsupported node: ${JSONbig.stringify(node)}`); - } + default: + throw new Error(`Unsupported node: ${JSON.stringify(node)}`); } } From bb0965ba8dbeaf9805b55461c265aa992cfcc595 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 29 Aug 2024 11:49:58 +0000 Subject: [PATCH 116/162] fix(grammar): Forbid ;-style comments --- src/func/grammar.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/func/grammar.ts b/src/func/grammar.ts index c27911464..15cf0eda6 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -1418,7 +1418,6 @@ export type FuncAstComment = FuncAstCommentSingleLine | FuncAstCommentMultiLine; export type FuncAstCommentSingleLine = { kind: "comment_singleline"; line: string; - style: ";" | ";;"; loc: FuncSrcInfo; }; @@ -1436,7 +1435,7 @@ export type FuncAstCommentMultiLine = { kind: "comment_multiline"; lines: string[]; skipCR: boolean; - style: "{-" | ";" | ";;"; + style: "{-" | ";;"; loc: FuncSrcInfo; }; @@ -1466,7 +1465,6 @@ semantics.addOperation("astOfModule", { return { kind: "comment_singleline", line: lineContents.sourceString, - style: ";;", loc: createSrcInfo(this), }; }, From 9142be6bcc93e42d45270966f90cd295cceecc65 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 29 Aug 2024 12:05:10 +0000 Subject: [PATCH 117/162] fix(codegen): Update some functionality --- src/codegen/context.ts | 4 ++-- src/codegen/function.ts | 2 +- src/codegen/statement.ts | 29 ++++++++++++++++++++--------- src/func/syntaxConstructors.ts | 26 ++++++++++++++++++++++++-- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index 48842d086..504e57a87 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -103,8 +103,8 @@ export class WriterContext { ): void { forEachExpression(fun, (expr) => { // TODO: It doesn't save receivers. But should it? - if (expr.kind === "call_expr" && expr.fun.kind === "id_expr") { - depends.add(expr.fun.value); + if (expr.kind === "expression_fun_call" && expr.object.kind === "plain_id") { + depends.add(expr.object.value); } }); } diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 1da22be23..893cb43b6 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -234,7 +234,7 @@ export class FunctionGen { } }); const body = - values.length === 0 && returnTy.kind === "tuple" + values.length === 0 && returnTy.kind === "type_tuple" ? [ret(call("empty_tuple", []))] : [ret(tensor(...values))]; const constructor = this.ctx.fun(attrs, name, params, returnTy, body); diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index b133b9fe1..5b87e95e9 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -25,6 +25,7 @@ import { assign, unit, condition, + conditionElseif, vardef, Type, } from "../func/syntaxConstructors"; @@ -61,7 +62,10 @@ export class StatementGen { return ExpressionGen.fromTact(this.ctx, expr).writeExpression(); } - private makeCastedExpr(expr: AstExpression, to: TypeRef): FuncAstExpression { + private makeCastedExpr( + expr: AstExpression, + to: TypeRef, + ): FuncAstExpression { return ExpressionGen.fromTact(this.ctx, expr).writeCastedExpression(to); } @@ -78,20 +82,27 @@ export class StatementGen { ).writeStatement(); const cond = this.makeExpr(f.condition); const thenBlock = f.trueStatements.map(writeStmt); - const elseStmt: FuncAstStatementCondition | undefined = - f.falseStatements !== null && f.falseStatements.length > 0 - ? condition(undefined, f.falseStatements.map(writeStmt)) - : f.elseif - ? this.writeCondition(f.elseif) - : undefined; - return condition(cond, thenBlock, false, elseStmt); + const elseBlock = f.falseStatements?.map(writeStmt); + if (f.elseif) { + return conditionElseif( + cond, + thenBlock, + this.makeExpr(f.elseif.condition), + f.elseif.trueStatements.map(writeStmt), + elseBlock, + ); + } else { + return condition(cond, thenBlock, elseBlock); + } } public writeStatement(): FuncAstStatement { switch (this.tactStmt.kind) { case "statement_return": { const selfVar = this.selfName ? id(this.selfName) : undefined; - const getValue = (expr: FuncAstExpression): FuncAstExpression => + const getValue = ( + expr: FuncAstExpression, + ): FuncAstExpression => this.selfName ? tensor(selfVar!, expr) : expr; if (this.tactStmt.expression) { const castedReturns = this.makeCastedExpr( diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index e95a5a0c6..abeff7602 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -403,7 +403,7 @@ export function repeat( export function condition( condition: FuncAstExpression, - body: FuncAstStatement[], + bodyStmts: FuncAstStatement[], elseStmts?: FuncAstStatement[], params: Partial<{ positive: boolean }> = {}, ): FuncAstStatementCondition { @@ -412,12 +412,34 @@ export function condition( kind: "statement_condition_if", condition, positive, - consequences: body, + consequences: bodyStmts, alternatives: elseStmts, loc: dummySrcInfo, }; } +export function conditionElseif( + conditionIf: FuncAstExpression, + bodyStmts: FuncAstStatement[], + conditionElseif: FuncAstExpression, + elseifStmts: FuncAstStatement[], + elseStmts?: FuncAstStatement[], + params: Partial<{ positiveIf: boolean; positiveElseif: boolean }> = {}, +): FuncAstStatementCondition { + const { positiveIf = false, positiveElseif = false } = params; + return { + kind: "statement_condition_elseif", + positiveIf, + conditionIf, + consequencesIf: bodyStmts, + positiveElseif, + conditionElseif, + consequencesElseif: elseifStmts, + alternativesElseif: elseStmts, + loc: dummySrcInfo, + }; +} + export function doUntil( condition: FuncAstExpression, statements: FuncAstStatement[], From 8fc6f1566a7a8cbbf03407f1f22be377d648f28f Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 29 Aug 2024 13:30:48 +0000 Subject: [PATCH 118/162] feat(func): Half-backed `pp` for the new AST --- src/func/formatter.ts | 526 ---------------------------- src/func/iterators.ts | 5 +- src/func/prettyPrinter.ts | 704 ++++++++++++++++++++++++++++++++++++++ src/func/syntaxUtils.ts | 12 + 4 files changed, 718 insertions(+), 529 deletions(-) delete mode 100644 src/func/formatter.ts create mode 100644 src/func/prettyPrinter.ts diff --git a/src/func/formatter.ts b/src/func/formatter.ts deleted file mode 100644 index 54c555a17..000000000 --- a/src/func/formatter.ts +++ /dev/null @@ -1,526 +0,0 @@ -import { - FuncAstNode, - FuncAstFormalFunctionParam, - FuncAstFunctionAttribute, - FuncType, - FuncAstIdExpr, - FuncAstAssignExpr, - FuncAstPragma, - FuncAstComment, - FuncAstCR, - FuncAstInclude, - FuncAstModule, - FuncAstFunctionDeclaration, - FuncAstFunctionDefinition, - FuncAstAsmFunction, - FuncAstVarDefStmt, - FuncAstReturnStmt, - FuncAstBlockStmt, - FuncAstRepeatStmt, - FuncAstConditionStmt, - FuncAstDoUntilStmt, - FuncAstWhileStmt, - FuncAstExprStmt, - FuncAstTryCatchStmt, - FuncAstConstant, - FuncAstGlobalVariable, - FuncAstCallExpr, - FuncAstAugmentedAssignExpr, - FuncAstTernaryExpr, - FuncAstBinaryExpr, - FuncAstUnaryExpr, - FuncAstNumberExpr, - FuncAstHexNumberExpr, - FuncAstBoolExpr, - FuncAstStringExpr, - FuncAstNilExpr, - FuncAstApplyExpr, - FuncAstTupleExpr, - FuncAstTensorExpr, - FuncAstUnitExpr, - FuncAstHoleExpr, - FuncAstPrimitiveTypeExpr, -} from "./syntax"; - -import JSONbig from "json-bigint"; - -/** - * Provides utilities to print the generated Func AST. - */ -export class FuncFormatter { - /** - * Limit for the length of a single line. - * @default 100 - */ - private lineLengthLimit: number; - /** - * Number of spaces used for identation. - * @default 4 - */ - private indent: number; - private currentIndent: number; - - constructor( - params: Partial<{ indent: number; lineLengthLimit: number }> = {}, - ) { - const { indent = 4, lineLengthLimit = 100 } = params; - this.lineLengthLimit = lineLengthLimit; - this.indent = indent; - this.currentIndent = 0; - } - - public dump(node: FuncAstNode): string { - switch (node.kind) { - case "id_expr": - return this.formatIdExpr(node as FuncAstIdExpr); - case "include": - return this.formatInclude(node as FuncAstInclude); - case "pragma": - return this.formatPragma(node as FuncAstPragma); - case "comment": - return this.formatComment(node as FuncAstComment); - case "cr": - return this.formatCR(node as FuncAstCR); - case "int": - case "hole": - case "cell": - case "slice": - case "builder": - case "cont": - case "tuple": - case "tensor": - case "type": - return this.formatType(node as FuncType); - case "module": - return this.formatModule(node as FuncAstModule); - case "function_declaration": - return this.formatFunctionDeclaration( - node as FuncAstFunctionDeclaration, - ); - case "function_definition": - return this.formatFunctionDefinition( - node as FuncAstFunctionDefinition, - ); - case "asm_function_definition": - return this.formatAsmFunction(node as FuncAstAsmFunction); - case "var_def_stmt": - return this.formatVarDefStmt(node as FuncAstVarDefStmt); - case "return_stmt": - return this.formatReturnStmt(node as FuncAstReturnStmt); - case "block_stmt": - return this.formatBlockStmt(node as FuncAstBlockStmt); - case "repeat_stmt": - return this.formatRepeatStmt(node as FuncAstRepeatStmt); - case "condition_stmt": - return this.formatConditionStmt(node as FuncAstConditionStmt); - case "do_until_stmt": - return this.formatDoUntilStmt(node as FuncAstDoUntilStmt); - case "while_stmt": - return this.formatWhileStmt(node as FuncAstWhileStmt); - case "expr_stmt": - return this.formatExprStmt(node as FuncAstExprStmt); - case "try_catch_stmt": - return this.formatTryCatchStmt(node as FuncAstTryCatchStmt); - case "constant": - return this.formatConstant(node as FuncAstConstant); - case "global_variable": - return this.formatGlobalVariable(node as FuncAstGlobalVariable); - case "call_expr": - return this.formatCallExpr(node as FuncAstCallExpr); - case "assign_expr": - return this.formatAssignExpr(node as FuncAstAssignExpr); - case "augmented_assign_expr": - return this.formatAugmentedAssignExpr( - node as FuncAstAugmentedAssignExpr, - ); - case "ternary_expr": - return this.formatTernaryExpr(node as FuncAstTernaryExpr); - case "binary_expr": - return this.formatBinaryExpr(node as FuncAstBinaryExpr); - case "unary_expr": - return this.formatUnaryExpr(node as FuncAstUnaryExpr); - case "number_expr": - return this.formatNumberExpr(node as FuncAstNumberExpr); - case "hex_number_expr": - return this.formatHexNumberExpr(node as FuncAstHexNumberExpr); - case "bool_expr": - return this.formatBoolExpr(node as FuncAstBoolExpr); - case "string_expr": - return this.formatStringExpr(node as FuncAstStringExpr); - case "nil_expr": - return this.formatNilExpr(node as FuncAstNilExpr); - case "apply_expr": - return this.formatApplyExpr(node as FuncAstApplyExpr); - case "tuple_expr": - return this.formatTupleExpr(node as FuncAstTupleExpr); - case "tensor_expr": - return this.formatTensorExpr(node as FuncAstTensorExpr); - case "unit_expr": - return this.formatUnitExpr(node as FuncAstUnitExpr); - case "hole_expr": - return this.formatHoleExpr(node as FuncAstHoleExpr); - case "primitive_type_expr": - return this.formatPrimitiveTypeExpr( - node as FuncAstPrimitiveTypeExpr, - ); - default: - throw new Error( - `Unsupported node: ${JSONbig.stringify(node, null, 2)}`, - ); - } - } - - private formatModule(node: FuncAstModule): string { - return node.entries - .map((entry, index) => { - const previousEntry = node.entries[index - 1]; - const isSequentialPragmaOrInclude = - previousEntry && - previousEntry.kind === entry.kind && - (entry.kind === "include" || entry.kind === "pragma"); - const isPreviousCommentSkipCR = - previousEntry && - previousEntry.kind === "comment" && - (previousEntry as FuncAstComment).skipCR; - const separator = - isSequentialPragmaOrInclude || isPreviousCommentSkipCR - ? "\n" - : "\n\n"; - return (index > 0 ? separator : "") + this.dump(entry); - }) - .join(""); - } - - private formatFunctionAttribute(attr: FuncAstFunctionAttribute): string { - switch (attr.kind) { - case "method_id": - return attr.value === undefined - ? "method_id" - : `method_id(${attr.value})`; - case "impure": - case "inline": - case "inline_ref": - return attr.kind; - } - } - - private formatFunctionSignature( - name: FuncAstIdExpr, - attrs: FuncAstFunctionAttribute[], - params: FuncAstFormalFunctionParam[], - returnTy: FuncType, - ): string { - const attrsStr = - attrs.length === 0 - ? "" - : ` ${attrs.map(this.formatFunctionAttribute).join(" ")}`; - const nameStr = this.dump(name); - const paramsStr = params - .map((param) => `${this.dump(param.ty)} ${this.dump(param.name)}`) - .join(", "); - const returnTypeStr = this.dump(returnTy); - return `${returnTypeStr} ${nameStr}(${paramsStr})${attrsStr}`; - } - - private formatFunctionDeclaration( - node: FuncAstFunctionDeclaration, - ): string { - const signature = this.formatFunctionSignature( - node.name, - node.attrs, - node.params, - node.returnTy, - ); - return `${signature};`; - } - - private formatFunctionDefinition(node: FuncAstFunctionDefinition): string { - const signature = this.formatFunctionSignature( - node.name, - node.attrs, - node.params, - node.returnTy, - ); - const body = this.formatIndentedBlock( - node.body.map((stmt) => this.dump(stmt)).join("\n"), - ); - return `${signature} {\n${body}\n}`; - } - - private formatAsmFunction(node: FuncAstAsmFunction): string { - const signature = this.formatFunctionSignature( - node.name, - node.attrs, - node.params, - node.returnTy, - ); - return `${signature} asm ${this.dump(node.rawAsm)};`; - } - - private formatVarDefStmt(node: FuncAstVarDefStmt): string { - const names = node.names.map(this.dump); - const namesStr = - names.length === 1 ? names[0] : `(${names.join(", ")})`; - const type = node.ty ? this.dump(node.ty) : "var"; - const init = node.init ? ` = ${this.dump(node.init)}` : ""; - return `${type} ${namesStr}${init};`; - } - - private formatReturnStmt(node: FuncAstReturnStmt): string { - const value = node.value ? ` ${this.dump(node.value)}` : ""; - return `return${value};`; - } - - private formatBlockStmt(node: FuncAstBlockStmt): string { - const body = this.formatIndentedBlock( - node.body - .map((stmt, index) => { - const previousStmt = node.body[index - 1]; - const isPreviousCommentSkipCR = - previousStmt && - previousStmt.kind === "comment" && - (previousStmt as FuncAstComment).skipCR; - const separator = isPreviousCommentSkipCR ? "" : "\n"; - return (index > 0 ? separator : "") + this.dump(stmt); - }) - .join(""), - ); - return `{\n${body}\n}`; - } - - private formatRepeatStmt(node: FuncAstRepeatStmt): string { - const condition = this.dump(node.condition); - const body = this.formatIndentedBlock( - node.body.map((stmt) => this.dump(stmt)).join("\n"), - ); - return `repeat ${condition} {\n${body}\n}`; - } - - private formatConditionStmt(node: FuncAstConditionStmt): string { - const condition = node.condition - ? `(${this.dump(node.condition)})` - : ""; - const ifnot = node.ifnot ? "ifnot" : "if"; - const bodyBlock = this.formatIndentedBlock( - node.body.map((stmt) => this.dump(stmt)).join("\n"), - ); - const elseBlock = node.else - ? ` else {\n${this.formatIndentedBlock(this.dump(node.else))}\n}` - : ""; - return `${ifnot} ${condition} {\n${bodyBlock}\n}${elseBlock}`; - } - - private formatDoUntilStmt(node: FuncAstDoUntilStmt): string { - const condition = this.dump(node.condition); - const body = this.formatIndentedBlock( - node.body.map((stmt) => this.dump(stmt)).join("\n"), - ); - return `do {\n${body}\n} until ${condition};`; - } - - private formatWhileStmt(node: FuncAstWhileStmt): string { - const condition = this.dump(node.condition); - const body = this.formatIndentedBlock( - node.body.map((stmt) => this.dump(stmt)).join("\n"), - ); - return `while ${condition} {\n${body}\n}`; - } - - private formatExprStmt(node: FuncAstExprStmt): string { - return `${this.dump(node.expr)};`; - } - - private formatTryCatchStmt(node: FuncAstTryCatchStmt): string { - const tryBlock = this.formatIndentedBlock( - node.tryBlock.map((stmt) => this.dump(stmt)).join("\n"), - ); - const catchBlock = this.formatIndentedBlock( - node.catchBlock.map((stmt) => this.dump(stmt)).join("\n"), - ); - const catchVar = node.catchVar ? ` (${this.dump(node.catchVar)})` : ""; - return `try {\n${tryBlock}\n} catch${catchVar} {\n${catchBlock}\n}`; - } - - private formatConstant(node: FuncAstConstant): string { - const type = this.dump(node.ty); - const init = this.dump(node.init); - return `const ${type} = ${init};`; - } - - private formatGlobalVariable(node: FuncAstGlobalVariable): string { - const name = this.dump(node.name); - const type = this.dump(node.ty); - return `global ${type} ${name};`; - } - - private formatCallExpr(node: FuncAstCallExpr): string { - const receiver = - node.receiver === undefined ? "" : `${this.dump(node.receiver)}.`; - const fun = this.dump(node.fun); - const args = node.args.map((arg) => this.dump(arg)).join(", "); - return `${receiver}${fun}(${args})`; - } - - private formatAssignExpr(node: FuncAstAssignExpr): string { - const lhs = this.dump(node.lhs); - const rhs = this.dump(node.rhs); - return `${lhs} = ${rhs}`; - } - - private formatAugmentedAssignExpr( - node: FuncAstAugmentedAssignExpr, - ): string { - const lhs = this.dump(node.lhs); - const rhs = this.dump(node.rhs); - return `${lhs} ${node.op} ${rhs}`; - } - - private formatTernaryExpr(node: FuncAstTernaryExpr): string { - const cond = this.dump(node.cond); - const body = this.dump(node.trueExpr); - const elseExpr = this.dump(node.falseExpr); - return `${cond} ? ${body} : ${elseExpr}`; - } - - private formatBinaryExpr(node: FuncAstBinaryExpr): string { - const lhs = this.dump(node.lhs); - const rhs = this.dump(node.rhs); - return `${lhs} ${node.op} ${rhs}`; - } - - private formatUnaryExpr(node: FuncAstUnaryExpr): string { - const value = this.dump(node.value); - const isNonTrivial = - node.value.kind !== "number_expr" && - node.value.kind !== "hex_number_expr" && - node.value.kind !== "unit_expr" && - node.value.kind !== "hole_expr" && - node.value.kind !== "tuple_expr" && - node.value.kind !== "tensor_expr" && - node.value.kind !== "primitive_type_expr" && - node.value.kind !== "bool_expr" && - node.value.kind !== "string_expr" && - node.value.kind !== "nil_expr" && - node.value.kind !== "id_expr"; - return node.op - ? `${node.op}${isNonTrivial ? `(${value})` : value}` - : value; - } - - private formatNumberExpr(node: FuncAstNumberExpr): string { - return node.value.toString(); - } - - private formatHexNumberExpr(node: FuncAstHexNumberExpr): string { - return node.value; - } - - private formatBoolExpr(node: FuncAstBoolExpr): string { - return node.value.toString(); - } - - private formatStringExpr(node: FuncAstStringExpr): string { - const ty = node.ty ? node.ty : ""; - return `"${node.value}"${ty}`; - } - - private formatNilExpr(_: FuncAstNilExpr): string { - return "nil"; - } - - private formatApplyExpr(node: FuncAstApplyExpr): string { - const lhs = this.dump(node.lhs); - const rhs = this.dump(node.rhs); - return `${lhs} ${rhs}`; - } - - private formatTupleExpr(node: FuncAstTupleExpr): string { - const values = node.values.map((value) => this.dump(value)).join(", "); - return `[${values}]`; - } - - private formatTensorExpr(node: FuncAstTensorExpr): string { - const values = node.values.map((value) => this.dump(value)); - const singleLine = `(${values.join(", ")})`; - - if (singleLine.length <= this.lineLengthLimit) { - return singleLine; - } else { - const indentedValues = values - .map((value) => this.indentLine(value)) - .join(",\n"); - return `(\n${indentedValues}\n${" ".repeat(this.currentIndent)})`; - } - } - - private formatUnitExpr(_: FuncAstUnitExpr): string { - return "()"; - } - - private formatHoleExpr(node: FuncAstHoleExpr): string { - const id = node.id ? node.id : "_"; - const init = this.dump(node.init); - return `${id} = ${init}`; - } - - private formatPrimitiveTypeExpr(node: FuncAstPrimitiveTypeExpr): string { - return node.ty.kind; - } - - private formatIdExpr(node: FuncAstIdExpr): string { - return node.value; - } - - private formatInclude(node: FuncAstInclude): string { - return `#include "${node.value}";`; - } - - private formatPragma(node: FuncAstPragma): string { - return `#pragma ${node.value};`; - } - - private formatComment(node: FuncAstComment): string { - return node.values - .map((v) => `${node.style}${v.length > 0 ? " " + v : ""}`) - .join("\n"); - } - - private formatCR(node: FuncAstCR): string { - return node.lines === 1 ? "" : "\n".repeat(node.lines - 1); - } - - private formatType(node: FuncType): string { - switch (node.kind) { - case "hole": - return "_"; - case "int": - case "cell": - case "slice": - case "builder": - case "cont": - case "tuple": - case "type": - return node.kind; - case "tensor": - return `(${node.value.map((t) => this.formatType(t)).join(", ")})`; - default: - throw new Error( - `Unsupported type kind: ${JSONbig.stringify(node, null, 2)}`, - ); - } - } - - private indentLine(line: string): string { - return " ".repeat(this.currentIndent + this.indent) + line; - } - - private formatIndentedBlock(content: string): string { - this.currentIndent += this.indent; - const indentedContent = content - .split("\n") - .map((line) => " ".repeat(this.currentIndent) + line) - .join("\n"); - this.currentIndent -= this.indent; - return indentedContent; - } -} diff --git a/src/func/iterators.ts b/src/func/iterators.ts index 2f7828898..2a0dc7a38 100644 --- a/src/func/iterators.ts +++ b/src/func/iterators.ts @@ -1,6 +1,5 @@ import { FuncAstNode, FuncAstExpression } from "./grammar"; - -import JSONbig from "json-bigint"; +import { throwUnsupportedNodeError } from "./syntaxUtils"; /** * Recursively executes `callback` on each nested expression. @@ -179,6 +178,6 @@ export function forEachExpression( break; default: - throw new Error(`Unsupported node: ${JSON.stringify(node)}`); + throwUnsupportedNodeError(node); } } diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts new file mode 100644 index 000000000..ccb9b3d65 --- /dev/null +++ b/src/func/prettyPrinter.ts @@ -0,0 +1,704 @@ +import { + FuncAstNode, + FuncAstModule, + FuncAstVersionRange, + FuncAstParameter, + FuncAstConstant, + FuncAstGlobalVariable, + FuncAstFunctionAttribute, + FuncVarDeclPart, + FuncAstId, + FuncAstTypeTensor, + FuncAstMethodId, + FuncAstQuotedId, + FuncAstOperatorId, + FuncAstPlainId, + FuncAstUnusedId, + FuncAstTypeTuple, + FuncAstHole, + FuncAstCR, + FuncAstComment, + FuncAstPragmaLiteral, + FuncAstPragmaVersionRange, + FuncAstPragmaVersionString, + FuncAstInclude, + FuncAstGlobalVariablesDeclaration, + FuncAstConstantsDefinition, + FuncAstAsmFunctionDefinition, + FuncAstFunctionDeclaration, + FuncAstFunctionDefinition, + FuncAstStatementReturn, + FuncAstStatementBlock, + FuncAstStatementConditionIf, + FuncAstStatementConditionElseIf, + FuncAstStatementRepeat, + FuncAstStatementUntil, + FuncAstStatementWhile, + FuncAstStatementTryCatch, + FuncAstStatementExpression, + FuncAstExpressionAssign, + FuncAstExpressionConditional, + FuncAstExpressionCompare, + FuncAstExpressionBitwiseShift, + FuncAstExpressionAddBitwise, + FuncAstExpressionMulBitwise, + FuncAstExpressionUnary, + FuncAstExpressionMethod, + FuncAstExpressionVarDecl, + FuncAstExpressionFunCall, + FuncAstExpressionTensor, + FuncAstExpressionTuple, + FuncAstIntegerLiteral, + FuncAstStringLiteral, + FuncAstType, + FuncAstTypePrimitive, + FuncAstTypeMapped, +} from "./grammar"; +import { throwUnsupportedNodeError } from "./syntaxUtils"; + +export class FuncPrettyPrinter { + private lineLengthLimit: number; + private indent: number; + private currentIndent: number; + + constructor( + params: Partial<{ indent: number; lineLengthLimit: number }> = {}, + ) { + const { indent = 4, lineLengthLimit = 100 } = params; + this.lineLengthLimit = lineLengthLimit; + this.indent = indent; + this.currentIndent = 0; + } + + public prettyPrint(node: FuncAstNode): string { + switch (node.kind) { + case "module": + return this.prettyPrintModule(node as FuncAstModule); + case "pragma_literal": + return this.prettyPrintPragmaLiteral( + node as FuncAstPragmaLiteral, + ); + case "pragma_version_range": + return this.prettyPrintPragmaVersionRange( + node as FuncAstPragmaVersionRange, + ); + case "pragma_version_string": + return this.prettyPrintPragmaVersionString( + node as FuncAstPragmaVersionString, + ); + case "include": + return this.prettyPrintInclude(node as FuncAstInclude); + case "global_variables_declaration": + return this.prettyPrintGlobalVariablesDeclaration( + node as FuncAstGlobalVariablesDeclaration, + ); + case "constants_definition": + return this.prettyPrintConstantsDefinition( + node as FuncAstConstantsDefinition, + ); + case "asm_function_definition": + return this.prettyPrintAsmFunctionDefinition( + node as FuncAstAsmFunctionDefinition, + ); + case "function_declaration": + return this.prettyPrintFunctionDeclaration( + node as FuncAstFunctionDeclaration, + ); + case "function_definition": + return this.prettyPrintFunctionDefinition( + node as FuncAstFunctionDefinition, + ); + case "statement_return": + return this.prettyPrintStatementReturn( + node as FuncAstStatementReturn, + ); + case "statement_block": + return this.prettyPrintStatementBlock( + node as FuncAstStatementBlock, + ); + case "statement_empty": + return ";"; + case "statement_condition_if": + return this.prettyPrintStatementConditionIf( + node as FuncAstStatementConditionIf, + ); + case "statement_condition_elseif": + return this.prettyPrintStatementConditionElseIf( + node as FuncAstStatementConditionElseIf, + ); + case "statement_repeat": + return this.prettyPrintStatementRepeat( + node as FuncAstStatementRepeat, + ); + case "statement_until": + return this.prettyPrintStatementUntil( + node as FuncAstStatementUntil, + ); + case "statement_while": + return this.prettyPrintStatementWhile( + node as FuncAstStatementWhile, + ); + case "statement_try_catch": + return this.prettyPrintStatementTryCatch( + node as FuncAstStatementTryCatch, + ); + case "statement_expression": + return this.prettyPrintStatementExpression( + node as FuncAstStatementExpression, + ); + case "expression_assign": + return this.prettyPrintExpressionAssign( + node as FuncAstExpressionAssign, + ); + case "expression_conditional": + return this.prettyPrintExpressionConditional( + node as FuncAstExpressionConditional, + ); + case "expression_compare": + return this.prettyPrintExpressionCompare( + node as FuncAstExpressionCompare, + ); + case "expression_bitwise_shift": + return this.prettyPrintExpressionBitwiseShift( + node as FuncAstExpressionBitwiseShift, + ); + case "expression_add_bitwise": + return this.prettyPrintExpressionAddBitwise( + node as FuncAstExpressionAddBitwise, + ); + case "expression_mul_bitwise": + return this.prettyPrintExpressionMulBitwise( + node as FuncAstExpressionMulBitwise, + ); + case "expression_unary": + return this.prettyPrintExpressionUnary( + node as FuncAstExpressionUnary, + ); + case "expression_method": + return this.prettyPrintExpressionMethod( + node as FuncAstExpressionMethod, + ); + case "expression_var_decl": + return this.prettyPrintExpressionVarDecl( + node as FuncAstExpressionVarDecl, + ); + case "expression_fun_call": + return this.prettyPrintExpressionFunCall( + node as FuncAstExpressionFunCall, + ); + case "expression_tensor": + return this.prettyPrintExpressionTensor( + node as FuncAstExpressionTensor, + ); + case "expression_tuple": + return this.prettyPrintExpressionTuple( + node as FuncAstExpressionTuple, + ); + case "integer_literal": + return this.prettyPrintIntegerLiteral( + node as FuncAstIntegerLiteral, + ); + case "string_singleline": + case "string_multiline": + return this.prettyPrintStringLiteral( + node as FuncAstStringLiteral, + ); + case "comment_singleline": + case "comment_multiline": + return this.prettyPrintComment(node as FuncAstComment); + case "cr": + return this.prettyPrintCR(node as FuncAstCR); + case "method_id": + return this.prettyPrintMethodId(node as FuncAstMethodId); + case "quoted_id": + return this.prettyPrintQuotedId(node as FuncAstQuotedId); + case "operator_id": + return this.prettyPrintOperatorId(node as FuncAstOperatorId); + case "plain_id": + return this.prettyPrintPlainId(node as FuncAstPlainId); + case "unused_id": + return this.prettyPrintUnusedId(node as FuncAstUnusedId); + default: + throwUnsupportedNodeError(node); + } + } + + private prettyPrintModule(node: FuncAstModule): string { + return node.items + .map((item, index) => { + const previousItem = node.items[index - 1]; + const isSequentialPragmaOrInclude = + previousItem && + previousItem.kind === item.kind && + (item.kind === "include" || + item.kind === "pragma_literal" || + item.kind === "pragma_version_range" || + item.kind === "pragma_version_string"); + const separator = isSequentialPragmaOrInclude ? "\n" : "\n\n"; + return (index > 0 ? separator : "") + this.prettyPrint(item); + }) + .join(""); + } + + private prettyPrintPragmaLiteral(node: FuncAstPragmaLiteral): string { + return `#pragma ${node.literal};`; + } + + private prettyPrintPragmaVersionRange( + node: FuncAstPragmaVersionRange, + ): string { + const allow = node.allow ? "allow" : "not-allow"; + return `#pragma ${allow} ${this.prettyPrintVersionRange(node.range)};`; + } + + private prettyPrintVersionRange(node: FuncAstVersionRange): string { + const op = node.op ? `${node.op} ` : ""; + const major = node.major.toString(); + const minor = node.minor !== undefined ? `.${node.minor}` : ""; + const patch = node.patch !== undefined ? `.${node.patch}` : ""; + return `${op}${major}${minor}${patch}`; + } + + private prettyPrintPragmaVersionString( + node: FuncAstPragmaVersionString, + ): string { + return `#pragma test-version-set "${node.version.value}";`; + } + + private prettyPrintInclude(node: FuncAstInclude): string { + return `#include "${node.path.value}";`; + } + + private prettyPrintGlobalVariablesDeclaration( + node: FuncAstGlobalVariablesDeclaration, + ): string { + const globals = node.globals + .map((g) => this.prettyPrintGlobalVariable(g)) + .join(", "); + return `global ${globals};`; + } + + private prettyPrintGlobalVariable(node: FuncAstGlobalVariable): string { + const typeStr = node.ty ? node.ty : "var"; + const nameStr = this.prettyPrint(node.name); + return `${typeStr} ${nameStr};`; + } + + private prettyPrintConstantsDefinition( + node: FuncAstConstantsDefinition, + ): string { + const constants = node.constants + .map((c) => this.prettyPrintConstant(c)) + .join(", "); + return `const ${constants};`; + } + + private prettyPrintConstant(node: FuncAstConstant): string { + const typeStr = node.ty ? node.ty : "var"; + const nameStr = this.prettyPrint(node.name); + const valueStr = this.prettyPrint(node.value); + return `${typeStr} ${nameStr} = ${valueStr};`; + } + + private prettyPrintAsmFunctionDefinition( + node: FuncAstAsmFunctionDefinition, + ): string { + const signature = this.prettyPrintFunctionSignature( + node.returnTy, + node.name, + node.parameters, + node.attributes, + ); + const asmBody = node.asmStrings + .map(this.prettyPrint.bind(this)) + .join("\n"); + return `${signature} asm ${asmBody};`; + } + + private prettyPrintFunctionDeclaration( + node: FuncAstFunctionDeclaration, + ): string { + const signature = this.prettyPrintFunctionSignature( + node.returnTy, + node.name, + node.parameters, + node.attributes, + ); + return `${signature};`; + } + + private prettyPrintFunctionDefinition( + node: FuncAstFunctionDefinition, + ): string { + const signature = this.prettyPrintFunctionSignature( + node.returnTy, + node.name, + node.parameters, + node.attributes, + ); + const body = this.prettyPrintIndentedBlock( + node.statements.map(this.prettyPrint.bind(this)).join("\n"), + ); + return `${signature} {\n${body}\n}`; + } + + private prettyPrintFunctionSignature( + returnType: FuncAstType, + name: FuncAstId, + parameters: FuncAstParameter[], + attributes: FuncAstFunctionAttribute[], + ): string { + const returnTypeStr = this.ppTy(returnType); + const nameStr = this.prettyPrint(name); + const paramsStr = parameters + .map((param) => this.prettyPrintParameter(param)) + .join(", "); + const attrsStr = + attributes.length > 0 + ? ` ${attributes.map((attr) => this.prettyPrintFunctionAttribute(attr)).join(" ")}` + : ""; + return `${returnTypeStr} ${nameStr}(${paramsStr})${attrsStr}`; + } + + private prettyPrintParameter(param: FuncAstParameter): string { + const typeStr = param.ty ? this.ppTy(param.ty) : "var"; + const nameStr = param.name ? this.prettyPrint(param.name) : ""; + return `${typeStr} ${nameStr}`.trim(); + } + + private prettyPrintFunctionAttribute( + attr: FuncAstFunctionAttribute, + ): string { + switch (attr.kind) { + case "impure": + case "inline": + case "inline_ref": + return attr.kind; + case "method_id": + return attr.value + ? `method_id(${this.prettyPrint(attr.value)})` + : "method_id"; + default: + throwUnsupportedNodeError(attr); + } + } + + private prettyPrintStatementReturn(node: FuncAstStatementReturn): string { + const value = node.expression + ? ` ${this.prettyPrint(node.expression)}` + : ""; + return `return${value};`; + } + + private prettyPrintStatementBlock(node: FuncAstStatementBlock): string { + const body = this.prettyPrintIndentedBlock( + node.statements.map(this.prettyPrint.bind(this)).join("\n"), + ); + return `{\n${body}\n}`; + } + + private prettyPrintStatementConditionIf( + node: FuncAstStatementConditionIf, + ): string { + const condition = this.prettyPrint(node.condition); + const ifnot = node.positive ? "if" : "ifnot"; + const bodyBlock = this.prettyPrintIndentedBlock( + node.consequences.map(this.prettyPrint.bind(this)).join("\n"), + ); + const elseBlock = node.alternatives + ? ` else {\n${this.prettyPrintIndentedBlock(node.alternatives.map(this.prettyPrint.bind(this)).join("\n"))}\n}` + : ""; + return `${ifnot} (${condition}) {\n${bodyBlock}\n}${elseBlock}`; + } + + private prettyPrintStatementConditionElseIf( + node: FuncAstStatementConditionElseIf, + ): string { + const conditionIf = this.prettyPrint(node.conditionIf); + const conditionElseif = this.prettyPrint(node.conditionElseif); + const ifnotIf = node.positiveIf ? "if" : "ifnot"; + const ifnotElseif = node.positiveElseif ? "elseif" : "elseifnot"; + const bodyBlockIf = this.prettyPrintIndentedBlock( + node.consequencesIf.map(this.prettyPrint.bind(this)).join("\n"), + ); + const bodyBlockElseif = this.prettyPrintIndentedBlock( + node.consequencesElseif.map(this.prettyPrint.bind(this)).join("\n"), + ); + const elseBlock = node.alternativesElseif + ? ` else {\n${this.prettyPrintIndentedBlock(node.alternativesElseif.map(this.prettyPrint.bind(this)).join("\n"))}\n}` + : ""; + return `${ifnotIf} (${conditionIf}) {\n${bodyBlockIf}\n} ${ifnotElseif} (${conditionElseif}) {\n${bodyBlockElseif}\n}${elseBlock}`; + } + + private prettyPrintStatementRepeat(node: FuncAstStatementRepeat): string { + const condition = this.prettyPrint(node.iterations); + const body = this.prettyPrintIndentedBlock( + node.statements.map(this.prettyPrint.bind(this)).join("\n"), + ); + return `repeat ${condition} {\n${body}\n}`; + } + + private prettyPrintStatementUntil(node: FuncAstStatementUntil): string { + const condition = this.prettyPrint(node.condition); + const body = this.prettyPrintIndentedBlock( + node.statements.map(this.prettyPrint.bind(this)).join("\n"), + ); + return `do {\n${body}\n} until ${condition};`; + } + + private prettyPrintStatementWhile(node: FuncAstStatementWhile): string { + const condition = this.prettyPrint(node.condition); + const body = this.prettyPrintIndentedBlock( + node.statements.map(this.prettyPrint.bind(this)).join("\n"), + ); + return `while ${condition} {\n${body}\n}`; + } + + private prettyPrintStatementTryCatch( + node: FuncAstStatementTryCatch, + ): string { + const tryBlock = this.prettyPrintIndentedBlock( + node.statementsTry.map(this.prettyPrint.bind(this)).join("\n"), + ); + const catchBlock = this.prettyPrintIndentedBlock( + node.statementsCatch.map(this.prettyPrint.bind(this)).join("\n"), + ); + const catchVar = `${this.prettyPrint(node.catchExceptionName)}, ${this.prettyPrint(node.catchExitCodeName)}`; + return `try {\n${tryBlock}\n} catch (${catchVar}) {\n${catchBlock}\n}`; + } + + private prettyPrintStatementExpression( + node: FuncAstStatementExpression, + ): string { + return `${this.prettyPrint(node.expression)};`; + } + + private prettyPrintExpressionAssign(node: FuncAstExpressionAssign): string { + const left = this.prettyPrint(node.left); + const right = this.prettyPrint(node.right); + return `${left} ${node.op} ${right}`; + } + + private prettyPrintExpressionConditional( + node: FuncAstExpressionConditional, + ): string { + const condition = this.prettyPrint(node.condition); + const consequence = this.prettyPrint(node.consequence); + const alternative = this.prettyPrint(node.alternative); + return `${condition} ? ${consequence} : ${alternative}`; + } + + private prettyPrintExpressionCompare( + node: FuncAstExpressionCompare, + ): string { + const left = this.prettyPrint(node.left); + const right = this.prettyPrint(node.right); + return `${left} ${node.op} ${right}`; + } + + private prettyPrintExpressionBitwiseShift( + node: FuncAstExpressionBitwiseShift, + ): string { + const left = this.prettyPrint(node.left); + const ops = node.ops + .map((op) => `${op.op} ${this.prettyPrint(op.expr)}`) + .join(" "); + return `${left} ${ops}`; + } + + private prettyPrintExpressionAddBitwise( + node: FuncAstExpressionAddBitwise, + ): string { + const left = node.negateLeft + ? `-${this.prettyPrint(node.left)}` + : this.prettyPrint(node.left); + const ops = node.ops + .map((op) => `${op.op} ${this.prettyPrint(op.expr)}`) + .join(" "); + return `${left} ${ops}`; + } + + private prettyPrintExpressionMulBitwise( + node: FuncAstExpressionMulBitwise, + ): string { + const left = this.prettyPrint(node.left); + const ops = node.ops + .map((op) => `${op.op} ${this.prettyPrint(op.expr)}`) + .join(" "); + return `${left} ${ops}`; + } + + private prettyPrintExpressionUnary(node: FuncAstExpressionUnary): string { + const operand = this.prettyPrint(node.operand); + return `${node.op}${operand}`; + } + + private prettyPrintExpressionMethod(node: FuncAstExpressionMethod): string { + const object = this.prettyPrint(node.object); + const calls = node.calls + .map( + (call) => + `.${this.prettyPrint(call.name)}(${this.prettyPrint(call.argument)})`, + ) + .join(""); + return `${object}${calls}`; + } + + private prettyPrintExpressionVarDecl( + node: FuncAstExpressionVarDecl, + ): string { + const type = this.ppTy(node.ty); + const names = this.prettyPrintVarDeclPart(node.names); + return `${type} ${names}`; + } + + private prettyPrintVarDeclPart(node: FuncVarDeclPart): string { + switch (node.kind) { + case "plain_id": + case "quoted_id": + case "method_id": + case "operator_id": + case "unused_id": + return this.prettyPrint(node as FuncAstId); + case "expression_tensor_var_decl": { + const names = node.names + .map((name) => this.prettyPrint(name)) + .join(", "); + return `(${names})`; + } + case "expression_tuple_var_decl": { + const names = node.names + .map((name) => this.prettyPrint(name)) + .join(", "); + return `[${names}]`; + } + default: + throwUnsupportedNodeError(node); + } + } + + private prettyPrintExpressionFunCall( + node: FuncAstExpressionFunCall, + ): string { + const object = this.prettyPrint(node.object); + const args = node.arguments + .map((arg) => this.prettyPrint(arg)) + .join(", "); + return `${object}(${args})`; + } + + private prettyPrintExpressionTensor(node: FuncAstExpressionTensor): string { + const expressions = node.expressions + .map((expr) => this.prettyPrint(expr)) + .join(", "); + return `(${expressions})`; + } + + private prettyPrintExpressionTuple(node: FuncAstExpressionTuple): string { + const expressions = node.expressions + .map((expr) => this.prettyPrint(expr)) + .join(", "); + return `[${expressions}]`; + } + + private prettyPrintIntegerLiteral(node: FuncAstIntegerLiteral): string { + return node.isHex + ? `0x${node.value.toString(16)}` + : node.value.toString(); + } + + private prettyPrintStringLiteral(node: FuncAstStringLiteral): string { + const type = node.ty ? node.ty : ""; + const value = + node.kind === "string_singleline" + ? `"${node.value}"` + : `"""${node.value}"""`; + return `${value}${type}`; + } + + private prettyPrintTypePrimitive(node: FuncAstTypePrimitive): string { + return node.value; + } + + private prettyPrintComment(node: FuncAstComment): string { + if (node.kind === "comment_singleline") { + return `;; ${node.line}`; + } else { + const lines = node.lines.join("\n;; "); + return node.style === "{-" ? `{- ${lines} -}` : `;; ${lines}`; + } + } + + private prettyPrintCR(node: FuncAstCR): string { + return "\n".repeat(node.lines); + } + + private prettyPrintIndentedBlock(content: string): string { + this.currentIndent += this.indent; + const indentedContent = content + .split("\n") + .map((line) => " ".repeat(this.currentIndent) + line) + .join("\n"); + this.currentIndent -= this.indent; + return indentedContent; + } + + private ppTy(ty: FuncAstType): string { + switch (ty.kind) { + case "type_primitive": + return this.prettyPrintTypePrimitive( + ty as FuncAstTypePrimitive, + ); + case "type_tensor": + return this.prettyPrintTypeTensor(ty as FuncAstTypeTensor); + case "type_tuple": + return this.prettyPrintTypeTuple(ty as FuncAstTypeTuple); + case "hole": + return this.prettyPrintTypeHole(ty as FuncAstHole); + case "unit": + return "()"; + case "type_mapped": + return this.prettyPrintTypeMapped(ty as FuncAstTypeMapped); + default: + throwUnsupportedNodeError(ty); + } + } + + private prettyPrintTypeTensor(node: FuncAstTypeTensor): string { + return `(${node.types.map((type) => this.ppTy(type)).join(", ")})`; + } + + private prettyPrintTypeTuple(node: FuncAstTypeTuple): string { + return `[${node.types.map((type) => this.ppTy(type)).join(", ")}]`; + } + + private prettyPrintTypeHole(node: FuncAstHole): string { + return node.value; + } + + private prettyPrintTypeMapped(node: FuncAstTypeMapped): string { + const value = this.ppTy(node.value); + const mapsTo = this.ppTy(node.mapsTo); + return `${value} -> ${mapsTo}`; + } + + private prettyPrintMethodId(node: FuncAstMethodId): string { + return `${node.prefix}${node.value}`; + } + + private prettyPrintQuotedId(node: FuncAstQuotedId): string { + return `\`${node.value}\``; + } + + private prettyPrintOperatorId(node: FuncAstOperatorId): string { + return node.value; + } + + private prettyPrintPlainId(node: FuncAstPlainId): string { + return node.value; + } + + private prettyPrintUnusedId(node: FuncAstUnusedId): string { + return node.value; + } +} diff --git a/src/func/syntaxUtils.ts b/src/func/syntaxUtils.ts index ff70410bd..d8247f2b7 100644 --- a/src/func/syntaxUtils.ts +++ b/src/func/syntaxUtils.ts @@ -1,3 +1,7 @@ +import JSONbig from "json-bigint"; +import { throwInternalCompilerError } from "../errors"; +import { dummySrcInfo as tactDummySrcInfo } from "../grammar/grammar"; + /** * Provides deep copy that works for AST nodes. */ @@ -16,3 +20,11 @@ export function deepCopy(obj: T): T { } return copy; } + +// TODO(jubnzv): Refactor and move to errors.ts when merging with `main` +export function throwUnsupportedNodeError(node: any): never { + throwInternalCompilerError( + `Unsupported node: ${JSONbig.stringify(node, null, 2)}`, + tactDummySrcInfo, + ); +} From d036d3e196caf302aa466f50c270e626a1416231 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 29 Aug 2024 14:07:34 +0000 Subject: [PATCH 119/162] feat: Finalize new AST translation --- src/codegen/generator.ts | 14 +++++++------- src/func/grammar.ts | 31 ++++++++++++++++++------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts index 75ffd51fb..78da78bc7 100644 --- a/src/codegen/generator.ts +++ b/src/codegen/generator.ts @@ -6,7 +6,7 @@ import { LocationContext, Location, locEquals, locValue } from "."; import { WriterContext, ModuleGen, WrittenFunction } from "."; import { getRawAST } from "../grammar/store"; import { ContractABI } from "@ton/core"; -import { FuncFormatter } from "../func/formatter"; +import { FuncPrettyPrinter } from "../func/prettyPrinter"; import { FuncAstModule, FuncAstFunctionDefinition, @@ -17,7 +17,7 @@ import { comment, mod, pragma, -version, + version, Type, include, global, @@ -123,7 +123,7 @@ export class FuncGenerator { m.items.push(pragma("compute-asm-ltr")); generated.files.push({ name: `${this.basename}.code.fc`, - code: new FuncFormatter().dump(m), + code: new FuncPrettyPrinter().prettyPrint(m), }); // header.push(""); @@ -187,7 +187,7 @@ export class FuncGenerator { }); generated.files.push({ name: `${this.basename}.headers.fc`, - code: new FuncFormatter().dump(m), + code: new FuncPrettyPrinter().prettyPrint(m), }); } @@ -219,7 +219,7 @@ export class FuncGenerator { }); generated.files.push({ name: `${this.basename}.stdlib.fc`, - code: new FuncFormatter().dump(m), + code: new FuncPrettyPrinter().prettyPrint(m), }); } @@ -247,7 +247,7 @@ export class FuncGenerator { generated.imported.push("constants"); generated.files.push({ name: `${this.basename}.constants.fc`, - code: new FuncFormatter().dump( + code: new FuncPrettyPrinter().prettyPrint( mod( ...constantsFunctions.reduce( (acc, v) => { @@ -335,7 +335,7 @@ export class FuncGenerator { generated.files.push({ name: `${this.basename}.storage.fc`, code: generatedModules - .map((m) => new FuncFormatter().dump(m)) + .map((m) => new FuncPrettyPrinter().prettyPrint(m)) .join("\n\n"), }); } diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 15cf0eda6..cd58a80ba 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -118,6 +118,7 @@ export function throwFuncParseError( /** * Throws a FunC syntax error occurred with the given `source` */ +// TODO(jubnzv): Move to `errors.ts` for consistency export function throwFuncSyntaxError( message: string, source: FuncSrcInfo, @@ -1034,15 +1035,15 @@ export type FuncBitwiseExpressionPart = { }; export const funcOpMulBitwise = [ - "*", - "/%", - "/", - "%", - "~/", - "~%", - "^/", - "^%", - "&" + "*", + "/%", + "/", + "%", + "~/", + "~%", + "^/", + "^%", + "&", ] as const; export type FuncOpMulBitwise = (typeof funcOpMulBitwise)[number]; @@ -1184,7 +1185,11 @@ export type FuncAstBinaryExpression = | FuncAstExpressionAddBitwise | FuncAstExpressionMulBitwise; -export type FuncBinaryOp = FuncOpCompare | FuncOpBitwiseShift | FuncOpAddBitwise | FuncOpMulBitwise +export type FuncBinaryOp = + | FuncOpCompare + | FuncOpBitwiseShift + | FuncOpAddBitwise + | FuncOpMulBitwise; /** * op Expression @@ -1440,8 +1445,8 @@ export type FuncAstCommentMultiLine = { }; export type FuncAstCR = { - kind: "cr", - lines: number, + kind: "cr"; + lines: number; }; // @@ -1921,7 +1926,7 @@ semantics.addOperation("astOfExpression", { object: exprLeft.astOfExpression(), calls: zipped, loc: createSrcInfo(this), - }; + } as FuncAstExpression; }, // parse_expr90, and some inner things From 6d3999a3d282539a676076b2e10884ae28991f33 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 4 Sep 2024 01:13:51 +0000 Subject: [PATCH 120/162] fix(syntaxConstructors): Allow empty `method_id` --- src/func/syntaxConstructors.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index abeff7602..b04f84651 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -124,9 +124,11 @@ export class FunAttr { value?: bigint | number | string, ): FuncAstFunctionAttribute { const literal = - typeof value === "string" - ? string(value) - : int(value as bigint | number); + value === undefined + ? undefined + : typeof value === "string" + ? string(value) + : int(value as bigint | number); return { kind: "method_id", value: literal, loc: dummySrcInfo }; } } From 299d3f7c514dd183bdb923b5fe214e0bf91973c9 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 4 Sep 2024 01:15:10 +0000 Subject: [PATCH 121/162] fix(pp): Support `unit` --- src/func/prettyPrinter.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index ccb9b3d65..05107d60f 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -218,6 +218,8 @@ export class FuncPrettyPrinter { return this.prettyPrintPlainId(node as FuncAstPlainId); case "unused_id": return this.prettyPrintUnusedId(node as FuncAstUnusedId); + case "unit": + return "()"; default: throwUnsupportedNodeError(node); } From 4127b024a7f4ae516a5b0f291a7383aa2d6eb3bd Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 4 Sep 2024 10:59:58 +0000 Subject: [PATCH 122/162] fix(package.json): Include func grammar bundle to dist --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b208d0414..a59ab7927 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "gen:compiler": "ts-node ./scripts/prepare.ts", "gen": "yarn gen:grammar && yarn gen:pack && yarn gen:compiler", "clean": "rm -fr dist", - "build": "tsc && cp ./src/grammar/grammar.ohm* ./dist/grammar/ && cp ./src/func/funcfiftlib.* ./dist/func", + "build": "tsc && cp ./src/grammar/grammar.ohm* ./dist/grammar/ && cp ./src/func/grammar.ohm* ./dist/func/ && cp ./src/func/funcfiftlib.* ./dist/func", "test": "jest", "test:func": "yarn gen:grammar && jest -t 'FunC grammar and parser'", "coverage": "cross-env COVERAGE=true jest", From 9f54da18b67c01414ad3c8d1c8a933aef957f23a Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 4 Sep 2024 13:15:51 +0000 Subject: [PATCH 123/162] fix(pp): Global types --- src/func/prettyPrinter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index 05107d60f..e098c0965 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -281,7 +281,7 @@ export class FuncPrettyPrinter { } private prettyPrintGlobalVariable(node: FuncAstGlobalVariable): string { - const typeStr = node.ty ? node.ty : "var"; + const typeStr = node.ty ? this.ppTy(node.ty) : "var"; const nameStr = this.prettyPrint(node.name); return `${typeStr} ${nameStr};`; } From ea7928f93b0395dbe26f43b6422eea5c7e0c63ad Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 5 Sep 2024 14:12:31 +0000 Subject: [PATCH 124/162] feat(codegen): Add stdlib --- src/codegen/module.ts | 4 +- src/codegen/stdlib.ts | 1341 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1343 insertions(+), 2 deletions(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index da511c9fb..089f17986 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -131,7 +131,7 @@ export class ModuleGen { /** * Adds stdlib definitions to the generated module. */ - private writeStdlib(m: FuncAstModule): void { + private writeStdlib(): void { writeStdlib(this.ctx); } @@ -1462,7 +1462,7 @@ export class ModuleGen { throw Error(`Contract "${this.contractName}" not found`); } - this.writeStdlib(m); + this.writeStdlib(); this.addSerializers(m); this.addAccessors(m); this.addInitSerializer(m); diff --git a/src/codegen/stdlib.ts b/src/codegen/stdlib.ts index 15910435f..eed58143d 100644 --- a/src/codegen/stdlib.ts +++ b/src/codegen/stdlib.ts @@ -1,4 +1,1345 @@ import { WriterContext, Location } from "./context"; +import { contractErrors } from "../abi/errors"; +import { enabledMasterchain } from "../config/features"; export function writeStdlib(ctx: WriterContext) { + // + // stdlib extension functions + // + // + ctx.skip("__tact_set"); + ctx.skip("__tact_nop"); + ctx.skip("__tact_str_to_slice"); + ctx.skip("__tact_slice_to_str"); + ctx.skip("__tact_address_to_slice"); + + // + // Addresses + // + + ctx.parse( + `slice __tact_verify_address(slice address) inline { + throw_unless(${contractErrors.invalidAddress.id}, address.slice_bits() == 267); + var h = address.preload_uint(11); + + ${ + enabledMasterchain(ctx.ctx) + ? ` + throw_unless(${contractErrors.invalidAddress.id}, (h == 1024) | (h == 1279)); + ` + : ` + throw_if(${contractErrors.masterchainNotEnabled.id}, h == 1279); + throw_unless(${contractErrors.invalidAddress.id}, h == 1024); + ` + } + + return address; + }`, + { context: Location.stdlib() }, + ); + + ctx.parse(`(slice, int) __tact_load_bool(slice s) asm(s -> 1 0) "1 LDI";`, { + context: Location.stdlib(), + }); + + ctx.parse( + `(slice, slice) __tact_load_address(slice cs) inline { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, slice) __tact_load_address_opt(slice cs) inline { + if (cs.preload_uint(2) != 0) { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); + } else { + cs~skip_bits(2); + return (cs, null()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `builder __tact_store_address(builder b, slice address) inline { + return b.store_slice(__tact_verify_address(address)); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `builder __tact_store_address_opt(builder b, slice address) inline { + if (null?(address)) { + b = b.store_uint(0, 2); + return b; + } else { + return __tact_store_address(b, address); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `slice __tact_create_address(int chain, int hash) inline { + var b = begin_cell(); + b = b.store_uint(2, 2); + b = b.store_uint(0, 1); + b = b.store_int(chain, 8); + b = b.store_uint(hash, 256); + var addr = b.end_cell().begin_parse(); + return __tact_verify_address(addr); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `slice __tact_compute_contract_address(int chain, cell code, cell data) inline { + var b = begin_cell(); + b = b.store_uint(0, 2); + b = b.store_uint(3, 2); + b = b.store_uint(0, 1); + b = b.store_ref(code); + b = b.store_ref(data); + var hash = cell_hash(b.end_cell()); + return __tact_create_address(chain, hash); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_my_balance() inline { + return pair_first(get_balance()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `forall X -> X __tact_not_null(X x) inline { + throw_if(${contractErrors.null.id}, null?(x)); + return x; + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(cell, int) __tact_dict_delete(cell dict, int key_len, slice index) asm(index dict key_len) "DICTDEL";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value) asm(value index dict key_len) "DICTSETREF";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, int) __tact_dict_get(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGET" "NULLSWAPIFNOT";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(cell, int) __tact_dict_get_ref(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGETREF" "NULLSWAPIFNOT";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, slice, int) __tact_dict_min(cell dict, int key_len) asm(dict key_len -> 1 0 2) "DICTMIN" "NULLSWAPIFNOT2";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, cell, int) __tact_dict_min_ref(cell dict, int key_len) asm(dict key_len -> 1 0 2) "DICTMINREF" "NULLSWAPIFNOT2";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, slice, int) __tact_dict_next(cell dict, int key_len, slice pivot) asm(pivot dict key_len -> 1 0 2) "DICTGETNEXT" "NULLSWAPIFNOT2";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, cell, int) __tact_dict_next_ref(cell dict, int key_len, slice pivot) inline { + var (key, value, flag) = __tact_dict_next(dict, key_len, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `forall X -> () __tact_debug(X value, slice debug_print) impure asm "STRDUMP" "DROP" "s0 DUMP" "DROP";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `() __tact_debug_str(slice value, slice debug_print) impure asm "STRDUMP" "DROP" "STRDUMP" "DROP";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `() __tact_debug_bool(int value, slice debug_print) impure { + if (value) { + __tact_debug_str("true", debug_print); + } else { + __tact_debug_str("false", debug_print); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice) __tact_preload_offset(slice s, int offset, int bits) inline asm "SDSUBSTR";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice) __tact_crc16(slice data) inline_ref { + slice new_data = begin_cell() + .store_slice(data) + .store_slice("0000"s) + .end_cell().begin_parse(); + int reg = 0; + while (~new_data.slice_data_empty?()) { + int byte = new_data~load_uint(8); + int mask = 0x80; + while (mask > 0) { + reg <<= 1; + if (byte & mask) { + reg += 1; + } + mask >>= 1; + if (reg > 0xffff) { + reg &= 0xffff; + reg ^= 0x1021; + } + } + } + (int q, int r) = divmod(reg, 256); + return begin_cell() + .store_uint(q, 8) + .store_uint(r, 8) + .end_cell().begin_parse(); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice) __tact_base64_encode(slice data) inline { + slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; + builder res = begin_cell(); + + while (data.slice_bits() >= 24) { + (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); + + int n = (bs1 << 16) | (bs2 << 8) | bs3; + + res = res + .store_slice(__tact_preload_offset(chars, ((n >> 18) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 12) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 6) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n ) & 63) * 8, 8)); + } + + return res.end_cell().begin_parse(); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice) __tact_address_to_user_friendly(slice address) inline { + (int wc, int hash) = address.parse_std_addr(); + + slice user_friendly_address = begin_cell() + .store_slice("11"s) + .store_uint((wc + 0x100) % 0x100, 8) + .store_uint(hash, 256) + .end_cell().begin_parse(); + + slice checksum = __tact_crc16(user_friendly_address); + slice user_friendly_address_with_checksum = begin_cell() + .store_slice(user_friendly_address) + .store_slice(checksum) + .end_cell().begin_parse(); + + return __tact_base64_encode(user_friendly_address_with_checksum); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `() __tact_debug_address(slice address, slice debug_print) impure { + __tact_debug_str(__tact_address_to_user_friendly(address), debug_print); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `() __tact_debug_stack(slice debug_print) impure asm "STRDUMP" "DROP" "DUMPSTK";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, slice, int, slice) __tact_context_get() inline { + return __tact_context; + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `slice __tact_context_get_sender() inline { + return __tact_context_sender; + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `() __tact_prepare_random() impure inline { + if (null?(__tact_randomized)) { + randomize_lt(); + __tact_randomized = true; + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `builder __tact_store_bool(builder b, int v) inline { + return b.store_int(v, 1); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse(`forall X -> tuple __tact_to_tuple(X x) asm "NOP";`, { + context: Location.stdlib(), + }); + + ctx.parse(`forall X -> X __tact_from_tuple(tuple x) asm "NOP";`, { + context: Location.stdlib(), + }); + + // + // Dict Int -> Int + // + + ctx.parse( + `(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_dict_get_int_int(cell d, int kl, int k, int vl) inline { + var (r, ok) = idict_get?(d, kl, k); + if (ok) { + return r~load_int(vl); + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl) inline { + var (key, value, flag) = idict_get_min?(d, kl); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl) inline { + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Int -> Uint + // + + ctx.parse( + `(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_dict_get_uint_int(cell d, int kl, int k, int vl) inline { + var (r, ok) = udict_get?(d, kl, k); + if (ok) { + return r~load_int(vl); + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl) inline { + var (key, value, flag) = udict_get_min?(d, kl); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl) inline { + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Uint -> Uint + // + + ctx.parse( + `(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl) inline { + var (r, ok) = udict_get?(d, kl, k); + if (ok) { + return r~load_uint(vl); + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl) inline { + var (key, value, flag) = udict_get_min?(d, kl); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl) inline { + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Int -> Cell + // + + ctx.parse( + `(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v) inline { + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set_ref(d, kl, k, v), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `cell __tact_dict_get_int_cell(cell d, int kl, int k) inline { + var (r, ok) = idict_get_ref?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, cell, int) __tact_dict_min_int_cell(cell d, int kl) inline { + var (key, value, flag) = idict_get_min_ref?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot) inline { + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Uint -> Cell + // + + ctx.parse( + `(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v) inline { + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set_ref(d, kl, k, v), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `cell __tact_dict_get_uint_cell(cell d, int kl, int k) inline { + var (r, ok) = udict_get_ref?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl) inline { + var (key, value, flag) = udict_get_min_ref?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot) inline { + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Int -> Slice + // + + ctx.parse( + `(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v) inline { + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set(d, kl, k, v), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `slice __tact_dict_get_int_slice(cell d, int kl, int k) inline { + var (r, ok) = idict_get?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, slice, int) __tact_dict_min_int_slice(cell d, int kl) inline { + var (key, value, flag) = idict_get_min?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot) inline { + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Uint -> Slice + // + + ctx.parse( + `(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v) inline { + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set(d, kl, k, v), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `slice __tact_dict_get_uint_slice(cell d, int kl, int k) inline { + var (r, ok) = udict_get?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl) inline { + var (key, value, flag) = udict_get_min?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot) inline { + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Slice -> Int + // + + ctx.parse( + `(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); + } else { + return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl) inline { + var (r, ok) = __tact_dict_get(d, kl, k); + if (ok) { + return r~load_int(vl); + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl) inline { + var (key, value, flag) = __tact_dict_min(d, kl); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl) inline { + var (key, value, flag) = __tact_dict_next(d, kl, pivot); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Slice -> UInt + // + + ctx.parse( + `(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); + } else { + return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl) inline { + var (r, ok) = __tact_dict_get(d, kl, k); + if (ok) { + return r~load_uint(vl); + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl) inline { + var (key, value, flag) = __tact_dict_min(d, kl); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl) inline { + var (key, value, flag) = __tact_dict_next(d, kl, pivot); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Slice -> Cell + // + + ctx.parse( + `(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v) inline { + if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); + } else { + return __tact_dict_set_ref(d, kl, k, v); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `cell __tact_dict_get_slice_cell(cell d, int kl, slice k) inline { + var (r, ok) = __tact_dict_get_ref(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl) inline { + var (key, value, flag) = __tact_dict_min_ref(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot) inline { + var (key, value, flag) = __tact_dict_next(d, kl, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + // + // Dict Slice -> Slice + // + + ctx.parse( + `(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v) inline { + if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); + } else { + return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `slice __tact_dict_get_slice_slice(cell d, int kl, slice k) inline { + var (r, ok) = __tact_dict_get(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl) inline { + var (key, value, flag) = __tact_dict_min(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot) inline { + return __tact_dict_next(d, kl, pivot); + }`, + { context: Location.stdlib() }, + ); + + // + // Address + // + + ctx.parse( + `int __tact_slice_eq_bits(slice a, slice b) inline { + return equal_slice_bits(a, b); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_slice_eq_bits_nullable_one(slice a, slice b) inline { + return (null?(a)) ? (false) : (equal_slice_bits(a, b)); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_slice_eq_bits_nullable(slice a, slice b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (equal_slice_bits(a, b)) : (false); + }`, + { context: Location.stdlib() }, + ); + + // + // Int Eq + // + + ctx.parse( + `int __tact_int_eq_nullable_one(int a, int b) inline { + return (null?(a)) ? (false) : (a == b); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_int_neq_nullable_one(int a, int b) inline { + return (null?(a)) ? (true) : (a != b); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_int_eq_nullable(int a, int b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a == b) : (false); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_int_neq_nullable(int a, int b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a != b) : (true); + }`, + { context: Location.stdlib() }, + ); + + // + // Cell Eq + // + + ctx.parse( + `int __tact_cell_eq(cell a, cell b) inline { + return (a.cell_hash() == b.cell_hash()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_cell_neq(cell a, cell b) inline { + return (a.cell_hash() != b.cell_hash()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_cell_eq_nullable_one(cell a, cell b) inline { + return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_cell_neq_nullable_one(cell a, cell b) inline { + return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_cell_eq_nullable(cell a, cell b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a.cell_hash() == b.cell_hash()) : (false); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_cell_neq_nullable(cell a, cell b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a.cell_hash() != b.cell_hash()) : (true); + }`, + { context: Location.stdlib() }, + ); + + // + // Slice Eq + // + + ctx.parse( + `int __tact_slice_eq(slice a, slice b) inline { + return (a.slice_hash() == b.slice_hash()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_slice_neq(slice a, slice b) inline { + return (a.slice_hash() != b.slice_hash()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_slice_eq_nullable_one(slice a, slice b) inline { + return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_slice_neq_nullable_one(slice a, slice b) inline { + return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_slice_eq_nullable(slice a, slice b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a.slice_hash() == b.slice_hash()) : (false); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_slice_neq_nullable(slice a, slice b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a.slice_hash() != b.slice_hash()) : (true); + }`, + { context: Location.stdlib() }, + ); + + // + // Sys Dict + // + + ctx.parse( + `cell __tact_dict_set_code(cell dict, int id, cell code) inline { + return udict_set_ref(dict, 16, id, code); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `cell __tact_dict_get_code(cell dict, int id) inline { + var (data, ok) = udict_get_ref?(dict, 16, id); + throw_unless(${contractErrors.codeNotFound.id}, ok); + return data; + }`, + { context: Location.stdlib() }, + ); + + // + // Tuples + // + + ctx.parse(`tuple __tact_tuple_create_0() asm "NIL";`, { + context: Location.stdlib(), + }); + + ctx.parse( + `() __tact_tuple_destroy_0() inline { + return (); + }`, + { context: Location.stdlib() }, + ); + + for (let i = 1; i < 64; i++) { + const args: string[] = []; + for (let j = 0; j < i; j++) { + args.push(`X${j}`); + } + + ctx.parse( + `forall ${args.join(", ")} -> tuple __tact_tuple_create_${i}((${args.join(", ")}) v) asm "${i} TUPLE";`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `forall ${args.join(", ")} -> (${args.join(", ")}) __tact_tuple_destroy_${i}(tuple v) asm "${i} UNTUPLE";`, + { context: Location.stdlib() }, + ); + } + + // + // Strings + // + + ctx.parse( + `tuple __tact_string_builder_start_comment() inline { + return __tact_string_builder_start(begin_cell().store_uint(0, 32)); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `tuple __tact_string_builder_start_tail_string() inline { + return __tact_string_builder_start(begin_cell().store_uint(0, 8)); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `tuple __tact_string_builder_start_string() inline { + return __tact_string_builder_start(begin_cell()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `tuple __tact_string_builder_start(builder b) inline { + return tpush(tpush(empty_tuple(), b), null()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `cell __tact_string_builder_end(tuple builders) inline { + (builder b, tuple tail) = uncons(builders); + cell c = b.end_cell(); + while (~null?(tail)) { + (b, tail) = uncons(tail); + c = b.store_ref(c).end_cell(); + } + return c; + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `slice __tact_string_builder_end_slice(tuple builders) inline { + return __tact_string_builder_end(builders).begin_parse(); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `((tuple), ()) __tact_string_builder_append(tuple builders, slice sc) { + int sliceRefs = slice_refs(sc); + int sliceBits = slice_bits(sc); + + while ((sliceBits > 0) | (sliceRefs > 0)) { + ;; Load the current builder + (builder b, tuple tail) = uncons(builders); + int remBytes = 127 - (builder_bits(b) / 8); + int exBytes = sliceBits / 8; + + ;; Append bits + int amount = min(remBytes, exBytes); + if (amount > 0) { + slice read = sc~load_bits(amount * 8); + b = b.store_slice(read); + } + + ;; Update builders + builders = cons(b, tail); + + ;; Check if we need to add a new cell and continue + if (exBytes - amount > 0) { + var bb = begin_cell(); + builders = cons(bb, builders); + sliceBits = (exBytes - amount) * 8; + } elseif (sliceRefs > 0) { + sc = sc~load_ref().begin_parse(); + sliceRefs = slice_refs(sc); + sliceBits = slice_bits(sc); + } else { + sliceBits = 0; + sliceRefs = 0; + } + } + + return ((builders), ()); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc) { + builders~__tact_string_builder_append(sc); + return builders; + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `slice __tact_int_to_string(int src) { + var b = begin_cell(); + if (src < 0) { + b = b.store_uint(45, 8); + src = -src; + } + + if (src < ${(10n ** 30n).toString(10)}) { + int len = 0; + int value = 0; + int mult = 1; + do { + (src, int res) = src.divmod(10); + value = value + (res + 48) * mult; + mult = mult * 256; + len = len + 1; + } until (src == 0); + + b = b.store_uint(value, len * 8); + } else { + tuple t = empty_tuple(); + int len = 0; + do { + int digit = src % 10; + t~tpush(digit); + len = len + 1; + src = src / 10; + } until (src == 0); + + int c = len - 1; + repeat(len) { + int v = t.at(c); + b = b.store_uint(v + 48, 8); + c = c - 1; + } + } + return b.end_cell().begin_parse(); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `slice __tact_float_to_string(int src, int digits) { + throw_if(${contractErrors.invalidArgument.id}, (digits <= 0) | (digits > 77)); + builder b = begin_cell(); + + if (src < 0) { + b = b.store_uint(45, 8); + src = -src; + } + + ;; Process rem part + int skip = true; + int len = 0; + int rem = 0; + tuple t = empty_tuple(); + repeat(digits) { + (src, rem) = src.divmod(10); + if (~(skip & (rem == 0))) { + skip = false; + t~tpush(rem + 48); + len = len + 1; + } + } + + ;; Process dot + if (~skip) { + t~tpush(46); + len = len + 1; + } + + ;; Main + do { + (src, rem) = src.divmod(10); + t~tpush(rem + 48); + len = len + 1; + } until (src == 0); + + ;; Assemble + int c = len - 1; + repeat(len) { + int v = t.at(c); + b = b.store_uint(v, 8); + c = c - 1; + } + + ;; Result + return b.end_cell().begin_parse(); + }`, + { context: Location.stdlib() }, + ); + + ctx.parse(`int __tact_log2(int num) asm "DUP 5 THROWIFNOT UBITSIZE DEC";`, { + context: Location.stdlib(), + }); + + ctx.parse( + `int __tact_log(int num, int base) { + throw_unless(5, num > 0); + throw_unless(5, base > 1); + if (num < base) { + return 0; + } + int result = 0; + while (num >= base) { + num /= base; + result += 1; + } + return result; + }`, + { context: Location.stdlib() }, + ); + + ctx.parse( + `int __tact_pow(int base, int exp) { + throw_unless(5, exp >= 0); + int result = 1; + repeat(exp) { + result *= base; + } + return result; + }`, + { context: Location.stdlib() }, + ); + + ctx.parse(`int __tact_pow2(int exp) asm "POW2";`, { + context: Location.stdlib(), + }); } From 123f7ae5bafe886faa850fe5b5d0ed156842c811 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 6 Sep 2024 12:15:31 +0000 Subject: [PATCH 125/162] fix(stdlib): Hack for Func parser --- src/codegen/stdlib.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/stdlib.ts b/src/codegen/stdlib.ts index eed58143d..a672c67cf 100644 --- a/src/codegen/stdlib.ts +++ b/src/codegen/stdlib.ts @@ -1272,7 +1272,7 @@ export function writeStdlib(ctx: WriterContext) { tuple t = empty_tuple(); repeat(digits) { (src, rem) = src.divmod(10); - if (~(skip & (rem == 0))) { + if (~ (skip & (rem == 0))) { skip = false; t~tpush(rem + 48); len = len + 1; From 3fc4e790f52a5ccc69656340d614627e33c2f65c Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 6 Sep 2024 12:27:00 +0000 Subject: [PATCH 126/162] fix(stdlib): Missing brackets --- src/codegen/stdlib.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/codegen/stdlib.ts b/src/codegen/stdlib.ts index a672c67cf..6d0601d5f 100644 --- a/src/codegen/stdlib.ts +++ b/src/codegen/stdlib.ts @@ -743,6 +743,7 @@ export function writeStdlib(ctx: WriterContext) { return (key, value~load_int(vl), flag); } else { return (null(), null(), flag); + } }`, { context: Location.stdlib() }, ); @@ -794,6 +795,7 @@ export function writeStdlib(ctx: WriterContext) { return (key, value~load_uint(vl), flag); } else { return (null(), null(), flag); + } }`, { context: Location.stdlib() }, ); From 1344fb78067c7bba89c9beae175f216974a97fd5 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 6 Sep 2024 12:27:49 +0000 Subject: [PATCH 127/162] chore(ctx): Add missing `parse` --- src/codegen/context.ts | 44 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index 504e57a87..aaeb77fe4 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -2,15 +2,19 @@ import { CompilerContext } from "../context"; import { topologicalSort } from "../utils/utils"; import { FuncAstFunctionDefinition, - FuncAstAsmFunctionDefinition , + FuncAstAsmFunctionDefinition, FuncAstFunctionAttribute, FuncAstId, + FuncAstModule, FuncAstType, FuncAstStatement, } from "../func/grammar"; import { asmfun, fun, FunParamValue } from "../func/syntaxConstructors"; +import { parse } from "../func/grammar"; import { forEachExpression } from "../func/iterators"; +import JSONbig from "json-bigint"; + /** * An additional information on how to handle the function definition. * TODO: Refactor: we need only the boolean `skip` field in WrittenFunction. @@ -70,7 +74,10 @@ export class Location { export type WrittenFunction = { name: string; - definition: FuncAstFunctionDefinition | FuncAstAsmFunctionDefinition | undefined; + definition: + | FuncAstFunctionDefinition + | FuncAstAsmFunctionDefinition + | undefined; kind: BodyKind; context: LocationContext | undefined; depends: Set; @@ -103,7 +110,10 @@ export class WriterContext { ): void { forEachExpression(fun, (expr) => { // TODO: It doesn't save receivers. But should it? - if (expr.kind === "expression_fun_call" && expr.object.kind === "plain_id") { + if ( + expr.kind === "expression_fun_call" && + expr.object.kind === "plain_id" + ) { depends.add(expr.object.value); } }); @@ -154,6 +164,29 @@ export class WriterContext { }); } + /** + * Parses the Func source code to the definition of function. + * @throws If the given code cannot be parsed as a simple function/asm function definition. + */ + public parse< + T extends FuncAstFunctionDefinition | FuncAstAsmFunctionDefinition, + >(code: string, params: Partial = {}): T | never { + const mod = parse(code) as FuncAstModule; + if ( + mod.items.length === 1 && + (mod.items[0]!.kind === "function_definition" || + mod.items[0]!.kind === "asm_function_definition") + ) { + const fun = mod.items[0] as T; + this.save(fun, params); + return fun; + } + // TODO(jubnzv): Add a custom error when merging w/ main + throw new Error( + `Incorrect function structure: ${JSONbig.stringify(mod)}`, + ); + } + /** * Wraps the function definition constructor saving it to the context. * XXX: Replicates old WriterContext.fun @@ -225,7 +258,10 @@ export class WriterContext { } }; this.mainFunctions().forEach((f) => visit(f.name)); - all = all.filter((v) => used.has(v.name)); + all = all.filter((v) => { + console.log(v.name, used.has(v.name)); + return used.has(v.name); + }); // Sort functions const sorted = topologicalSort(all, (f) => { From ac3111a197d65fa7c2cfe362b2d92948ee0eaf5f Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 6 Sep 2024 12:31:22 +0000 Subject: [PATCH 128/162] chore(stdlib): simplify --- src/codegen/stdlib.ts | 363 ++++++++++++++---------------------------- 1 file changed, 121 insertions(+), 242 deletions(-) diff --git a/src/codegen/stdlib.ts b/src/codegen/stdlib.ts index 6d0601d5f..fde94ea45 100644 --- a/src/codegen/stdlib.ts +++ b/src/codegen/stdlib.ts @@ -3,6 +3,9 @@ import { contractErrors } from "../abi/errors"; import { enabledMasterchain } from "../config/features"; export function writeStdlib(ctx: WriterContext) { + const parse = (code: string) => + ctx.parse(code, { context: Location.stdlib() }); + // // stdlib extension functions // @@ -17,7 +20,7 @@ export function writeStdlib(ctx: WriterContext) { // Addresses // - ctx.parse( + parse( `slice __tact_verify_address(slice address) inline { throw_unless(${contractErrors.invalidAddress.id}, address.slice_bits() == 267); var h = address.preload_uint(11); @@ -35,22 +38,18 @@ export function writeStdlib(ctx: WriterContext) { return address; }`, - { context: Location.stdlib() }, ); - ctx.parse(`(slice, int) __tact_load_bool(slice s) asm(s -> 1 0) "1 LDI";`, { - context: Location.stdlib(), - }); + parse(`(slice, int) __tact_load_bool(slice s) asm(s -> 1 0) "1 LDI";`); - ctx.parse( + parse( `(slice, slice) __tact_load_address(slice cs) inline { slice raw = cs~load_msg_addr(); return (cs, __tact_verify_address(raw)); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, slice) __tact_load_address_opt(slice cs) inline { if (cs.preload_uint(2) != 0) { slice raw = cs~load_msg_addr(); @@ -60,17 +59,15 @@ export function writeStdlib(ctx: WriterContext) { return (cs, null()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `builder __tact_store_address(builder b, slice address) inline { return b.store_slice(__tact_verify_address(address)); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `builder __tact_store_address_opt(builder b, slice address) inline { if (null?(address)) { b = b.store_uint(0, 2); @@ -79,10 +76,9 @@ export function writeStdlib(ctx: WriterContext) { return __tact_store_address(b, address); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `slice __tact_create_address(int chain, int hash) inline { var b = begin_cell(); b = b.store_uint(2, 2); @@ -92,10 +88,9 @@ export function writeStdlib(ctx: WriterContext) { var addr = b.end_cell().begin_parse(); return __tact_verify_address(addr); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `slice __tact_compute_contract_address(int chain, cell code, cell data) inline { var b = begin_cell(); b = b.store_uint(0, 2); @@ -106,70 +101,58 @@ export function writeStdlib(ctx: WriterContext) { var hash = cell_hash(b.end_cell()); return __tact_create_address(chain, hash); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_my_balance() inline { return pair_first(get_balance()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `forall X -> X __tact_not_null(X x) inline { throw_if(${contractErrors.null.id}, null?(x)); return x; }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(cell, int) __tact_dict_delete(cell dict, int key_len, slice index) asm(index dict key_len) "DICTDEL";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value) asm(value index dict key_len) "DICTSETREF";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, int) __tact_dict_get(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGET" "NULLSWAPIFNOT";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(cell, int) __tact_dict_get_ref(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGETREF" "NULLSWAPIFNOT";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, slice, int) __tact_dict_min(cell dict, int key_len) asm(dict key_len -> 1 0 2) "DICTMIN" "NULLSWAPIFNOT2";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, cell, int) __tact_dict_min_ref(cell dict, int key_len) asm(dict key_len -> 1 0 2) "DICTMINREF" "NULLSWAPIFNOT2";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, slice, int) __tact_dict_next(cell dict, int key_len, slice pivot) asm(pivot dict key_len -> 1 0 2) "DICTGETNEXT" "NULLSWAPIFNOT2";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, cell, int) __tact_dict_next_ref(cell dict, int key_len, slice pivot) inline { var (key, value, flag) = __tact_dict_next(dict, key_len, pivot); if (flag) { @@ -178,20 +161,17 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `forall X -> () __tact_debug(X value, slice debug_print) impure asm "STRDUMP" "DROP" "s0 DUMP" "DROP";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `() __tact_debug_str(slice value, slice debug_print) impure asm "STRDUMP" "DROP" "STRDUMP" "DROP";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `() __tact_debug_bool(int value, slice debug_print) impure { if (value) { __tact_debug_str("true", debug_print); @@ -199,15 +179,13 @@ export function writeStdlib(ctx: WriterContext) { __tact_debug_str("false", debug_print); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice) __tact_preload_offset(slice s, int offset, int bits) inline asm "SDSUBSTR";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice) __tact_crc16(slice data) inline_ref { slice new_data = begin_cell() .store_slice(data) @@ -235,10 +213,9 @@ export function writeStdlib(ctx: WriterContext) { .store_uint(r, 8) .end_cell().begin_parse(); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice) __tact_base64_encode(slice data) inline { slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; builder res = begin_cell(); @@ -257,10 +234,9 @@ export function writeStdlib(ctx: WriterContext) { return res.end_cell().begin_parse(); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice) __tact_address_to_user_friendly(slice address) inline { (int wc, int hash) = address.parse_std_addr(); @@ -278,65 +254,54 @@ export function writeStdlib(ctx: WriterContext) { return __tact_base64_encode(user_friendly_address_with_checksum); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `() __tact_debug_address(slice address, slice debug_print) impure { __tact_debug_str(__tact_address_to_user_friendly(address), debug_print); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `() __tact_debug_stack(slice debug_print) impure asm "STRDUMP" "DROP" "DUMPSTK";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, slice, int, slice) __tact_context_get() inline { return __tact_context; }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `slice __tact_context_get_sender() inline { return __tact_context_sender; }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `() __tact_prepare_random() impure inline { if (null?(__tact_randomized)) { randomize_lt(); __tact_randomized = true; } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `builder __tact_store_bool(builder b, int v) inline { return b.store_int(v, 1); }`, - { context: Location.stdlib() }, ); - ctx.parse(`forall X -> tuple __tact_to_tuple(X x) asm "NOP";`, { - context: Location.stdlib(), - }); + parse(`forall X -> tuple __tact_to_tuple(X x) asm "NOP";`); - ctx.parse(`forall X -> X __tact_from_tuple(tuple x) asm "NOP";`, { - context: Location.stdlib(), - }); + parse(`forall X -> X __tact_from_tuple(tuple x) asm "NOP";`); // // Dict Int -> Int // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl) inline { if (null?(v)) { var (r, ok) = idict_delete?(d, kl, k); @@ -345,10 +310,9 @@ export function writeStdlib(ctx: WriterContext) { return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_dict_get_int_int(cell d, int kl, int k, int vl) inline { var (r, ok) = idict_get?(d, kl, k); if (ok) { @@ -357,10 +321,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl) inline { var (key, value, flag) = idict_get_min?(d, kl); if (flag) { @@ -369,10 +332,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl) inline { var (key, value, flag) = idict_get_next?(d, kl, pivot); if (flag) { @@ -381,14 +343,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Int -> Uint // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl) inline { if (null?(v)) { var (r, ok) = udict_delete?(d, kl, k); @@ -397,10 +358,9 @@ export function writeStdlib(ctx: WriterContext) { return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_dict_get_uint_int(cell d, int kl, int k, int vl) inline { var (r, ok) = udict_get?(d, kl, k); if (ok) { @@ -409,10 +369,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl) inline { var (key, value, flag) = udict_get_min?(d, kl); if (flag) { @@ -421,10 +380,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl) inline { var (key, value, flag) = udict_get_next?(d, kl, pivot); if (flag) { @@ -433,14 +391,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Uint -> Uint // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl) inline { if (null?(v)) { var (r, ok) = udict_delete?(d, kl, k); @@ -449,10 +406,9 @@ export function writeStdlib(ctx: WriterContext) { return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl) inline { var (r, ok) = udict_get?(d, kl, k); if (ok) { @@ -461,10 +417,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl) inline { var (key, value, flag) = udict_get_min?(d, kl); if (flag) { @@ -473,10 +428,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl) inline { var (key, value, flag) = udict_get_next?(d, kl, pivot); if (flag) { @@ -485,14 +439,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Int -> Cell // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v) inline { if (null?(v)) { var (r, ok) = idict_delete?(d, kl, k); @@ -501,10 +454,9 @@ export function writeStdlib(ctx: WriterContext) { return (idict_set_ref(d, kl, k, v), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `cell __tact_dict_get_int_cell(cell d, int kl, int k) inline { var (r, ok) = idict_get_ref?(d, kl, k); if (ok) { @@ -513,10 +465,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, cell, int) __tact_dict_min_int_cell(cell d, int kl) inline { var (key, value, flag) = idict_get_min_ref?(d, kl); if (flag) { @@ -525,10 +476,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot) inline { var (key, value, flag) = idict_get_next?(d, kl, pivot); if (flag) { @@ -537,14 +487,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Uint -> Cell // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v) inline { if (null?(v)) { var (r, ok) = udict_delete?(d, kl, k); @@ -553,10 +502,9 @@ export function writeStdlib(ctx: WriterContext) { return (udict_set_ref(d, kl, k, v), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `cell __tact_dict_get_uint_cell(cell d, int kl, int k) inline { var (r, ok) = udict_get_ref?(d, kl, k); if (ok) { @@ -565,10 +513,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl) inline { var (key, value, flag) = udict_get_min_ref?(d, kl); if (flag) { @@ -577,10 +524,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot) inline { var (key, value, flag) = udict_get_next?(d, kl, pivot); if (flag) { @@ -589,14 +535,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Int -> Slice // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v) inline { if (null?(v)) { var (r, ok) = idict_delete?(d, kl, k); @@ -605,10 +550,9 @@ export function writeStdlib(ctx: WriterContext) { return (idict_set(d, kl, k, v), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `slice __tact_dict_get_int_slice(cell d, int kl, int k) inline { var (r, ok) = idict_get?(d, kl, k); if (ok) { @@ -617,10 +561,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, slice, int) __tact_dict_min_int_slice(cell d, int kl) inline { var (key, value, flag) = idict_get_min?(d, kl); if (flag) { @@ -629,10 +572,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot) inline { var (key, value, flag) = idict_get_next?(d, kl, pivot); if (flag) { @@ -641,14 +583,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Uint -> Slice // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v) inline { if (null?(v)) { var (r, ok) = udict_delete?(d, kl, k); @@ -657,10 +598,9 @@ export function writeStdlib(ctx: WriterContext) { return (udict_set(d, kl, k, v), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `slice __tact_dict_get_uint_slice(cell d, int kl, int k) inline { var (r, ok) = udict_get?(d, kl, k); if (ok) { @@ -669,10 +609,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl) inline { var (key, value, flag) = udict_get_min?(d, kl); if (flag) { @@ -681,10 +620,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot) inline { var (key, value, flag) = udict_get_next?(d, kl, pivot); if (flag) { @@ -693,14 +631,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Slice -> Int // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl) inline { if (null?(v)) { var (r, ok) = __tact_dict_delete(d, kl, k); @@ -709,10 +646,9 @@ export function writeStdlib(ctx: WriterContext) { return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl) inline { var (r, ok) = __tact_dict_get(d, kl, k); if (ok) { @@ -721,10 +657,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl) inline { var (key, value, flag) = __tact_dict_min(d, kl); if (flag) { @@ -733,10 +668,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl) inline { var (key, value, flag) = __tact_dict_next(d, kl, pivot); if (flag) { @@ -745,14 +679,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Slice -> UInt // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl) inline { if (null?(v)) { var (r, ok) = __tact_dict_delete(d, kl, k); @@ -761,10 +694,9 @@ export function writeStdlib(ctx: WriterContext) { return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl) inline { var (r, ok) = __tact_dict_get(d, kl, k); if (ok) { @@ -773,10 +705,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl) inline { var (key, value, flag) = __tact_dict_min(d, kl); if (flag) { @@ -785,10 +716,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl) inline { var (key, value, flag) = __tact_dict_next(d, kl, pivot); if (flag) { @@ -797,14 +727,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Slice -> Cell // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v) inline { if (null?(v)) { var (r, ok) = __tact_dict_delete(d, kl, k); @@ -813,10 +742,9 @@ export function writeStdlib(ctx: WriterContext) { return __tact_dict_set_ref(d, kl, k, v); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `cell __tact_dict_get_slice_cell(cell d, int kl, slice k) inline { var (r, ok) = __tact_dict_get_ref(d, kl, k); if (ok) { @@ -825,10 +753,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl) inline { var (key, value, flag) = __tact_dict_min_ref(d, kl); if (flag) { @@ -837,10 +764,9 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot) inline { var (key, value, flag) = __tact_dict_next(d, kl, pivot); if (flag) { @@ -849,14 +775,13 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); // // Dict Slice -> Slice // - ctx.parse( + parse( `(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v) inline { if (null?(v)) { var (r, ok) = __tact_dict_delete(d, kl, k); @@ -865,10 +790,9 @@ export function writeStdlib(ctx: WriterContext) { return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `slice __tact_dict_get_slice_slice(cell d, int kl, slice k) inline { var (r, ok) = __tact_dict_get(d, kl, k); if (ok) { @@ -877,10 +801,9 @@ export function writeStdlib(ctx: WriterContext) { return null(); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl) inline { var (key, value, flag) = __tact_dict_min(d, kl); if (flag) { @@ -889,212 +812,186 @@ export function writeStdlib(ctx: WriterContext) { return (null(), null(), flag); } }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot) inline { return __tact_dict_next(d, kl, pivot); }`, - { context: Location.stdlib() }, ); // // Address // - ctx.parse( + parse( `int __tact_slice_eq_bits(slice a, slice b) inline { return equal_slice_bits(a, b); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_slice_eq_bits_nullable_one(slice a, slice b) inline { return (null?(a)) ? (false) : (equal_slice_bits(a, b)); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_slice_eq_bits_nullable(slice a, slice b) inline { var a_is_null = null?(a); var b_is_null = null?(b); return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (equal_slice_bits(a, b)) : (false); }`, - { context: Location.stdlib() }, ); // // Int Eq // - ctx.parse( + parse( `int __tact_int_eq_nullable_one(int a, int b) inline { return (null?(a)) ? (false) : (a == b); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_int_neq_nullable_one(int a, int b) inline { return (null?(a)) ? (true) : (a != b); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_int_eq_nullable(int a, int b) inline { var a_is_null = null?(a); var b_is_null = null?(b); return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a == b) : (false); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_int_neq_nullable(int a, int b) inline { var a_is_null = null?(a); var b_is_null = null?(b); return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a != b) : (true); }`, - { context: Location.stdlib() }, ); // // Cell Eq // - ctx.parse( + parse( `int __tact_cell_eq(cell a, cell b) inline { return (a.cell_hash() == b.cell_hash()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_cell_neq(cell a, cell b) inline { return (a.cell_hash() != b.cell_hash()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_cell_eq_nullable_one(cell a, cell b) inline { return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_cell_neq_nullable_one(cell a, cell b) inline { return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_cell_eq_nullable(cell a, cell b) inline { var a_is_null = null?(a); var b_is_null = null?(b); return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a.cell_hash() == b.cell_hash()) : (false); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_cell_neq_nullable(cell a, cell b) inline { var a_is_null = null?(a); var b_is_null = null?(b); return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a.cell_hash() != b.cell_hash()) : (true); }`, - { context: Location.stdlib() }, ); // // Slice Eq // - ctx.parse( + parse( `int __tact_slice_eq(slice a, slice b) inline { return (a.slice_hash() == b.slice_hash()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_slice_neq(slice a, slice b) inline { return (a.slice_hash() != b.slice_hash()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_slice_eq_nullable_one(slice a, slice b) inline { return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_slice_neq_nullable_one(slice a, slice b) inline { return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_slice_eq_nullable(slice a, slice b) inline { var a_is_null = null?(a); var b_is_null = null?(b); return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a.slice_hash() == b.slice_hash()) : (false); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_slice_neq_nullable(slice a, slice b) inline { var a_is_null = null?(a); var b_is_null = null?(b); return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a.slice_hash() != b.slice_hash()) : (true); }`, - { context: Location.stdlib() }, ); // // Sys Dict // - ctx.parse( + parse( `cell __tact_dict_set_code(cell dict, int id, cell code) inline { return udict_set_ref(dict, 16, id, code); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `cell __tact_dict_get_code(cell dict, int id) inline { var (data, ok) = udict_get_ref?(dict, 16, id); throw_unless(${contractErrors.codeNotFound.id}, ok); return data; }`, - { context: Location.stdlib() }, ); // // Tuples // - ctx.parse(`tuple __tact_tuple_create_0() asm "NIL";`, { - context: Location.stdlib(), - }); + parse(`tuple __tact_tuple_create_0() asm "NIL";`); - ctx.parse( + parse( `() __tact_tuple_destroy_0() inline { return (); }`, - { context: Location.stdlib() }, ); for (let i = 1; i < 64; i++) { @@ -1103,14 +1000,12 @@ export function writeStdlib(ctx: WriterContext) { args.push(`X${j}`); } - ctx.parse( + parse( `forall ${args.join(", ")} -> tuple __tact_tuple_create_${i}((${args.join(", ")}) v) asm "${i} TUPLE";`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `forall ${args.join(", ")} -> (${args.join(", ")}) __tact_tuple_destroy_${i}(tuple v) asm "${i} UNTUPLE";`, - { context: Location.stdlib() }, ); } @@ -1118,35 +1013,31 @@ export function writeStdlib(ctx: WriterContext) { // Strings // - ctx.parse( + parse( `tuple __tact_string_builder_start_comment() inline { return __tact_string_builder_start(begin_cell().store_uint(0, 32)); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `tuple __tact_string_builder_start_tail_string() inline { return __tact_string_builder_start(begin_cell().store_uint(0, 8)); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `tuple __tact_string_builder_start_string() inline { return __tact_string_builder_start(begin_cell()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `tuple __tact_string_builder_start(builder b) inline { return tpush(tpush(empty_tuple(), b), null()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `cell __tact_string_builder_end(tuple builders) inline { (builder b, tuple tail) = uncons(builders); cell c = b.end_cell(); @@ -1156,17 +1047,15 @@ export function writeStdlib(ctx: WriterContext) { } return c; }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `slice __tact_string_builder_end_slice(tuple builders) inline { return __tact_string_builder_end(builders).begin_parse(); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `((tuple), ()) __tact_string_builder_append(tuple builders, slice sc) { int sliceRefs = slice_refs(sc); int sliceBits = slice_bits(sc); @@ -1204,18 +1093,16 @@ export function writeStdlib(ctx: WriterContext) { return ((builders), ()); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc) { builders~__tact_string_builder_append(sc); return builders; }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `slice __tact_int_to_string(int src) { var b = begin_cell(); if (src < 0) { @@ -1254,10 +1141,9 @@ export function writeStdlib(ctx: WriterContext) { } return b.end_cell().begin_parse(); }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `slice __tact_float_to_string(int src, int digits) { throw_if(${contractErrors.invalidArgument.id}, (digits <= 0) | (digits > 77)); builder b = begin_cell(); @@ -1305,14 +1191,11 @@ export function writeStdlib(ctx: WriterContext) { ;; Result return b.end_cell().begin_parse(); }`, - { context: Location.stdlib() }, ); - ctx.parse(`int __tact_log2(int num) asm "DUP 5 THROWIFNOT UBITSIZE DEC";`, { - context: Location.stdlib(), - }); + parse(`int __tact_log2(int num) asm "DUP 5 THROWIFNOT UBITSIZE DEC";`); - ctx.parse( + parse( `int __tact_log(int num, int base) { throw_unless(5, num > 0); throw_unless(5, base > 1); @@ -1326,10 +1209,9 @@ export function writeStdlib(ctx: WriterContext) { } return result; }`, - { context: Location.stdlib() }, ); - ctx.parse( + parse( `int __tact_pow(int base, int exp) { throw_unless(5, exp >= 0); int result = 1; @@ -1338,10 +1220,7 @@ export function writeStdlib(ctx: WriterContext) { } return result; }`, - { context: Location.stdlib() }, ); - ctx.parse(`int __tact_pow2(int exp) asm "POW2";`, { - context: Location.stdlib(), - }); + parse(`int __tact_pow2(int exp) asm "POW2";`); } From 4f6e849a5c2bb5064a76b467a65033399adeb44e Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sat, 7 Sep 2024 12:57:57 +0000 Subject: [PATCH 129/162] chore(pp): ppTy as a public interface --- src/func/prettyPrinter.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index e098c0965..67882dbe3 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -281,7 +281,7 @@ export class FuncPrettyPrinter { } private prettyPrintGlobalVariable(node: FuncAstGlobalVariable): string { - const typeStr = node.ty ? this.ppTy(node.ty) : "var"; + const typeStr = node.ty ? this.prettyPrintType(node.ty) : "var"; const nameStr = this.prettyPrint(node.name); return `${typeStr} ${nameStr};`; } @@ -350,7 +350,7 @@ export class FuncPrettyPrinter { parameters: FuncAstParameter[], attributes: FuncAstFunctionAttribute[], ): string { - const returnTypeStr = this.ppTy(returnType); + const returnTypeStr = this.prettyPrintType(returnType); const nameStr = this.prettyPrint(name); const paramsStr = parameters .map((param) => this.prettyPrintParameter(param)) @@ -363,7 +363,7 @@ export class FuncPrettyPrinter { } private prettyPrintParameter(param: FuncAstParameter): string { - const typeStr = param.ty ? this.ppTy(param.ty) : "var"; + const typeStr = param.ty ? this.prettyPrintType(param.ty) : "var"; const nameStr = param.name ? this.prettyPrint(param.name) : ""; return `${typeStr} ${nameStr}`.trim(); } @@ -549,7 +549,7 @@ export class FuncPrettyPrinter { private prettyPrintExpressionVarDecl( node: FuncAstExpressionVarDecl, ): string { - const type = this.ppTy(node.ty); + const type = this.prettyPrintType(node.ty); const names = this.prettyPrintVarDeclPart(node.names); return `${type} ${names}`; } @@ -645,7 +645,7 @@ export class FuncPrettyPrinter { return indentedContent; } - private ppTy(ty: FuncAstType): string { + public prettyPrintType(ty: FuncAstType): string { switch (ty.kind) { case "type_primitive": return this.prettyPrintTypePrimitive( @@ -667,11 +667,11 @@ export class FuncPrettyPrinter { } private prettyPrintTypeTensor(node: FuncAstTypeTensor): string { - return `(${node.types.map((type) => this.ppTy(type)).join(", ")})`; + return `(${node.types.map((type) => this.prettyPrintType(type)).join(", ")})`; } private prettyPrintTypeTuple(node: FuncAstTypeTuple): string { - return `[${node.types.map((type) => this.ppTy(type)).join(", ")}]`; + return `[${node.types.map((type) => this.prettyPrintType(type)).join(", ")}]`; } private prettyPrintTypeHole(node: FuncAstHole): string { @@ -679,8 +679,8 @@ export class FuncPrettyPrinter { } private prettyPrintTypeMapped(node: FuncAstTypeMapped): string { - const value = this.ppTy(node.value); - const mapsTo = this.ppTy(node.mapsTo); + const value = this.prettyPrintType(node.value); + const mapsTo = this.prettyPrintType(node.mapsTo); return `${value} -> ${mapsTo}`; } From be14b13048f7e14a279479831cfc36a8fa2f4b03 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sat, 7 Sep 2024 13:47:39 +0000 Subject: [PATCH 130/162] feat(codegen): Add accessors --- src/codegen/context.ts | 1 - src/codegen/module.ts | 64 ++++++++++-------------- src/codegen/type.ts | 108 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 40 deletions(-) diff --git a/src/codegen/context.ts b/src/codegen/context.ts index aaeb77fe4..570e292e6 100644 --- a/src/codegen/context.ts +++ b/src/codegen/context.ts @@ -259,7 +259,6 @@ export class WriterContext { }; this.mainFunctions().forEach((f) => visit(f.name)); all = all.filter((v) => { - console.log(v.name, used.has(v.name)); return used.has(v.name); }); diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 089f17986..5bada3480 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -14,6 +14,7 @@ import { getMethodId } from "../utils/utils"; import { idTextErr } from "../errors"; import { contractErrors } from "../abi/errors"; import { writeStdlib } from "./stdlib"; +import { writeAccessors } from "./accessors"; import { resolveFuncTypeUnpack, resolveFuncType, @@ -141,10 +142,6 @@ export class ModuleGen { } } - private addAccessors(_m: FuncAstModule): void { - // TODO - } - private addInitSerializer(_m: FuncAstModule): void { // TODO } @@ -718,11 +715,7 @@ export class ModuleGen { ) { // var text_op = slice_hash(in_msg); condBody.push( - vardef( - "_", - "text_op", - call("slice_hash", [id("in_msg")]), - ), + vardef("_", "text_op", call("slice_hash", [id("in_msg")])), ); for (const r of type.receivers) { if ( @@ -741,18 +734,15 @@ export class ModuleGen { comment(`Receive "${r.selector.comment}" message`), ); condBody.push( - condition( - binop(id("text_op"), "==", hex(hash)), - [ - expr( - call( - `self~${ops.receiveText(type.name, kind, hash)}`, - [], - ), + condition(binop(id("text_op"), "==", hex(hash)), [ + expr( + call( + `self~${ops.receiveText(type.name, kind, hash)}`, + [], ), - ret(tensor(id("self"), bool(true))), - ], - ), + ), + ret(tensor(id("self"), bool(true))), + ]), ); } } @@ -833,7 +823,7 @@ export class ModuleGen { ); const selfType = resolveFuncType(this.ctx.ctx, self); const selfUnpack = vardef( - '_', + "_", resolveFuncTypeUnpack(this.ctx.ctx, self, funcIdOf("self")), id(funcIdOf("self")), ); @@ -863,7 +853,7 @@ export class ModuleGen { const body: FuncAstStatement[] = [selfUnpack]; body.push( vardef( - '_', + "_", resolveFuncTypeUnpack( this.ctx.ctx, selector.type, @@ -1101,7 +1091,7 @@ export class ModuleGen { const body: FuncAstStatement[] = [selfUnpack]; body.push( vardef( - '_', + "_", resolveFuncTypeUnpack( this.ctx.ctx, selector.type, @@ -1163,13 +1153,11 @@ export class ModuleGen { ); } // Load contract state - body.push( - vardef('_', "self", call(ops.contractLoad(self.name), [])), - ); + body.push(vardef("_", "self", call(ops.contractLoad(self.name), []))); // Execute get method body.push( vardef( - '_', + "_", "res", call( `self~${ops.extension(self.name, f.name)}`, @@ -1225,17 +1213,15 @@ export class ModuleGen { body.push(comment("Context")); body.push( vardef( - '_', + "_", "cs", call("begin_parse", [], { receiver: id("in_msg_cell") }), ), ); - body.push( - vardef('_', "msg_flags", call("cs~load_uint", [int(4)])), - ); // int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + body.push(vardef("_", "msg_flags", call("cs~load_uint", [int(4)]))); // int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool body.push( vardef( - '_', + "_", "msg_bounced", unop("-", binop(id("msg_flags"), "&", int(1))), ), @@ -1267,9 +1253,7 @@ export class ModuleGen { // Load self body.push(comment("Load contract data")); - body.push( - vardef('_', "self", call(ops.contractLoad(type.name), [])), - ); + body.push(vardef("_", "self", call(ops.contractLoad(type.name), []))); body.push(cr()); // Process operation @@ -1323,9 +1307,7 @@ export class ModuleGen { // Load self body.push(comment("Load contract data")); - body.push( - vardef('_', "self", call(ops.contractLoad(type.name), [])), - ); + body.push(vardef("_", "self", call(ops.contractLoad(type.name), []))); body.push(cr()); // Process operation @@ -1464,7 +1446,11 @@ export class ModuleGen { this.writeStdlib(); this.addSerializers(m); - this.addAccessors(m); + for (const t of allTypes) { + if (t.kind === "contract" || t.kind === "struct") { + writeAccessors(t, this.ctx); + } + } this.addInitSerializer(m); this.addStorageFunctions(m); this.addStaticFunctions(m); diff --git a/src/codegen/type.ts b/src/codegen/type.ts index 6a380da78..b0ec3b681 100644 --- a/src/codegen/type.ts +++ b/src/codegen/type.ts @@ -243,3 +243,111 @@ export function resolveFuncTupleType( // Unreachable throw Error(`Unknown type: ${descriptor.kind}`); } + +export function resolveFuncFlatPack( + ctx: CompilerContext, + descriptor: TypeRef | TypeDescription | string, + name: string, + optional: boolean = false, +): string[] { + // String + if (typeof descriptor === "string") { + return resolveFuncFlatPack(ctx, getType(ctx, descriptor), name); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncFlatPack( + ctx, + getType(ctx, descriptor.name), + name, + descriptor.optional, + ); + } + if (descriptor.kind === "map") { + return [name]; + } + if (descriptor.kind === "ref_bounced") { + throw Error("Unimplemented"); + } + if (descriptor.kind === "void") { + throw Error("Void type is not allowed in function arguments: " + name); + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + return [name]; + } else if (descriptor.kind === "struct") { + if (optional || descriptor.fields.length === 0) { + return [name]; + } else { + return descriptor.fields.flatMap((v) => + resolveFuncFlatPack(ctx, v.type, name + `'` + v.name), + ); + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return [name]; + } else { + return descriptor.fields.flatMap((v) => + resolveFuncFlatPack(ctx, v.type, name + `'` + v.name), + ); + } + } + + // Unreachable + throw Error("Unknown type: " + descriptor.kind); +} + +export function resolveFuncFlatTypes( + ctx: CompilerContext, + descriptor: TypeRef | TypeDescription | string, + optional: boolean = false, +): FuncAstType[] { + // String + if (typeof descriptor === "string") { + return resolveFuncFlatTypes(ctx, getType(ctx, descriptor)); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncFlatTypes( + ctx, + getType(ctx, descriptor.name), + descriptor.optional, + ); + } + if (descriptor.kind === "map") { + return [Type.cell()]; + } + if (descriptor.kind === "ref_bounced") { + throw Error("Unimplemented"); + } + if (descriptor.kind === "void") { + throw Error("Void type is not allowed in function arguments"); + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + return [resolveFuncType(ctx, descriptor)]; + } else if (descriptor.kind === "struct") { + if (optional || descriptor.fields.length === 0) { + return [Type.tuple()]; + } else { + return descriptor.fields.flatMap((v) => + resolveFuncFlatTypes(ctx, v.type), + ); + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return [Type.tuple()]; + } else { + return descriptor.fields.flatMap((v) => + resolveFuncFlatTypes(ctx, v.type), + ); + } + } + + // Unreachable + throw Error("Unknown type: " + descriptor.kind); +} From 41c3f358cd83bebd0acc12bfe3cf2d26349ea78c Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sun, 8 Sep 2024 01:07:26 +0000 Subject: [PATCH 131/162] fix(accessors): Syntax errors --- src/codegen/accessors.ts | 190 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 src/codegen/accessors.ts diff --git a/src/codegen/accessors.ts b/src/codegen/accessors.ts new file mode 100644 index 000000000..74e81c02e --- /dev/null +++ b/src/codegen/accessors.ts @@ -0,0 +1,190 @@ +import { WriterContext, Location } from "./context"; +import { contractErrors } from "../abi/errors"; +import { getType } from "../types/resolveDescriptors"; +import { TypeDescription } from "../types/types"; +import { FuncAstType } from "../func/grammar"; +import { FuncPrettyPrinter } from "../func/prettyPrinter"; +import { ops } from "./util"; +import { + resolveFuncTypeUnpack, + resolveFuncFlatPack, + resolveFuncFlatTypes, + resolveFuncTupleType, + resolveFuncType, +} from "./type"; + +export function writeAccessors(type: TypeDescription, ctx: WriterContext) { + const parse = (code: string) => + ctx.parse(code, { context: Location.type(type.name) }); + const ppty = (ty: FuncAstType): string => + new FuncPrettyPrinter().prettyPrintType(ty); + + // Getters + for (const f of type.fields) { + parse(`_ ${ops.typeField(type.name, f.name)}(${ppty(resolveFuncType(ctx.ctx, type))} v) inline { + var (${type.fields.map((v) => `v'${v.name}`).join(", ")}) = v; + return v'${f.name}; + } + `); + } + + // Tensor cast + parse( + `(${ppty(resolveFuncType(ctx.ctx, type))}) ${ops.typeTensorCast(type.name)}(${ppty(resolveFuncType(ctx.ctx, type))} v) asm "NOP";`, + ); + + // Not null + { + const flatPack = resolveFuncFlatPack(ctx.ctx, type, "vvv"); + const flatTypes = resolveFuncFlatTypes(ctx.ctx, type); + if (flatPack.length !== flatTypes.length) + throw Error("Flat pack and flat types length mismatch"); + const pairs = flatPack.map((v, i) => `${ppty(flatTypes[i]!)} ${v}`); + parse(`(${ppty(resolveFuncType(ctx.ctx, type))}) ${ops.typeNotNull(type.name)}(tuple v) inline { + throw_if(${contractErrors.null.id}, null?(v)); + (${pairs.join(", ")}) = __tact_tuple_destroy_${flatPack.length}(v); + return ${resolveFuncTypeUnpack(ctx.ctx, type, "vvv")}; + }`); + } + + // As optional + { + const flatPack = resolveFuncFlatPack(ctx.ctx, type, "v"); + parse(`tuple ${ops.typeAsOptional(type.name)}(${ppty(resolveFuncType(ctx.ctx, type))} v) inline { + var ${resolveFuncTypeUnpack(ctx.ctx, type, "v")} = v; + return __tact_tuple_create_${flatPack.length}(${flatPack.join(", ")}); + }`); + } + + // + // Convert to and from tuple representation + // + + { + const vars: string[] = []; + for (const f of type.fields) { + if (f.type.kind === "ref") { + const t = getType(ctx.ctx, f.type.name); + if (t.kind === "struct") { + if (f.type.optional) { + vars.push( + `${ops.typeToOptTuple(f.type.name)}(v'${f.name})`, + ); + } else { + vars.push( + `${ops.typeToTuple(f.type.name)}(v'${f.name})`, + ); + } + continue; + } + } + vars.push(`v'${f.name}`); + } + parse(`tuple ${ops.typeToTuple(type.name)}((${ppty(resolveFuncType(ctx.ctx, type))}) v) inline { + var (${type.fields.map((v) => `v'${v.name}`).join(", ")}) = v; + return __tact_tuple_create_${vars.length}(${vars.join(", ")}); + }`); + } + + parse(`tuple ${ops.typeToOptTuple(type.name)}(tuple v) inline { + if (null?(v)) { return null(); } + return ${ops.typeToTuple(type.name)}(${ops.typeNotNull(type.name)}(v)); + }`); + + { + const vars: string[] = []; + const out: string[] = []; + for (const f of type.fields) { + if (f.type.kind === "ref") { + const t = getType(ctx.ctx, f.type.name); + if (t.kind === "struct") { + vars.push(`tuple v'${f.name}`); + if (f.type.optional) { + out.push( + `${ops.typeFromOptTuple(f.type.name)}(v'${f.name})`, + ); + } else { + out.push( + `${ops.typeFromTuple(f.type.name)}(v'${f.name})`, + ); + } + continue; + } else if ( + t.kind === "primitive_type_decl" && + t.name === "Address" + ) { + if (f.type.optional) { + vars.push( + `${ppty(resolveFuncType(ctx.ctx, f.type))} v'${f.name}`, + ); + out.push( + `null?(v'${f.name}) ? null() : __tact_verify_address(v'${f.name})`, + ); + } else { + vars.push( + `${ppty(resolveFuncType(ctx.ctx, f.type))} v'${f.name}`, + ); + out.push(`__tact_verify_address(v'${f.name})`); + } + continue; + } + } + vars.push(`${ppty(resolveFuncType(ctx.ctx, f.type))} v'${f.name}`); + out.push(`v'${f.name}`); + } + parse(`(${type.fields.map((v) => `${ppty(resolveFuncType(ctx.ctx, v.type))}`).join(", ")}) ${ops.typeFromTuple(type.name)}(tuple v) inline { + (${vars.join(", ")}) = __tact_tuple_destroy_${vars.length}(v); + return (${out.join(", ")}); + }`); + } + + parse(`tuple ${ops.typeFromOptTuple(type.name)}(tuple v) inline { + if (null?(v)) { return null(); } + return ${ops.typeAsOptional(type.name)}(${ops.typeFromTuple(type.name)}(v)); + } + `); + + // + // Convert to and from external representation + // + + { + const vars: string[] = []; + for (const f of type.fields) { + if (f.type.kind === "ref") { + const t = getType(ctx.ctx, f.type.name); + if (t.kind === "struct") { + if (f.type.optional) { + vars.push( + `${ops.typeToOptTuple(f.type.name)}(v'${f.name})`, + ); + } else { + vars.push( + `${ops.typeToTuple(f.type.name)}(v'${f.name})`, + ); + } + continue; + } + } + vars.push(`v'${f.name}`); + } + parse(`(${type.fields + .map((v) => resolveFuncTupleType(ctx.ctx, v.type)) + .map((ty) => `${ppty(ty)}`) + .join( + ", ", + )}) ${ops.typeToExternal(type.name)}((${ppty(resolveFuncType(ctx.ctx, type))}) v) inline { + var (${type.fields.map((v) => `v'${v.name}`).join(", ")}) = v; + return (${vars.join(", ")}); + }`); + } + + parse(`tuple ${ops.typeToOptExternal(type.name)}(tuple v) inline { + var loaded = ${ops.typeToOptTuple(type.name)}(v); + if (null?(loaded)) { + return null(); + } else { + return (loaded); + } + }`); +} From f675f27fc19cd9317090673eb0130a02db96cd0b Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sun, 8 Sep 2024 07:00:26 +0000 Subject: [PATCH 132/162] feat(codegen): Serializers --- src/codegen/module.ts | 60 +++- src/codegen/serializers.ts | 587 +++++++++++++++++++++++++++++++++++++ src/codegen/type.ts | 111 +++++++ 3 files changed, 748 insertions(+), 10 deletions(-) create mode 100644 src/codegen/serializers.ts diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 5bada3480..c45a32263 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,4 +1,4 @@ -import { getAllTypes, getType } from "../types/resolveDescriptors"; +import { getAllTypes, getType, toBounced } from "../types/resolveDescriptors"; import { enabledInline } from "../config/features"; import { LiteralGen, Location } from "."; import { @@ -8,8 +8,15 @@ import { TypeRef, FunctionDescription, } from "../types/types"; +import { + writeBouncedParser, + writeOptionalParser, + writeOptionalSerializer, + writeParser, + writeSerializer, +} from "./serializers"; import { CompilerContext } from "../context"; -import { getSortedTypes } from "../storage/resolveAllocation"; +import { getSortedTypes, getAllocation } from "../storage/resolveAllocation"; import { getMethodId } from "../utils/utils"; import { idTextErr } from "../errors"; import { contractErrors } from "../abi/errors"; @@ -136,9 +143,43 @@ export class ModuleGen { writeStdlib(this.ctx); } - private addSerializers(_m: FuncAstModule): void { - const sortedTypes = getSortedTypes(this.ctx.ctx); + private addSerializers(sortedTypes: TypeDescription[]): void { for (const t of sortedTypes) { + if (t.kind === "contract" || t.kind === "struct") { + const allocation = getAllocation(this.ctx.ctx, t.name); + const allocationBounced = getAllocation( + this.ctx.ctx, + toBounced(t.name), + ); + writeSerializer( + t.name, + t.kind === "contract", + allocation, + this.ctx, + ); + writeOptionalSerializer(t.name, this.ctx); + writeParser( + t.name, + t.kind === "contract", + allocation, + this.ctx, + ); + writeOptionalParser(t.name, this.ctx); + writeBouncedParser( + t.name, + t.kind === "contract", + allocationBounced, + this.ctx, + ); + } + } + } + + private addAccessors(allTypes: TypeDescription[]): void { + for (const t of allTypes) { + if (t.kind === "contract" || t.kind === "struct") { + writeAccessors(t, this.ctx); + } } } @@ -1445,12 +1486,11 @@ export class ModuleGen { } this.writeStdlib(); - this.addSerializers(m); - for (const t of allTypes) { - if (t.kind === "contract" || t.kind === "struct") { - writeAccessors(t, this.ctx); - } - } + + const sortedTypes = getSortedTypes(this.ctx.ctx); + + this.addSerializers(sortedTypes); + this.addAccessors(allTypes); this.addInitSerializer(m); this.addStorageFunctions(m); this.addStaticFunctions(m); diff --git a/src/codegen/serializers.ts b/src/codegen/serializers.ts new file mode 100644 index 000000000..7459c76a7 --- /dev/null +++ b/src/codegen/serializers.ts @@ -0,0 +1,587 @@ +import { contractErrors } from "../abi/errors"; +import { throwInternalCompilerError } from "../errors"; +import { dummySrcInfo } from "../grammar/grammar"; +import { AllocationCell, AllocationOperation } from "../storage/operation"; +import { StorageAllocation } from "../storage/StorageAllocation"; +import { getType } from "../types/resolveDescriptors"; +import { WriterContext, Location } from "./context"; +import { ops } from "./util"; +import { resolveFuncTypeFromAbiUnpack, resolveFuncTypeFromAbi } from "./type"; + +const SMALL_STRUCT_MAX_FIELDS = 5; + +// +// Serializer +// + +export function writeSerializer( + name: string, + forceInline: boolean, + allocation: StorageAllocation, + ctx: WriterContext, +) { + const parse = (code: string) => + ctx.parse(code, { context: Location.type(name) }); + const isSmall = allocation.ops.length <= SMALL_STRUCT_MAX_FIELDS; + + // Write to builder + parse(`builder ${ops.writer(name)}(builder build_0, ${resolveFuncTypeFromAbi( + ctx.ctx, + allocation.ops.map((v) => v.type), + )} v) ${forceInline || isSmall ? "inline" : ""} { + ${allocation.ops.length > 0 ? `${resolveFuncTypeFromAbiUnpack(ctx.ctx, "v", allocation.ops)} = v;` : ""} + ${allocation.header ? `build_0 = store_uint(build_0, ${allocation.header.value}, ${allocation.header.bits});` : ""} + ${writeSerializerCell(allocation.root, 0, ctx)}; + return build_0; + } +`); + + // Write to cell + parse(`cell ${ops.writerCell(name)}(${resolveFuncTypeFromAbi( + ctx.ctx, + allocation.ops.map((v) => v.type), + )} v) inline { + return ${ops.writer(name)}(begin_cell(), v).end_cell(); + } + `); +} + +export function writeOptionalSerializer(name: string, ctx: WriterContext) { + const parse = (code: string) => + ctx.parse(code, { context: Location.type(name) }); + parse(`cell ${ops.writerCellOpt(name)}(tuple v) inline { + if (null?(v)) { + return null(); + } + return ${ops.writerCell(name)}(${ops.typeNotNull(name)}(v)); + }`); +} + +function writeSerializerCell( + cell: AllocationCell, + gen: number, + ctx: WriterContext, +): string { + const result = []; + + // Write fields + for (const f of cell.ops) { + result.push(writeSerializerField(f, gen, ctx)); + } + + // Tail + if (cell.next) { + result.push(`var build_${gen + 1} = begin_cell();`); + result.push(writeSerializerCell(cell.next, gen + 1, ctx)); + result.push( + `build_${gen} = store_ref(build_${gen}, build_${gen + 1}.end_cell());`, + ); + } + + return result.join("\n"); +} + +function writeSerializerField( + f: AllocationOperation, + gen: number, + ctx: WriterContext, +): string { + const result: string[] = []; + const fieldName = `v'${f.name}`; + const op = f.op; + + switch (op.kind) { + case "int": { + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_int(${fieldName}, ${op.bits}) : build_${gen}.store_int(false, 1);`, + ); + } else { + result.push( + `build_${gen} = build_${gen}.store_int(${fieldName}, ${op.bits});`, + ); + } + return result.join("\n"); + } + case "uint": { + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_uint(${fieldName}, ${op.bits}) : build_${gen}.store_int(false, 1);`, + ); + } else { + result.push( + `build_${gen} = build_${gen}.store_uint(${fieldName}, ${op.bits});`, + ); + } + return result.join("\n"); + } + case "coins": { + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_coins(${fieldName}) : build_${gen}.store_int(false, 1);`, + ); + } else { + result.push( + `build_${gen} = build_${gen}.store_coins(${fieldName});`, + ); + } + return result.join("\n"); + } + case "boolean": { + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_int(${fieldName}, 1) : build_${gen}.store_int(false, 1);`, + ); + } else { + result.push( + `build_${gen} = build_${gen}.store_int(${fieldName}, 1);`, + ); + } + return result.join("\n"); + } + case "address": { + if (op.optional) { + result.push( + `build_${gen} = __tact_store_address_opt(build_${gen}, ${fieldName});`, + ); + } else { + result.push( + `build_${gen} = __tact_store_address(build_${gen}, ${fieldName});`, + ); + } + return result.join("\n"); + } + case "cell": { + switch (op.format) { + case "default": + { + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_ref(${fieldName}) : build_${gen}.store_int(false, 1);`, + ); + } else { + result.push( + `build_${gen} = build_${gen}.store_ref(${fieldName});`, + ); + } + } + break; + case "remainder": + { + if (op.optional) { + throw Error("Impossible"); + } + result.push( + `build_${gen} = build_${gen}.store_slice(${fieldName}.begin_parse());`, + ); + } + break; + } + return result.join("\n"); + } + case "slice": { + switch (op.format) { + case "default": + { + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_ref(begin_cell().store_slice(${fieldName}).end_cell()) : build_${gen}.store_int(false, 1);`, + ); + } else { + result.push( + `build_${gen} = build_${gen}.store_ref(begin_cell().store_slice(${fieldName}).end_cell());`, + ); + } + } + break; + case "remainder": { + if (op.optional) { + throw Error("Impossible"); + } + result.push( + `build_${gen} = build_${gen}.store_slice(${fieldName});`, + ); + } + } + return result.join("\n"); + } + case "builder": { + switch (op.format) { + case "default": + { + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_ref(begin_cell().store_slice(${fieldName}.end_cell().begin_parse()).end_cell()) : build_${gen}.store_int(false, 1);`, + ); + } else { + result.push( + `build_${gen} = build_${gen}.store_ref(begin_cell().store_slice(${fieldName}.end_cell().begin_parse()).end_cell());`, + ); + } + } + break; + case "remainder": { + if (op.optional) { + throw Error("Impossible"); + } + result.push( + `build_${gen} = build_${gen}.store_slice(${fieldName}.end_cell().begin_parse());`, + ); + } + } + return result.join("\n"); + } + case "string": { + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_ref(begin_cell().store_slice(${fieldName}).end_cell()) : build_${gen}.store_int(false, 1);`, + ); + } else { + result.push( + `build_${gen} = build_${gen}.store_ref(begin_cell().store_slice(${fieldName}).end_cell());`, + ); + } + return result.join("\n"); + } + case "fixed-bytes": { + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_slice(${fieldName}) : build_${gen}.store_int(false, 1);`, + ); + } else { + result.push( + `build_${gen} = build_${gen}.store_slice(${fieldName});`, + ); + } + return result.join("\n"); + } + case "map": { + result.push( + `build_${gen} = build_${gen}.store_dict(${fieldName});`, + ); + return result.join("\n"); + } + case "struct": { + if (op.ref) { + throw Error("Not implemented"); + } + if (op.optional) { + result.push( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).${ops.writer(op.type)}(${ops.typeNotNull(op.type)}(${fieldName})) : build_${gen}.store_int(false, 1);`, + ); + } else { + const ff = getType(ctx.ctx, op.type).fields.map((f) => f.abi); + result.push( + `build_${gen} = ${ops.writer(op.type)}(build_${gen}, ${resolveFuncTypeFromAbiUnpack(ctx.ctx, fieldName, ff)});`, + ); + } + return result.join("\n"); + } + } + + throwInternalCompilerError(`Unsupported field kind`, dummySrcInfo); +} + +// +// Parser +// + +export function writeParser( + name: string, + forceInline: boolean, + allocation: StorageAllocation, + ctx: WriterContext, +) { + const isSmall = allocation.ops.length <= SMALL_STRUCT_MAX_FIELDS; + const parse = (code: string) => + ctx.parse(code, { context: Location.type(name) }); + + { + const result = []; + result.push( + `(slice, (${resolveFuncTypeFromAbi( + ctx.ctx, + allocation.ops.map((v) => v.type), + )})) ${ops.reader(name)}(slice sc_0) ${forceInline || isSmall ? "inline" : ""} {`, + ); + if (allocation.header) { + result.push(` + throw_unless(${contractErrors.invalidPrefix.id}, sc_0~load_uint(${allocation.header.bits}) == ${allocation.header.value}); + `); + } + result.push(writeCellParser(allocation.root, 0, ctx)); + if (allocation.ops.length === 0) { + result.push("return (sc_0, null());"); + } else { + result.push(` + return (sc_0, (${allocation.ops.map((v) => `v'${v.name}`).join(", ")})); + `); + } + result.push("}"); + parse(result.join("\n")); + } + + // Write non-modifying variant + parse(`${resolveFuncTypeFromAbi( + ctx.ctx, + allocation.ops.map((v) => v.type), + )} ${ops.readerNonModifying(name)}(slice sc_0) ${forceInline || isSmall ? "inline" : ""} { + var r = sc_0~${ops.reader(name)}(); + sc_0.end_parse(); + return r; + }`); +} + +export function writeBouncedParser( + name: string, + forceInline: boolean, + allocation: StorageAllocation, + ctx: WriterContext, +) { + const isSmall = allocation.ops.length <= SMALL_STRUCT_MAX_FIELDS; + const parse = (code: string) => + ctx.parse(code, { context: Location.type(name) }); + + { + const result = []; + result.push( + `(slice, (${resolveFuncTypeFromAbi( + ctx.ctx, + allocation.ops.map((v) => v.type), + )})) ${ops.readerBounced(name)}(slice sc_0) ${forceInline || isSmall ? "inline" : ""} {`, + ); + if (allocation.header) { + result.push( + `throw_unless(${contractErrors.invalidPrefix.id}, sc_0~load_uint(${allocation.header.bits}) == ${allocation.header.value});`, + ); + } + result.push(writeCellParser(allocation.root, 0, ctx)); + if (allocation.ops.length === 0) { + result.push("return (sc_0, null());"); + } else { + result.push( + `return (sc_0, (${allocation.ops.map((v) => `v'${v.name}`).join(", ")}));`, + ); + } + result.push("}"); + parse(result.join("\n")); + } +} + +export function writeOptionalParser(name: string, ctx: WriterContext) { + const parse = (code: string) => + ctx.parse(code, { context: Location.type(name) }); + parse(`tuple ${ops.readerOpt(name)}(cell cl) inline { + if (null?(cl)) { + return null(); + } + var sc = cl.begin_parse(); + return ${ops.typeAsOptional(name)}(sc~${ops.reader(name)}()); + }`); +} + +function writeCellParser( + cell: AllocationCell, + gen: number, + ctx: WriterContext, +): string { + const result: string[] = []; + + // Write current fields + for (const f of cell.ops) { + result.push(writeFieldParser(f, gen)); + } + + // Handle next cell + if (cell.next) { + result.push( + `slice sc_${gen + 1} = sc_${gen}~load_ref().begin_parse();\n`, + ); + result.push(writeCellParser(cell.next, gen + 1, ctx)); + } + + return result.join("\n"); +} + +function writeFieldParser(f: AllocationOperation, gen: number): string { + const result: string[] = []; + const op = f.op; + const varName = `var v'${f.name}`; + + switch (op.kind) { + case "int": { + if (op.optional) { + result.push( + `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_int(${op.bits}) : null();`, + ); + } else { + result.push(`${varName} = sc_${gen}~load_int(${op.bits});`); + } + return result.join("\n"); + } + case "uint": { + if (op.optional) { + result.push( + `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_uint(${op.bits}) : null();`, + ); + } else { + result.push(`${varName} = sc_${gen}~load_uint(${op.bits});`); + } + return result.join("\n"); + } + case "coins": { + if (op.optional) { + result.push( + `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_coins() : null();`, + ); + } else { + result.push(`${varName} = sc_${gen}~load_coins();`); + } + return result.join("\n"); + } + case "boolean": { + if (op.optional) { + result.push( + `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_int(1) : null();`, + ); + } else { + result.push(`${varName} = sc_${gen}~load_int(1);`); + } + return result.join("\n"); + } + case "address": { + if (op.optional) { + result.push( + `${varName} = sc_${gen}~__tact_load_address_opt();`, + ); + } else { + result.push(`${varName} = sc_${gen}~__tact_load_address();`); + } + return result.join("\n"); + } + case "cell": { + if (op.optional) { + if (op.format !== "default") { + throw new Error(`Impossible`); + } + result.push( + `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_ref() : null();`, + ); + } else { + switch (op.format) { + case "default": + { + result.push(`${varName} = sc_${gen}~load_ref();`); + } + break; + case "remainder": { + result.push( + `${varName} = begin_cell().store_slice(sc_${gen}).end_cell();`, + ); + } + } + } + return result.join("\n"); + } + case "slice": { + if (op.optional) { + if (op.format !== "default") { + throw new Error(`Impossible`); + } + result.push( + `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_ref().begin_parse() : null();`, + ); + } else { + switch (op.format) { + case "default": + { + result.push( + `${varName} = sc_${gen}~load_ref().begin_parse();`, + ); + } + break; + case "remainder": + { + result.push(`${varName} = sc_${gen};`); + } + break; + } + } + return result.join("\n"); + } + case "builder": { + if (op.optional) { + if (op.format !== "default") { + throw new Error(`Impossible`); + } + result.push( + `${varName} = sc_${gen}~load_int(1) ? begin_cell().store_slice(sc_${gen}~load_ref().begin_parse()) : null();`, + ); + } else { + switch (op.format) { + case "default": + { + result.push( + `${varName} = begin_cell().store_slice(sc_${gen}~load_ref().begin_parse());`, + ); + } + break; + case "remainder": + { + result.push( + `${varName} = begin_cell().store_slice(sc_${gen});`, + ); + } + break; + } + } + return result.join("\n"); + } + case "string": { + if (op.optional) { + result.push( + `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_ref().begin_parse() : null();`, + ); + } else { + result.push(`${varName} = sc_${gen}~load_ref().begin_parse();`); + } + return result.join("\n"); + } + case "fixed-bytes": { + if (op.optional) { + result.push( + `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_bits(${op.bytes * 8}) : null();`, + ); + } else { + result.push( + `${varName} = sc_${gen}~load_bits(${op.bytes * 8});`, + ); + } + return result.join("\n"); + } + case "map": { + result.push(`${varName} = sc_${gen}~load_dict();`); + return result.join("\n"); + } + case "struct": { + if (op.optional) { + if (op.ref) { + throw Error("Not implemented"); + } else { + result.push( + `${varName} = sc_${gen}~load_int(1) ? ${ops.typeAsOptional(op.type)}(sc_${gen}~${ops.reader(op.type)}()) : null();`, + ); + } + } else { + if (op.ref) { + throw Error("Not implemented"); + } else { + result.push( + `${varName} = sc_${gen}~${ops.reader(op.type)}();`, + ); + } + } + return result.join("\n"); + } + } +} diff --git a/src/codegen/type.ts b/src/codegen/type.ts index b0ec3b681..abb9b6332 100644 --- a/src/codegen/type.ts +++ b/src/codegen/type.ts @@ -3,6 +3,7 @@ import { TypeDescription, TypeRef } from "../types/types"; import { getType } from "../types/resolveDescriptors"; import { FuncAstType } from "../func/grammar"; import { Type, unit } from "../func/syntaxConstructors"; +import { ABITypeRef } from "@ton/core"; /** * Unpacks string representation of a user-defined Tact type from its type description. @@ -351,3 +352,113 @@ export function resolveFuncFlatTypes( // Unreachable throw Error("Unknown type: " + descriptor.kind); } + +export function resolveFuncTypeFromAbi( + ctx: CompilerContext, + fields: ABITypeRef[], +): string { + if (fields.length === 0) { + return "tuple"; + } + const res: string[] = []; + for (const f of fields) { + switch (f.kind) { + case "dict": + { + res.push("cell"); + } + break; + case "simple": { + if ( + f.type === "int" || + f.type === "uint" || + f.type === "bool" + ) { + res.push("int"); + } else if (f.type === "cell") { + res.push("cell"); + } else if (f.type === "slice") { + res.push("slice"); + } else if (f.type === "builder") { + res.push("builder"); + } else if (f.type === "address") { + res.push("slice"); + } else if (f.type === "fixed-bytes") { + res.push("slice"); + } else if (f.type === "string") { + res.push("slice"); + } else { + const t = getType(ctx, f.type); + if (t.kind !== "struct") { + throw Error("Unsupported type: " + t.kind); + } + if (f.optional ?? t.fields.length === 0) { + res.push("tuple"); + } else { + const loaded = t.fields.map((v) => v.abi.type); + res.push(resolveFuncTypeFromAbi(ctx, loaded)); + } + } + } + } + } + return `(${res.join(", ")})`; +} + +export function resolveFuncTypeFromAbiUnpack( + ctx: CompilerContext, + name: string, + fields: { name: string; type: ABITypeRef }[], +): string { + if (fields.length === 0) { + return name; + } + const res: string[] = []; + for (const f of fields) { + switch (f.type.kind) { + case "dict": + { + res.push(`${name}'${f.name}`); + } + break; + case "simple": + { + if ( + f.type.type === "int" || + f.type.type === "uint" || + f.type.type === "bool" + ) { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "cell") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "slice") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "builder") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "address") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "fixed-bytes") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "string") { + res.push(`${name}'${f.name}`); + } else { + const t = getType(ctx, f.type.type); + if (f.type.optional ?? t.fields.length === 0) { + res.push(`${name}'${f.name}`); + } else { + const loaded = t.fields.map((v) => v.abi); + res.push( + resolveFuncTypeFromAbiUnpack( + ctx, + `${name}'${f.name}`, + loaded, + ), + ); + } + } + } + break; + } + } + return `(${res.join(", ")})`; +} From 8da2062c123d24552f29b1df6f59ed211716826e Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sun, 8 Sep 2024 07:13:43 +0000 Subject: [PATCH 133/162] fix(util): `funcInitIdOf` --- src/codegen/util.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/codegen/util.ts b/src/codegen/util.ts index 10c104805..32642269f 100644 --- a/src/codegen/util.ts +++ b/src/codegen/util.ts @@ -86,5 +86,7 @@ export function funcIdOf(ident: AstId | string): string { return typeof ident === "string" ? `$${ident}` : `$${idText(ident)}`; } export function funcInitIdOf(ident: AstId | string): string { - return typeof ident === "string" ? `$${ident}` : `$init`; + return typeof ident === "string" + ? `${ident}$init` + : idText(ident) + "$init"; } From dc3af50ddcb69bc7f62d5753aa5ed1fc8720629b Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sun, 8 Sep 2024 07:13:59 +0000 Subject: [PATCH 134/162] feat(codegen): Init serializers --- src/codegen/module.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index c45a32263..85b396cd8 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -183,8 +183,24 @@ export class ModuleGen { } } - private addInitSerializer(_m: FuncAstModule): void { - // TODO + private addInitSerializer(sortedTypes: TypeDescription[]): void { + for (const t of sortedTypes) { + if (t.kind === "contract" && t.init) { + const allocation = getAllocation(this.ctx.ctx, funcInitIdOf(t.name)); + writeSerializer( + funcInitIdOf(t.name), + true, + allocation, + this.ctx, + ); + writeParser( + funcInitIdOf(t.name), + false, + allocation, + this.ctx, + ); + } + } } private addStorageFunctions(_m: FuncAstModule): void { @@ -1491,7 +1507,7 @@ export class ModuleGen { this.addSerializers(sortedTypes); this.addAccessors(allTypes); - this.addInitSerializer(m); + this.addInitSerializer(sortedTypes); this.addStorageFunctions(m); this.addStaticFunctions(m); this.addExtensions(m); From 5e5a5b83fd78f75b93a1c46a6e48faaba053126d Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sun, 8 Sep 2024 07:32:43 +0000 Subject: [PATCH 135/162] feat(codegen): Storage functions --- src/codegen/module.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 85b396cd8..49571acb8 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -8,6 +8,7 @@ import { TypeRef, FunctionDescription, } from "../types/types"; +import {writeStorageOps} from "./storage"; import { writeBouncedParser, writeOptionalParser, @@ -203,8 +204,12 @@ export class ModuleGen { } } - private addStorageFunctions(_m: FuncAstModule): void { - // TODO + private addStorageFunctions(sortedTypes: TypeDescription[]): void { + for (const t of sortedTypes) { + if (t.kind === "contract") { + writeStorageOps(t, this.ctx); + } + } } private addStaticFunctions(_m: FuncAstModule): void { @@ -1508,7 +1513,7 @@ export class ModuleGen { this.addSerializers(sortedTypes); this.addAccessors(allTypes); this.addInitSerializer(sortedTypes); - this.addStorageFunctions(m); + this.addStorageFunctions(sortedTypes); this.addStaticFunctions(m); this.addExtensions(m); contracts.forEach((c) => this.addContractFunctions(m, c)); From 10bbf30cd6b86f532f1bb6c2ad23669307154f21 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sun, 8 Sep 2024 12:35:46 +0000 Subject: [PATCH 136/162] feat(codegen): Add static functions --- src/codegen/function.ts | 88 ++++++++++++++++++++++++++++------------- src/codegen/literal.ts | 9 +---- src/codegen/module.ts | 61 ++++++++++++++++------------ 3 files changed, 97 insertions(+), 61 deletions(-) diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 893cb43b6..0196dc10a 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -1,6 +1,7 @@ import { enabledInline } from "../config/features"; import { getType, resolveTypeRef } from "../types/resolveDescriptors"; import { ops, funcIdOf } from "./util"; +import { FuncPrettyPrinter } from "../func/prettyPrinter"; import { TypeDescription, FunctionDescription, TypeRef } from "../types/types"; import { FuncAstFunctionDefinition, @@ -9,6 +10,7 @@ import { FuncAstExpression, FuncAstType, } from "../func/grammar"; +import { idText, AstNativeFunctionDecl } from "../grammar/ast"; import { id, call, @@ -89,29 +91,32 @@ export class FunctionGen { throw Error(`Unknown type: ${descriptor.kind}`); } - /** - * Generates Func function from the Tact funciton description. - */ - public writeFunction( - tactFun: FunctionDescription, - ): FuncAstFunctionDefinition { - if (tactFun.ast.kind !== "function_def") { - throw new Error(`Unknown function kind: ${tactFun.ast.kind}`); + public writeNativeFunction(f: FunctionDescription): void | never { + if (f.ast.kind !== "native_function_decl") { + throw new Error(`Unsupported function kind: ${f.ast.kind}`); } - - let returnTy = resolveFuncType(this.ctx.ctx, tactFun.returns); - // let returnsStr: string | null; - const self: TypeDescription | undefined = tactFun.self - ? getType(this.ctx.ctx, tactFun.self) - : undefined; - if (self !== undefined && tactFun.isMutating) { - // Add `self` to the method signature as it is mutating in the body. - const selfTy = resolveFuncType(this.ctx.ctx, self); - returnTy = Type.tensor(selfTy, returnTy); - // returnsStr = resolveFuncTypeUnpack(ctx, self, funcIdOf("self")); + if (f.isMutating) { + const nonMutName = ops.nonModifying(idText(f.ast.nativeName)); + const returns = new FuncPrettyPrinter().prettyPrintType( + resolveFuncType(this.ctx.ctx, f.returns), + ); + const params = this.getFunParams(f); + const code = ` + ${returns} ${nonMutName}(${params.join(", ")}) impure ${enabledInline(this.ctx.ctx) || f.isInline ? "inline" : ""} { + return ${funcIdOf("self")}~${idText((f.ast as AstNativeFunctionDecl).nativeName)}(${f.ast.params + .slice(1) + .map((arg) => funcIdOf(arg.name)) + .join(", ")}); + }`; + f.origin === "stdlib" + ? this.ctx.parse(code, { context: Location.stdlib() }) + : this.ctx.parse(code); } + } - const params: [string, FuncAstType][] = tactFun.params.reduce( + private getFunParams(f: FunctionDescription): [string, FuncAstType][] { + const self = this.getSelf(f); + return f.params.reduce( (acc, a) => { acc.push([ funcIdOf(a.name), @@ -123,16 +128,43 @@ export class FunctionGen { ? [[funcIdOf("self"), resolveFuncType(this.ctx.ctx, self)]] : [], ); + } + + private getSelf(f: FunctionDescription): TypeDescription | undefined { + return f.self ? getType(this.ctx.ctx, f.self) : undefined; + } + + /** + * Generates Func function from the Tact funciton description. + * + * @return The generated function or `undefined` if no function was generated. + */ + public writeFunction( + f: FunctionDescription, + ): FuncAstFunctionDefinition | never { + let returnTy = resolveFuncType(this.ctx.ctx, f.returns); + const self = this.getSelf(f); + if (self !== undefined && f.isMutating) { + // Add `self` to the method signature as it is mutating in the body. + const selfTy = resolveFuncType(this.ctx.ctx, self); + returnTy = Type.tensor(selfTy, returnTy); + } + + const params: [string, FuncAstType][] = this.getFunParams(f); + + if (f.ast.kind !== "function_def") { + throw new Error(`Unknown function kind: ${f.ast.kind}`); + } // TODO: handle native functions delcs. should be in a separatre funciton const name = self - ? ops.extension(self.name, tactFun.name) - : ops.global(tactFun.name); + ? ops.extension(self.name, f.name) + : ops.global(f.name); // Prepare function attributes let attrs: FuncAstFunctionAttribute[] = [FunAttr.impure()]; - if (enabledInline(this.ctx.ctx) || tactFun.isInline) { + if (enabledInline(this.ctx.ctx) || f.isInline) { attrs.push(FunAttr.inline()); } // TODO: handle stdlib @@ -151,9 +183,9 @@ export class FunctionGen { funcIdOf("self"), ); const init: FuncAstExpression = id(funcIdOf("self")); - body.push(vardef('_', varName, init)); + body.push(vardef("_", varName, init)); } - for (const a of tactFun.ast.params) { + for (const a of f.ast.params) { if ( !this.resolveFuncPrimitive(resolveTypeRef(this.ctx.ctx, a.type)) ) { @@ -163,7 +195,7 @@ export class FunctionGen { funcIdOf(a.name), ); const init: FuncAstExpression = id(funcIdOf(a.name)); - body.push(vardef('_', name, init)); + body.push(vardef("_", name, init)); } } @@ -172,12 +204,12 @@ export class FunctionGen { ? resolveFuncTypeUnpack(this.ctx.ctx, self, funcIdOf("self")) : undefined; // Process statements - tactFun.ast.statements.forEach((stmt) => { + f.ast.statements.forEach((stmt) => { const funcStmt = StatementGen.fromTact( this.ctx, stmt, selfName, - tactFun.returns, + f.returns, ).writeStatement(); body.push(funcStmt); }); diff --git a/src/codegen/literal.ts b/src/codegen/literal.ts index fb839793f..b5e1755e4 100644 --- a/src/codegen/literal.ts +++ b/src/codegen/literal.ts @@ -2,14 +2,7 @@ import { WriterContext, FunctionGen, Location } from "."; import { FuncAstExpression } from "../func/grammar"; import { Address, beginCell, Cell } from "@ton/core"; import { Value, CommentValue } from "../types/types"; -import { - call, - Type, - int, - id, - nil, - bool, -} from "../func/syntaxConstructors"; +import { call, Type, int, id, nil, bool } from "../func/syntaxConstructors"; import { getType } from "../types/resolveDescriptors"; import JSONbig from "json-bigint"; diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 49571acb8..c78d8f177 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -1,4 +1,9 @@ -import { getAllTypes, getType, toBounced } from "../types/resolveDescriptors"; +import { + getAllTypes, + getAllStaticFunctions, + getType, + toBounced, +} from "../types/resolveDescriptors"; import { enabledInline } from "../config/features"; import { LiteralGen, Location } from "."; import { @@ -8,7 +13,7 @@ import { TypeRef, FunctionDescription, } from "../types/types"; -import {writeStorageOps} from "./storage"; +import { writeStorageOps } from "./storage"; import { writeBouncedParser, writeOptionalParser, @@ -185,35 +190,41 @@ export class ModuleGen { } private addInitSerializer(sortedTypes: TypeDescription[]): void { - for (const t of sortedTypes) { - if (t.kind === "contract" && t.init) { - const allocation = getAllocation(this.ctx.ctx, funcInitIdOf(t.name)); - writeSerializer( - funcInitIdOf(t.name), - true, - allocation, - this.ctx, - ); - writeParser( - funcInitIdOf(t.name), - false, - allocation, - this.ctx, - ); + for (const t of sortedTypes) { + if (t.kind === "contract" && t.init) { + const allocation = getAllocation( + this.ctx.ctx, + funcInitIdOf(t.name), + ); + writeSerializer( + funcInitIdOf(t.name), + true, + allocation, + this.ctx, + ); + writeParser(funcInitIdOf(t.name), false, allocation, this.ctx); + } } } - } private addStorageFunctions(sortedTypes: TypeDescription[]): void { - for (const t of sortedTypes) { - if (t.kind === "contract") { - writeStorageOps(t, this.ctx); + for (const t of sortedTypes) { + if (t.kind === "contract") { + writeStorageOps(t, this.ctx); + } } } - } - private addStaticFunctions(_m: FuncAstModule): void { - // TODO + private addStaticFunctions(): void { + const sf = getAllStaticFunctions(this.ctx.ctx); + Object.values(sf).forEach((f) => { + const gen = FunctionGen.fromTact(this.ctx); + if (f.ast.kind === "native_function_decl") { + gen.writeNativeFunction(f); + } else { + gen.writeFunction(f); + } + }); } private addExtensions(_m: FuncAstModule): void { @@ -1514,7 +1525,7 @@ export class ModuleGen { this.addAccessors(allTypes); this.addInitSerializer(sortedTypes); this.addStorageFunctions(sortedTypes); - this.addStaticFunctions(m); + this.addStaticFunctions(); this.addExtensions(m); contracts.forEach((c) => this.addContractFunctions(m, c)); this.writeMainContract(m, contract); From 77d12b0005590fd33560ec9f22095db46933c1c1 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sun, 8 Sep 2024 12:35:58 +0000 Subject: [PATCH 137/162] chore(codegen): Add missing file --- src/codegen/storage.ts | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/codegen/storage.ts diff --git a/src/codegen/storage.ts b/src/codegen/storage.ts new file mode 100644 index 000000000..914a54e1d --- /dev/null +++ b/src/codegen/storage.ts @@ -0,0 +1,67 @@ +import { contractErrors } from "../abi/errors"; +import { enabledMasterchain } from "../config/features"; +import { TypeDescription } from "../types/types"; +import { WriterContext, Location } from "./context"; +import { FuncPrettyPrinter } from "../func/prettyPrinter"; +import { FuncAstType } from "../func/grammar"; +import { funcIdOf, funcInitIdOf, ops } from "./util"; +import { resolveFuncType } from "./type"; + +export function writeStorageOps(type: TypeDescription, ctx: WriterContext) { + const parse = (code: string) => + ctx.parse(code, { context: Location.type(`${type.name}$init`) }); + const ppty = (ty: FuncAstType): string => + new FuncPrettyPrinter().prettyPrintType(ty); + + // Load function + parse(`${ppty(resolveFuncType(ctx.ctx, type))} ${ops.contractLoad(type.name)}() impure { + slice $sc = get_data().begin_parse(); + + ;; Load context + __tact_context_sys = $sc~load_ref(); + int $loaded = $sc~load_int(1); + + ;; Load data + if ($loaded) { + ${type.fields.length > 0 ? `return $sc~${ops.reader(type.name)}();` : `return null();`} + } else { + ${ + !enabledMasterchain(ctx.ctx) + ? ` + ;; Allow only workchain deployments + throw_unless(${contractErrors.masterchainNotEnabled.id}, my_address().preload_uint(11) == 1024); + ` + : "" + } + + ${ + type.init!.params.length > 0 + ? ` + (${type.init!.params.map((v) => ppty(resolveFuncType(ctx.ctx, v.type)) + " " + funcIdOf(v.name)).join(", ")}) = $sc~${ops.reader(funcInitIdOf(type.name))}(); + $sc.end_parse(); + ` + : "" + } + + return ${ops.contractInit(type.name)}(${[...type.init!.params.map((v) => funcIdOf(v.name))].join(", ")}); + } + }`); + + // Store function + parse(`() ${ops.contractStore(type.name)}(${ppty(resolveFuncType(ctx.ctx, type))} v) impure inline { + builder b = begin_cell(); + + ;; Persist system cell + b = b.store_ref(__tact_context_sys); + + ;; Persist deployment flag + b = b.store_int(true, 1); + + ;; Build data + ${type.fields.length > 0 ? `b = ${ops.writer(type.name)}(b, v);` : ""} + + ;; Persist data + set_data(b.end_cell()); + } +`); +} From 3bfc322bd884c6c8c6174ff1dc7840833a5e58f1 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sun, 8 Sep 2024 12:46:06 +0000 Subject: [PATCH 138/162] feat(codegen): Support extensions --- src/codegen/function.ts | 23 ++++++++++++++++++----- src/codegen/module.ts | 22 +++++++++++++--------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 0196dc10a..196f05625 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -96,13 +96,13 @@ export class FunctionGen { throw new Error(`Unsupported function kind: ${f.ast.kind}`); } if (f.isMutating) { + const ppty = (ty: FuncAstType): string => + new FuncPrettyPrinter().prettyPrintType(ty); const nonMutName = ops.nonModifying(idText(f.ast.nativeName)); - const returns = new FuncPrettyPrinter().prettyPrintType( - resolveFuncType(this.ctx.ctx, f.returns), - ); + const returns = ppty(resolveFuncType(this.ctx.ctx, f.returns)); const params = this.getFunParams(f); const code = ` - ${returns} ${nonMutName}(${params.join(", ")}) impure ${enabledInline(this.ctx.ctx) || f.isInline ? "inline" : ""} { + ${returns} ${nonMutName}(${params.map(([name, ty]) => `${ppty(ty)} ${name}`).join(", ")}) impure ${enabledInline(this.ctx.ctx) || f.isInline ? "inline" : ""} { return ${funcIdOf("self")}~${idText((f.ast as AstNativeFunctionDecl).nativeName)}(${f.ast.params .slice(1) .map((arg) => funcIdOf(arg.name)) @@ -139,7 +139,7 @@ export class FunctionGen { * * @return The generated function or `undefined` if no function was generated. */ - public writeFunction( + public writeFunctionDefinition( f: FunctionDescription, ): FuncAstFunctionDefinition | never { let returnTy = resolveFuncType(this.ctx.ctx, f.returns); @@ -217,6 +217,19 @@ export class FunctionGen { return this.ctx.fun(attrs, name, params, returnTy, body); } + public writeFunction(f: FunctionDescription): void | never { + switch (f.ast.kind) { + case "native_function_decl": + this.writeNativeFunction(f); + return; + case "function_def": + this.writeFunctionDefinition(f); + return; + default: + throw new Error(`Unsupported function kind: ${f.ast.kind}`); + } + } + /** * Creates a Func function that represents a constructor for the Tact struct, e.g.: * ``` diff --git a/src/codegen/module.ts b/src/codegen/module.ts index c78d8f177..112517a15 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -219,16 +219,20 @@ export class ModuleGen { const sf = getAllStaticFunctions(this.ctx.ctx); Object.values(sf).forEach((f) => { const gen = FunctionGen.fromTact(this.ctx); - if (f.ast.kind === "native_function_decl") { - gen.writeNativeFunction(f); - } else { - gen.writeFunction(f); - } + gen.writeFunction(f); }); } - private addExtensions(_m: FuncAstModule): void { - // TODO + private addExtensions(allTypes: TypeDescription[]): void { + for (const c of allTypes) { + if (c.kind !== "contract" && c.kind !== "trait") { + // We are rendering contract functions separately + for (const f of c.functions.values()) { + const gen = FunctionGen.fromTact(this.ctx); + gen.writeFunction(f); + } + } + } } /** @@ -516,7 +520,7 @@ export class ModuleGen { } for (const tactFun of c.functions.values()) { - const funcFun = FunctionGen.fromTact(this.ctx).writeFunction( + const funcFun = FunctionGen.fromTact(this.ctx).writeFunctionDefinition( tactFun, ); // TODO: Should we really put them here? @@ -1526,7 +1530,7 @@ export class ModuleGen { this.addInitSerializer(sortedTypes); this.addStorageFunctions(sortedTypes); this.addStaticFunctions(); - this.addExtensions(m); + this.addExtensions(allTypes); contracts.forEach((c) => this.addContractFunctions(m, c)); this.writeMainContract(m, contract); From dfa9013cbc60bab82714afc5b62c55ddc262ca38 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 9 Sep 2024 12:38:51 +0000 Subject: [PATCH 139/162] feat(grammar): Support `try {} catch (_) {}` --- src/func/grammar.ts | 16 ++++++++++++---- src/func/prettyPrinter.ts | 10 ++++++++-- src/func/syntaxConstructors.ts | 19 +++++++++++++++---- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/func/grammar.ts b/src/func/grammar.ts index cd58a80ba..a5bb23dc1 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -883,14 +883,20 @@ export type FuncAstStatementWhile = { loc: FuncSrcInfo; }; +/** (id, id) */ +export type FuncCatchDefintions = { + exceptionName: FuncAstId; + exitCodeName: FuncAstId; +}; + /** * try { ... } catch (id, id) { ... } + * try { ... } catch (_) { ... } */ export type FuncAstStatementTryCatch = { kind: "statement_try_catch"; statementsTry: FuncAstStatement[]; - catchExceptionName: FuncAstId; - catchExitCodeName: FuncAstId; + catchDefinitions: FuncCatchDefintions | "_"; statementsCatch: FuncAstStatement[]; loc: FuncSrcInfo; }; @@ -1735,8 +1741,10 @@ semantics.addOperation("astOfStatement", { return { kind: "statement_try_catch", statementsTry: stmtsTry.children.map((x) => x.astOfStatement()), - catchExceptionName: exceptionName.astOfExpression(), - catchExitCodeName: exitCodeName.astOfExpression(), + catchDefinitions: { + exceptionName: exceptionName.astOfExpression(), + exitCodeName: exitCodeName.astOfExpression(), + }, statementsCatch: stmtsCatch.children.map((x) => x.astOfStatement()), loc: createSrcInfo(this), }; diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index 67882dbe3..8156c0ce5 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -462,11 +462,17 @@ export class FuncPrettyPrinter { const tryBlock = this.prettyPrintIndentedBlock( node.statementsTry.map(this.prettyPrint.bind(this)).join("\n"), ); + const catchStr = + node.catchDefinitions === "_" + ? "_" + : [ + this.prettyPrint(node.catchDefinitions.exceptionName), + this.prettyPrint(node.catchDefinitions.exitCodeName), + ].join(", "); const catchBlock = this.prettyPrintIndentedBlock( node.statementsCatch.map(this.prettyPrint.bind(this)).join("\n"), ); - const catchVar = `${this.prettyPrint(node.catchExceptionName)}, ${this.prettyPrint(node.catchExitCodeName)}`; - return `try {\n${tryBlock}\n} catch (${catchVar}) {\n${catchBlock}\n}`; + return `try {\n${tryBlock}\n} catch (${catchStr}) {\n${catchBlock}\n}`; } private prettyPrintStatementExpression( diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index b04f84651..1a79d47e3 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -52,6 +52,7 @@ import { FuncAstModuleItem, FuncAstModule, FuncAstGlobalVariablesDeclaration, + FuncCatchDefintions, dummySrcInfo, } from "./grammar"; import { dummySrcInfo as tactDummySrcInfo } from "../grammar/grammar"; @@ -476,17 +477,27 @@ export function expr( }; } +export function try_( + statementsTry: FuncAstStatement[], +): FuncAstStatementTryCatch { + return { + kind: "statement_try_catch", + statementsTry, + catchDefinitions: "_", + statementsCatch: [], + loc: dummySrcInfo, + }; +} + export function tryCatch( statementsTry: FuncAstStatement[], - catchExceptionName: string | FuncAstId, - catchExitCodeName: string | FuncAstId, + catchDefinitions: "_" | FuncCatchDefintions, statementsCatch: FuncAstStatement[], ): FuncAstStatementTryCatch { return { kind: "statement_try_catch", statementsTry, - catchExceptionName: wrapToId(catchExceptionName), - catchExitCodeName: wrapToId(catchExitCodeName), + catchDefinitions, statementsCatch, loc: dummySrcInfo, }; From 9c46edd7a3ef7349e2c30990799beb77da1a9928 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Mon, 9 Sep 2024 12:39:10 +0000 Subject: [PATCH 140/162] feat(codegen): Support all the statements --- src/codegen/function.ts | 4 +- src/codegen/module.ts | 16 +- src/codegen/statement.ts | 783 ++++++++++++++++++++------------------- src/codegen/util.ts | 7 + 4 files changed, 426 insertions(+), 384 deletions(-) diff --git a/src/codegen/function.ts b/src/codegen/function.ts index 196f05625..ff78b1034 100644 --- a/src/codegen/function.ts +++ b/src/codegen/function.ts @@ -205,13 +205,13 @@ export class FunctionGen { : undefined; // Process statements f.ast.statements.forEach((stmt) => { - const funcStmt = StatementGen.fromTact( + const funcStmts = StatementGen.fromTact( this.ctx, stmt, selfName, f.returns, ).writeStatement(); - body.push(funcStmt); + body.push(...funcStmts); }); return this.ctx.fun(attrs, name, params, returnTy, body); diff --git a/src/codegen/module.ts b/src/codegen/module.ts index 112517a15..3f87c9afc 100644 --- a/src/codegen/module.ts +++ b/src/codegen/module.ts @@ -333,7 +333,7 @@ export class ModuleGen { ); for (const s of init.ast.statements) { body.push( - StatementGen.fromTact( + ...StatementGen.fromTact( this.ctx, s, returns, @@ -941,7 +941,7 @@ export class ModuleGen { ); f.ast.statements.forEach((s) => body.push( - StatementGen.fromTact( + ...StatementGen.fromTact( this.ctx, s, selfRes, @@ -978,7 +978,7 @@ export class ModuleGen { const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( - StatementGen.fromTact( + ...StatementGen.fromTact( this.ctx, s, selfRes, @@ -1017,7 +1017,7 @@ export class ModuleGen { const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( - StatementGen.fromTact( + ...StatementGen.fromTact( this.ctx, s, selfRes, @@ -1059,7 +1059,7 @@ export class ModuleGen { const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( - StatementGen.fromTact( + ...StatementGen.fromTact( this.ctx, s, selfRes, @@ -1093,7 +1093,7 @@ export class ModuleGen { const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( - StatementGen.fromTact( + ...StatementGen.fromTact( this.ctx, s, selfRes, @@ -1127,7 +1127,7 @@ export class ModuleGen { const body: FuncAstStatement[] = [selfUnpack]; f.ast.statements.forEach((s) => body.push( - StatementGen.fromTact( + ...StatementGen.fromTact( this.ctx, s, selfRes, @@ -1181,7 +1181,7 @@ export class ModuleGen { ); f.ast.statements.forEach((s) => body.push( - StatementGen.fromTact( + ...StatementGen.fromTact( this.ctx, s, selfRes, diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts index 5b87e95e9..b70cd09e3 100644 --- a/src/codegen/statement.ts +++ b/src/codegen/statement.ts @@ -1,10 +1,20 @@ import { throwInternalCompilerError } from "../errors"; -import { funcIdOf } from "./util"; +import { funcIdOf, cast, ops, freshIdentifier } from "./util"; import { getType, resolveTypeRef } from "../types/resolveDescriptors"; import { getExpType } from "../types/resolveExpression"; import { TypeRef } from "../types/types"; import { AstCondition, + AstStatementReturn, + AstStatementUntil, + AstStatementRepeat, + AstStatementTryCatch, + AstStatementTry, + AstStatementWhile, + AstStatementForEach, + AstStatementAugmentedAssign, + AstStatementAssign, + AstStatementLet, AstExpression, AstStatement, isWildcard, @@ -16,15 +26,24 @@ import { FuncAstStatement, FuncAstStatementCondition, FuncAstExpression, + FuncCatchDefintions, } from "../func/grammar"; import { id, expr, + call, ret, + while_, + try_, + doUntil, + int, + repeat, + augassign, tensor, assign, unit, condition, + tryCatch, conditionElseif, vardef, Type, @@ -62,7 +81,7 @@ export class StatementGen { return ExpressionGen.fromTact(this.ctx, expr).writeExpression(); } - private makeCastedExpr( + private writeCastedExpr( expr: AstExpression, to: TypeRef, ): FuncAstExpression { @@ -81,14 +100,14 @@ export class StatementGen { this.returns, ).writeStatement(); const cond = this.makeExpr(f.condition); - const thenBlock = f.trueStatements.map(writeStmt); - const elseBlock = f.falseStatements?.map(writeStmt); + const thenBlock = f.trueStatements.map(writeStmt).flat(); + const elseBlock = f.falseStatements?.map(writeStmt).flat(); if (f.elseif) { return conditionElseif( cond, thenBlock, this.makeExpr(f.elseif.condition), - f.elseif.trueStatements.map(writeStmt), + f.elseif.trueStatements.map(writeStmt).flat(), elseBlock, ); } else { @@ -96,392 +115,408 @@ export class StatementGen { } } - public writeStatement(): FuncAstStatement { + public writeStatement(): FuncAstStatement[] | never { switch (this.tactStmt.kind) { case "statement_return": { - const selfVar = this.selfName ? id(this.selfName) : undefined; - const getValue = ( - expr: FuncAstExpression, - ): FuncAstExpression => - this.selfName ? tensor(selfVar!, expr) : expr; - if (this.tactStmt.expression) { - const castedReturns = this.makeCastedExpr( - this.tactStmt.expression, - this.returns!, - ); - return ret(getValue(castedReturns)); - } else { - return ret(getValue(unit())); - } + return [this.writeReturnStatement(this.tactStmt)]; } case "statement_let": { - // Underscore name case - if (isWildcard(this.tactStmt.name)) { - return expr(this.makeExpr(this.tactStmt.expression)); - } + return [this.writeLetStatement(this.tactStmt)]; + } + case "statement_assign": { + return [this.writeAssignStatement(this.tactStmt)]; + } + case "statement_augmentedassign": { + return [this.writeAugmentedAssignStatement(this.tactStmt)]; + } + case "statement_condition": { + return [this.writeCondition(this.tactStmt)]; + } + case "statement_expression": { + return [expr(this.makeExpr(this.tactStmt.expression))]; + } + case "statement_while": { + return [this.writeWhileStatement(this.tactStmt)]; + } + case "statement_until": { + return [this.writeUntilStatement(this.tactStmt)]; + } + case "statement_repeat": { + return [this.writeRepeatStatement(this.tactStmt)]; + } + case "statement_try": { + return [this.writeTryStatement(this.tactStmt)]; + } + case "statement_try_catch": { + return [this.writeTryCatchStatement(this.tactStmt)]; + } + case "statement_foreach": { + return this.writeForeachStatement(this.tactStmt); + } + default: { + throw Error(`Unknown statement: ${this.tactStmt}`); + } + } + } - // Contract/struct case - const t = - this.tactStmt.type === null - ? getExpType(this.ctx.ctx, this.tactStmt.expression) - : resolveTypeRef(this.ctx.ctx, this.tactStmt.type); + private writeReturnStatement(stmt: AstStatementReturn): FuncAstStatement { + const selfVar = this.selfName ? id(this.selfName) : undefined; + const getValue = (expr: FuncAstExpression): FuncAstExpression => + this.selfName ? tensor(selfVar!, expr) : expr; - if (t.kind === "ref") { - const tt = getType(this.ctx.ctx, t.name); - if (tt.kind === "contract" || tt.kind === "struct") { - if (t.optional) { - const name = funcIdOf(this.tactStmt.name); - const init = this.makeCastedExpr( - this.tactStmt.expression, - t, - ); - return vardef(Type.tuple(), name, init); - } else { - const name = resolveFuncTypeUnpack( - this.ctx.ctx, - t, - funcIdOf(this.tactStmt.name), - ); - const init = this.makeCastedExpr( - this.tactStmt.expression, - t, - ); - return vardef("_", name, init); - } - } - } + if (stmt.expression) { + const castedReturns = this.writeCastedExpr( + stmt.expression, + this.returns!, + ); + return ret(getValue(castedReturns)); + } else { + return ret(getValue(unit())); + } + } - const ty = resolveFuncType(this.ctx.ctx, t); - const name = funcIdOf(this.tactStmt.name); - const init = this.makeCastedExpr(this.tactStmt.expression, t); - return vardef(ty, name, init); - } + private writeLetStatement(stmt: AstStatementLet): FuncAstStatement { + // Underscore name case + if (isWildcard(stmt.name)) { + return expr(this.makeExpr(stmt.expression)); + } - case "statement_assign": { - // Prepare lvalue - const lvaluePath = tryExtractPath(this.tactStmt.path); - if (lvaluePath === null) { - // typechecker is supposed to catch this - throwInternalCompilerError( - `Assignments are allowed only into path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, - this.tactStmt.path.loc, + // Contract/struct case + const t = + stmt.type === null + ? getExpType(this.ctx.ctx, stmt.expression) + : resolveTypeRef(this.ctx.ctx, stmt.type); + + if (t.kind === "ref") { + const tt = getType(this.ctx.ctx, t.name); + if (tt.kind === "contract" || tt.kind === "struct") { + if (t.optional) { + const name = funcIdOf(stmt.name); + const init = this.writeCastedExpr(stmt.expression, t); + return vardef(Type.tuple(), name, init); + } else { + const name = resolveFuncTypeUnpack( + this.ctx.ctx, + t, + funcIdOf(stmt.name), ); + const init = this.writeCastedExpr(stmt.expression, t); + return vardef("_", name, init); } - const path = writePathExpression(lvaluePath); + } + } - // Contract/struct case - const t = getExpType(this.ctx.ctx, this.tactStmt.path); - if (t.kind === "ref") { - const tt = getType(this.ctx.ctx, t.name); - if (tt.kind === "contract" || tt.kind === "struct") { - const lhs = id( - resolveFuncTypeUnpack(this.ctx.ctx, t, path.value), - ); - const rhs = this.makeCastedExpr( - this.tactStmt.expression, - t, - ); - return expr(assign(lhs, rhs)); - } - } + const ty = resolveFuncType(this.ctx.ctx, t); + const name = funcIdOf(stmt.name); + const init = this.writeCastedExpr(stmt.expression, t); + return vardef(ty, name, init); + } - const rhs = this.makeCastedExpr(this.tactStmt.expression, t); - return expr(assign(path, rhs)); + private writeAssignStatement(stmt: AstStatementAssign): FuncAstStatement { + const lvaluePath = tryExtractPath(stmt.path); + if (lvaluePath === null) { + throwInternalCompilerError( + [ + `Assignments are allowed only into path expressions, i.e. identifiers, or sequences`, + `of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + ].join(" "), + stmt.path.loc, + ); + } + const path = writePathExpression(lvaluePath); + const t = getExpType(this.ctx.ctx, stmt.path); + if (t.kind === "ref") { + const tt = getType(this.ctx.ctx, t.name); + if (tt.kind === "contract" || tt.kind === "struct") { + const lhs = id( + resolveFuncTypeUnpack(this.ctx.ctx, t, path.value), + ); + const rhs = this.writeCastedExpr(stmt.expression, t); + return expr(assign(lhs, rhs)); } + } + const rhs = this.writeCastedExpr(stmt.expression, t); + return expr(assign(path, rhs)); + } - // case "statement_augmentedassign": { - // const lvaluePath = tryExtractPath(f.path); - // if (lvaluePath === null) { - // // typechecker is supposed to catch this - // throwInternalCompilerError( - // `Assignments are allowed only into path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, - // f.path.loc, - // ); - // } - // const path = writePathExpression(lvaluePath); - // const t = getExpType(ctx.ctx, f.path); - // ctx.append( - // `${path} = ${cast(t, t, `${path} ${f.op} ${writeExpression(f.expression, ctx)}`, ctx)};`, - // ); - // return; - // } - case "statement_condition": { - return this.writeCondition(this.tactStmt); + private writeAugmentedAssignStatement( + stmt: AstStatementAugmentedAssign, + ): FuncAstStatement { + const lvaluePath = tryExtractPath(stmt.path); + if (lvaluePath === null) { + throwInternalCompilerError( + [ + `Assignments are allowed only into path expressions, i.e. identifiers, or sequences`, + `of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + ].join(" "), + stmt.path.loc, + ); + } + const path = writePathExpression(lvaluePath); + const t = getExpType(this.ctx.ctx, stmt.path); + return expr( + assign( + path, + cast( + this.ctx.ctx, + t, + t, + augassign( + path, + `${stmt.op}=`, + this.makeExpr(stmt.expression), + ), + ), + ), + ); + } + + private writeWhileStatement(stmt: AstStatementWhile): FuncAstStatement { + const condition = this.makeExpr(stmt.condition); + const body = stmt.statements + .map((s) => + StatementGen.fromTact( + this.ctx, + s, + this.selfName, + this.returns, + ).writeStatement(), + ) + .flat(); + return while_(condition, body); + } + + private writeUntilStatement(stmt: AstStatementUntil): FuncAstStatement { + const condition = this.makeExpr(stmt.condition); + const body = stmt.statements + .map((s) => + StatementGen.fromTact( + this.ctx, + s, + this.selfName, + this.returns, + ).writeStatement(), + ) + .flat(); + return doUntil(condition, body); + } + + private writeRepeatStatement(stmt: AstStatementRepeat): FuncAstStatement { + const iterations = this.makeExpr(stmt.iterations); + const body = stmt.statements + .map((s) => + StatementGen.fromTact( + this.ctx, + s, + this.selfName, + this.returns, + ).writeStatement(), + ) + .flat(); + return repeat(iterations, body); + } + + private writeTryStatement(stmt: AstStatementTry): FuncAstStatement { + const body = stmt.statements + .map((s) => + StatementGen.fromTact( + this.ctx, + s, + this.selfName, + this.returns, + ).writeStatement(), + ) + .flat(); + return try_(body); + } + + private writeTryCatchStatement( + stmt: AstStatementTryCatch, + ): FuncAstStatement { + const generateStatements = (statements: any[]) => + statements + .map((s) => + StatementGen.fromTact( + this.ctx, + s, + this.selfName, + this.returns, + ).writeStatement(), + ) + .flat(); + const body = generateStatements(stmt.statements); + const catchStmts = generateStatements(stmt.catchStatements); + const catchNames: "_" | FuncCatchDefintions = isWildcard(stmt.catchName) + ? "_" + : ({ + exceptionName: id("_"), + exitCodeName: id(funcIdOf(stmt.catchName)), + } as FuncCatchDefintions); + return tryCatch(body, catchNames, catchStmts); + } + + private writeForeachStatement( + stmt: AstStatementForEach, + ): FuncAstStatement[] { + const mapPath = tryExtractPath(stmt.map); + if (mapPath === null) { + throwInternalCompilerError( + [ + "foreach is only allowed over maps that are path expressions, i.e. identifiers, or sequences", + `of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + ].join(" "), + stmt.map.loc, + ); + } + const path = writePathExpression(mapPath); + const t = getExpType(this.ctx.ctx, stmt.map); + if (t.kind !== "map") { + throw Error("Unknown map type"); + } + const flag = freshIdentifier("flag"); + const key = isWildcard(stmt.keyName) + ? freshIdentifier("underscore") + : funcIdOf(stmt.keyName); + const value = isWildcard(stmt.valueName) + ? freshIdentifier("underscore") + : funcIdOf(stmt.valueName); + + // Handle Int key + if (t.key === "Int") { + // Generates FunC code for non-struct values + const generatePrimitive = ( + varFun: FuncAstExpression, + funcall: FuncAstExpression, + ): FuncAstStatement[] => { + let whileBody: FuncAstStatement[] = []; + for (const s of stmt.statements) { + whileBody = whileBody.concat( + StatementGen.fromTact( + this.ctx, + s, + this.selfName, + this.returns, + ).writeStatement(), + ); + } + whileBody.push( + expr(assign(tensor(id(key), id(value), id(flag)), funcall)), + ); + return [ + vardef("_", [key, value, flag], varFun), + while_(id(flag), whileBody), + ]; + }; + let bits = 257; + let kind = "int"; + if (t.keyAs?.startsWith("int")) { + bits = parseInt(t.keyAs.slice(3), 10); + } else if (t.keyAs?.startsWith("uint")) { + bits = parseInt(t.keyAs.slice(4), 10); + kind = "uint"; } - case "statement_expression": { - return expr(this.makeExpr(this.tactStmt.expression)); + if (t.value === "Int") { + let vBits = 257; + let vKind = "int"; + if (t.valueAs?.startsWith("int")) { + vBits = parseInt(t.valueAs.slice(3), 10); + } else if (t.valueAs?.startsWith("uint")) { + vKind = "uint"; + } + return generatePrimitive( + call(`__tact_dict_min_${kind}_${vKind}`, [ + path, + int(bits), + int(vBits), + ]), + call(`__tact_dict_next_${kind}_${vKind}`, [ + path, + id(key), + int(bits), + int(vBits), + ]), + ); + } else if (t.value === "Bool") { + return generatePrimitive( + call(`__tact_dict_min_${kind}_int`, [ + path, + int(bits), + int(1), + ]), + call(`__tact_dict_next_${kind}_int`, [ + path, + int(bits), + id(key), + int(1), + ]), + ); + } else if (t.value === "Cell") { + return generatePrimitive( + call(`__tact_dict_next_${kind}_cell`, [ + path, + int(bits), + id(key), + ]), + call(`__tact_dict_next_${kind}_cell`, [ + path, + int(bits), + id(key), + ]), + ); + } else if (t.value === "Address") { + return generatePrimitive( + call(`__tact_dict_min_${kind}_slice`, [path, int(bits)]), + call(`__tact_dict_next_${kind}_slice`, [ + path, + int(bits), + id(key), + ]), + ); + } else { + // Value is a struct + const v = vardef( + "_", + [key, value, flag], + call(`__tact_dict_min_${kind}_cell`, [path, int(bits)]), + ); + let whileBody: FuncAstStatement[] = []; + whileBody.push( + vardef( + "_", + resolveFuncTypeUnpack( + this.ctx.ctx, + t.value, + funcIdOf(stmt.valueName), + ), + call(ops.typeNotNull(t.value), [id(value)]), + ), + ); + for (const s of stmt.statements) { + whileBody = whileBody.concat( + StatementGen.fromTact( + this.ctx, + s, + this.selfName, + this.returns, + ).writeStatement(), + ); + } + whileBody.push( + expr( + assign( + tensor(id(key), id(value), id(flag)), + call(`__tact_dict_next_${kind}_cell`, [ + path, + int(bits), + id(key), + ]), + ), + ), + ); + return [v, while_(id(flag), whileBody)]; } - // case "statement_while": { - // ctx.append(`while (${writeExpression(f.condition, ctx)}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // }); - // ctx.append(`}`); - // return; - // } - // case "statement_until": { - // ctx.append(`do {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // }); - // ctx.append(`} until (${writeExpression(f.condition, ctx)});`); - // return; - // } - // case "statement_repeat": { - // ctx.append(`repeat (${writeExpression(f.iterations, ctx)}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // }); - // ctx.append(`}`); - // return; - // } - // case "statement_try": { - // ctx.append(`try {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // }); - // ctx.append("} catch (_) { }"); - // return; - // } - // case "statement_try_catch": { - // ctx.append(`try {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // }); - // if (isWildcard(f.catchName)) { - // ctx.append(`} catch (_) {`); - // } else { - // ctx.append(`} catch (_, ${funcIdOf(f.catchName)}) {`); - // } - // ctx.inIndent(() => { - // for (const s of f.catchStatements) { - // writeStatement(s, self, returns, ctx); - // } - // }); - // ctx.append(`}`); - // return; - // } - // case "statement_foreach": { - // const mapPath = tryExtractPath(f.map); - // if (mapPath === null) { - // // typechecker is supposed to catch this - // throwInternalCompilerError( - // `foreach is only allowed over maps that are path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, - // f.map.loc, - // ); - // } - // const path = writePathExpression(mapPath); - // - // const t = getExpType(ctx.ctx, f.map); - // if (t.kind !== "map") { - // throw Error("Unknown map type"); - // } - // - // const flag = freshIdentifier("flag"); - // const key = isWildcard(f.keyName) - // ? freshIdentifier("underscore") - // : funcIdOf(f.keyName); - // const value = isWildcard(f.valueName) - // ? freshIdentifier("underscore") - // : funcIdOf(f.valueName); - // - // // Handle Int key - // if (t.key === "Int") { - // let bits = 257; - // let kind = "int"; - // if (t.keyAs?.startsWith("int")) { - // bits = parseInt(t.keyAs.slice(3), 10); - // } else if (t.keyAs?.startsWith("uint")) { - // bits = parseInt(t.keyAs.slice(4), 10); - // kind = "uint"; - // } - // if (t.value === "Int") { - // let vBits = 257; - // let vKind = "int"; - // if (t.valueAs?.startsWith("int")) { - // vBits = parseInt(t.valueAs.slice(3), 10); - // } else if (t.valueAs?.startsWith("uint")) { - // vBits = parseInt(t.valueAs.slice(4), 10); - // vKind = "uint"; - // } - // - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_${vKind}`)}(${path}, ${bits}, ${vBits});`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_${vKind}`)}(${path}, ${bits}, ${key}, ${vBits});`, - // ); - // }); - // ctx.append(`}`); - // } else if (t.value === "Bool") { - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_int`)}(${path}, ${bits}, 1);`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_int`)}(${path}, ${bits}, ${key}, 1);`, - // ); - // }); - // ctx.append(`}`); - // } else if (t.value === "Cell") { - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_cell`)}(${path}, ${bits});`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_cell`)}(${path}, ${bits}, ${key});`, - // ); - // }); - // ctx.append(`}`); - // } else if (t.value === "Address") { - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_slice`)}(${path}, ${bits});`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_slice`)}(${path}, ${bits}, ${key});`, - // ); - // }); - // ctx.append(`}`); - // } else { - // // value is struct - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_cell`)}(${path}, ${bits});`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // ctx.append( - // `var ${resolveFuncTypeUnpack(t.value, funcIdOf(f.valueName), ctx)} = ${ops.typeNotNull(t.value, ctx)}(${ops.readerOpt(t.value, ctx)}(${value}));`, - // ); - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_cell`)}(${path}, ${bits}, ${key});`, - // ); - // }); - // ctx.append(`}`); - // } - // } - // - // // Handle address key - // if (t.key === "Address") { - // if (t.value === "Int") { - // let vBits = 257; - // let vKind = "int"; - // if (t.valueAs?.startsWith("int")) { - // vBits = parseInt(t.valueAs.slice(3), 10); - // } else if (t.valueAs?.startsWith("uint")) { - // vBits = parseInt(t.valueAs.slice(4), 10); - // vKind = "uint"; - // } - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_${vKind}`)}(${path}, 267, ${vBits});`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_${vKind}`)}(${path}, 267, ${key}, ${vBits});`, - // ); - // }); - // ctx.append(`}`); - // } else if (t.value === "Bool") { - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_int`)}(${path}, 267, 1);`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_int`)}(${path}, 267, ${key}, 1);`, - // ); - // }); - // ctx.append(`}`); - // } else if (t.value === "Cell") { - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_cell`)}(${path}, 267);`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_cell`)}(${path}, 267, ${key});`, - // ); - // }); - // ctx.append(`}`); - // } else if (t.value === "Address") { - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_slice`)}(${path}, 267);`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_slice`)}(${path}, 267, ${key});`, - // ); - // }); - // ctx.append(`}`); - // } else { - // // value is struct - // ctx.append( - // `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_cell`)}(${path}, 267);`, - // ); - // ctx.append(`while (${flag}) {`); - // ctx.inIndent(() => { - // ctx.append( - // `var ${resolveFuncTypeUnpack(t.value, funcIdOf(f.valueName), ctx)} = ${ops.typeNotNull(t.value, ctx)}(${ops.readerOpt(t.value, ctx)}(${value}));`, - // ); - // for (const s of f.statements) { - // writeStatement(s, self, returns, ctx); - // } - // ctx.append( - // `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_cell`)}(${path}, 267, ${key});`, - // ); - // }); - // ctx.append(`}`); - // } - // } - // - // return; - // } } - throw Error(`Unknown statement kind: ${this.tactStmt.kind}`); + return []; } } diff --git a/src/codegen/util.ts b/src/codegen/util.ts index 32642269f..5cc6866a4 100644 --- a/src/codegen/util.ts +++ b/src/codegen/util.ts @@ -90,3 +90,10 @@ export function funcInitIdOf(ident: AstId | string): string { ? `${ident}$init` : idText(ident) + "$init"; } + +let NEXT_IDENTIFIER = 0; +export function freshIdentifier(prefix: string): string { + const fresh = `fresh$${prefix}_${NEXT_IDENTIFIER}`; + NEXT_IDENTIFIER += 1; + return funcIdOf(fresh); +} From 9ee58a1d05bd5bc35ba24e382efbfb034950ee61 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 10 Sep 2024 02:01:55 +0000 Subject: [PATCH 141/162] feat(pp): Refine API; more public methods --- src/func/prettyPrinter.ts | 108 ++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 51 deletions(-) diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index 8156c0ce5..d38ee7a57 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -1,5 +1,6 @@ import { FuncAstNode, + FuncAstStatement, FuncAstModule, FuncAstVersionRange, FuncAstParameter, @@ -225,6 +226,51 @@ export class FuncPrettyPrinter { } } + public prettyPrintType(ty: FuncAstType): string { + switch (ty.kind) { + case "type_primitive": + return this.prettyPrintTypePrimitive( + ty as FuncAstTypePrimitive, + ); + case "type_tensor": + return this.prettyPrintTypeTensor(ty as FuncAstTypeTensor); + case "type_tuple": + return this.prettyPrintTypeTuple(ty as FuncAstTypeTuple); + case "hole": + return this.prettyPrintTypeHole(ty as FuncAstHole); + case "unit": + return "()"; + case "type_mapped": + return this.prettyPrintTypeMapped(ty as FuncAstTypeMapped); + default: + throwUnsupportedNodeError(ty); + } + } + + public prettyPrintFunctionSignature( + returnType: FuncAstType, + name: FuncAstId, + parameters: FuncAstParameter[], + attributes: FuncAstFunctionAttribute[], + ): string { + const returnTypeStr = this.prettyPrintType(returnType); + const nameStr = this.prettyPrint(name); + const paramsStr = parameters + .map((param) => this.prettyPrintParameter(param)) + .join(", "); + const attrsStr = + attributes.length > 0 + ? ` ${attributes.map((attr) => this.prettyPrintFunctionAttribute(attr)).join(" ")}` + : ""; + return `${returnTypeStr} ${nameStr}(${paramsStr})${attrsStr}`; + } + + public prettyPrintStatements(stmts: FuncAstStatement[]): string { + return this.prettyPrintIndentedBlock( + stmts.map(this.prettyPrint.bind(this)).join("\n"), + ); + } + private prettyPrintModule(node: FuncAstModule): string { return node.items .map((item, index) => { @@ -302,6 +348,11 @@ export class FuncPrettyPrinter { return `${typeStr} ${nameStr} = ${valueStr};`; } + prettyPrintAsmStrings(asmStrings: FuncAstStringLiteral[]): string { + return asmStrings.map(this.prettyPrint.bind(this)) + .join("\n") + } + private prettyPrintAsmFunctionDefinition( node: FuncAstAsmFunctionDefinition, ): string { @@ -311,9 +362,7 @@ export class FuncPrettyPrinter { node.parameters, node.attributes, ); - const asmBody = node.asmStrings - .map(this.prettyPrint.bind(this)) - .join("\n"); + const asmBody = this.prettyPrintAsmStrings(node.asmStrings); return `${signature} asm ${asmBody};`; } @@ -338,28 +387,7 @@ export class FuncPrettyPrinter { node.parameters, node.attributes, ); - const body = this.prettyPrintIndentedBlock( - node.statements.map(this.prettyPrint.bind(this)).join("\n"), - ); - return `${signature} {\n${body}\n}`; - } - - private prettyPrintFunctionSignature( - returnType: FuncAstType, - name: FuncAstId, - parameters: FuncAstParameter[], - attributes: FuncAstFunctionAttribute[], - ): string { - const returnTypeStr = this.prettyPrintType(returnType); - const nameStr = this.prettyPrint(name); - const paramsStr = parameters - .map((param) => this.prettyPrintParameter(param)) - .join(", "); - const attrsStr = - attributes.length > 0 - ? ` ${attributes.map((attr) => this.prettyPrintFunctionAttribute(attr)).join(" ")}` - : ""; - return `${returnTypeStr} ${nameStr}(${paramsStr})${attrsStr}`; + return `${signature} ${this.prettyPrintStatementBlock(node)}`; } private prettyPrintParameter(param: FuncAstParameter): string { @@ -392,11 +420,10 @@ export class FuncPrettyPrinter { return `return${value};`; } - private prettyPrintStatementBlock(node: FuncAstStatementBlock): string { - const body = this.prettyPrintIndentedBlock( - node.statements.map(this.prettyPrint.bind(this)).join("\n"), - ); - return `{\n${body}\n}`; + private prettyPrintStatementBlock< + T extends { statements: FuncAstStatement[] }, + >(node: T): string { + return `{\n${this.prettyPrintStatements(node.statements)}\n}`; } private prettyPrintStatementConditionIf( @@ -651,27 +678,6 @@ export class FuncPrettyPrinter { return indentedContent; } - public prettyPrintType(ty: FuncAstType): string { - switch (ty.kind) { - case "type_primitive": - return this.prettyPrintTypePrimitive( - ty as FuncAstTypePrimitive, - ); - case "type_tensor": - return this.prettyPrintTypeTensor(ty as FuncAstTypeTensor); - case "type_tuple": - return this.prettyPrintTypeTuple(ty as FuncAstTypeTuple); - case "hole": - return this.prettyPrintTypeHole(ty as FuncAstHole); - case "unit": - return "()"; - case "type_mapped": - return this.prettyPrintTypeMapped(ty as FuncAstTypeMapped); - default: - throwUnsupportedNodeError(ty); - } - } - private prettyPrintTypeTensor(node: FuncAstTypeTensor): string { return `(${node.types.map((type) => this.prettyPrintType(type)).join(", ")})`; } From 82272f407cf4838767ef606a5b76160c8ce24808 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 10 Sep 2024 03:25:35 +0000 Subject: [PATCH 142/162] feat(pp): Support type vars --- src/func/prettyPrinter.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index d38ee7a57..99bf68208 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -228,6 +228,8 @@ export class FuncPrettyPrinter { public prettyPrintType(ty: FuncAstType): string { switch (ty.kind) { + case "type_var": + return this.prettyPrint(ty.name as FuncAstId); case "type_primitive": return this.prettyPrintTypePrimitive( ty as FuncAstTypePrimitive, From 494c240a5444583ee514d94d901082f56f8cc9b2 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 10 Sep 2024 03:25:58 +0000 Subject: [PATCH 143/162] chore(Writer): Replace `#` annotations Needed to test the backend leveraging structural typing in TS --- src/generator/Writer.ts | 206 +++++++++++++++++++--------------------- 1 file changed, 96 insertions(+), 110 deletions(-) diff --git a/src/generator/Writer.ts b/src/generator/Writer.ts index 82a4ff0c1..e75e83d56 100644 --- a/src/generator/Writer.ts +++ b/src/generator/Writer.ts @@ -30,36 +30,30 @@ export type WrittenFunction = { export class WriterContext { readonly ctx: CompilerContext; - #name: string; - #functions: Map = new Map(); - #functionsRendering: Set = new Set(); - #pendingWriter: Writer | null = null; - #pendingCode: Body | null = null; - #pendingDepends: Set | null = null; - #pendingName: string | null = null; - #pendingSignature: string | null = null; - #pendingFlags: Set | null = null; - #pendingComment: string | null = null; - #pendingContext: string | null = null; - #nextId = 0; - // #headers: string[] = []; - #rendered: Set = new Set(); + name: string; + functions: Map = new Map(); + functionsRendering: Set = new Set(); + pendingWriter: Writer | null = null; + pendingCode: Body | null = null; + pendingDepends: Set | null = null; + pendingName: string | null = null; + pendingSignature: string | null = null; + pendingFlags: Set | null = null; + pendingComment: string | null = null; + pendingContext: string | null = null; + nextId = 0; + rendered: Set = new Set(); constructor(ctx: CompilerContext, name: string) { this.ctx = ctx; - this.#name = name; - } - - get name() { - return this.#name; + this.name = name; } clone() { - const res = new WriterContext(this.ctx, this.#name); - res.#functions = new Map(this.#functions); - res.#nextId = this.#nextId; - // res.#headers = [...this.#headers]; - res.#rendered = new Set(this.#rendered); + const res = new WriterContext(this.ctx, this.name); + res.functions = new Map(this.functions); + res.nextId = this.nextId; + res.rendered = new Set(this.rendered); return res; } @@ -70,9 +64,9 @@ export class WriterContext { extract(debug: boolean = false) { // Check dependencies const missing: Map = new Map(); - for (const f of this.#functions.values()) { + for (const f of this.functions.values()) { for (const d of f.depends) { - if (!this.#functions.has(d)) { + if (!this.functions.has(d)) { if (!missing.has(d)) { missing.set(d, [f.name]); } else { @@ -90,14 +84,14 @@ export class WriterContext { } // All functions - let all = Array.from(this.#functions.values()); + let all = Array.from(this.functions.values()); // Remove unused if (!debug) { const used: Set = new Set(); const visit = (name: string) => { used.add(name); - const f = this.#functions.get(name)!; + const f = this.functions.get(name)!; for (const d of f.depends) { visit(d); } @@ -108,7 +102,7 @@ export class WriterContext { // Sort functions const sorted = topologicalSort(all, (f) => - Array.from(f.depends).map((v) => this.#functions.get(v)!), + Array.from(f.depends).map((v) => this.functions.get(v)!), ); return sorted; @@ -122,7 +116,7 @@ export class WriterContext { this.fun(name, () => { this.signature(""); this.context("stdlib"); - this.#pendingCode = { kind: "skip" }; + this.pendingCode = { kind: "skip" }; }); } @@ -131,10 +125,10 @@ export class WriterContext { // Duplicates check // - if (this.#functions.has(name)) { + if (this.functions.has(name)) { throw new Error(`Function "${name}" already defined`); // Should not happen } - if (this.#functionsRendering.has(name)) { + if (this.functionsRendering.has(name)) { throw new Error(`Function "${name}" already rendering`); // Should not happen } @@ -142,52 +136,52 @@ export class WriterContext { // Nesting check // - if (this.#pendingName) { - const w = this.#pendingWriter; - const d = this.#pendingDepends; - const n = this.#pendingName; - const s = this.#pendingSignature; - const f = this.#pendingFlags; - const c = this.#pendingCode; - const cc = this.#pendingComment; - const cs = this.#pendingContext; - this.#pendingDepends = null; - this.#pendingWriter = null; - this.#pendingName = null; - this.#pendingSignature = null; - this.#pendingFlags = null; - this.#pendingCode = null; - this.#pendingComment = null; - this.#pendingContext = null; + if (this.pendingName) { + const w = this.pendingWriter; + const d = this.pendingDepends; + const n = this.pendingName; + const s = this.pendingSignature; + const f = this.pendingFlags; + const c = this.pendingCode; + const cc = this.pendingComment; + const cs = this.pendingContext; + this.pendingDepends = null; + this.pendingWriter = null; + this.pendingName = null; + this.pendingSignature = null; + this.pendingFlags = null; + this.pendingCode = null; + this.pendingComment = null; + this.pendingContext = null; this.fun(name, handler); - this.#pendingSignature = s; - this.#pendingDepends = d; - this.#pendingWriter = w; - this.#pendingName = n; - this.#pendingFlags = f; - this.#pendingCode = c; - this.#pendingComment = cc; - this.#pendingContext = cs; + this.pendingSignature = s; + this.pendingDepends = d; + this.pendingWriter = w; + this.pendingName = n; + this.pendingFlags = f; + this.pendingCode = c; + this.pendingComment = cc; + this.pendingContext = cs; return; } // Write function - this.#functionsRendering.add(name); - this.#pendingWriter = null; - this.#pendingDepends = new Set(); - this.#pendingName = name; - this.#pendingSignature = null; - this.#pendingFlags = new Set(); - this.#pendingCode = null; - this.#pendingComment = null; - this.#pendingContext = null; + this.functionsRendering.add(name); + this.pendingWriter = null; + this.pendingDepends = new Set(); + this.pendingName = name; + this.pendingSignature = null; + this.pendingFlags = new Set(); + this.pendingCode = null; + this.pendingComment = null; + this.pendingContext = null; handler(); - const depends = this.#pendingDepends; - const signature = this.#pendingSignature!; - const flags = this.#pendingFlags; - const code = this.#pendingCode; - const comment = this.#pendingComment; - const context = this.#pendingContext; + const depends = this.pendingDepends; + const signature = this.pendingSignature!; + const flags = this.pendingFlags; + const code = this.pendingCode; + const comment = this.pendingComment; + const context = this.pendingContext; if (!signature && name !== "$main") { throw new Error(`Function "${name}" signature not set`); } @@ -195,13 +189,13 @@ export class WriterContext { if (!code) { throw new Error(`Function "${name}" body not set`); } - this.#pendingDepends = null; - this.#pendingWriter = null; - this.#pendingName = null; - this.#pendingSignature = null; - this.#pendingFlags = null; - this.#functionsRendering.delete(name); - this.#functions.set(name, { + this.pendingDepends = null; + this.pendingWriter = null; + this.pendingName = null; + this.pendingSignature = null; + this.pendingFlags = null; + this.functionsRendering.delete(name); + this.functions.set(name, { name, code, depends, @@ -213,8 +207,8 @@ export class WriterContext { } asm(code: string) { - if (this.#pendingName) { - this.#pendingCode = { + if (this.pendingName) { + this.pendingCode = { kind: "asm", code, }; @@ -224,14 +218,14 @@ export class WriterContext { } body(handler: () => void) { - if (this.#pendingWriter) { + if (this.pendingWriter) { throw new Error(`Body can be set only once`); } - this.#pendingWriter = new Writer(); + this.pendingWriter = new Writer(); handler(); - this.#pendingCode = { + this.pendingCode = { kind: "generic", - code: this.#pendingWriter!.end(), + code: this.pendingWriter!.end(), }; } @@ -244,46 +238,46 @@ export class WriterContext { } signature(sig: string) { - if (this.#pendingName) { - this.#pendingSignature = sig; + if (this.pendingName) { + this.pendingSignature = sig; } else { throw new Error(`Signature can be set only inside function`); } } flag(flag: Flag) { - if (this.#pendingName) { - this.#pendingFlags!.add(flag); + if (this.pendingName) { + this.pendingFlags!.add(flag); } else { throw new Error(`Flag can be set only inside function`); } } used(name: string) { - if (this.#pendingName !== name) { - this.#pendingDepends!.add(name); + if (this.pendingName !== name) { + this.pendingDepends!.add(name); } return name; } comment(src: string) { - if (this.#pendingName) { - this.#pendingComment = trimIndent(src); + if (this.pendingName) { + this.pendingComment = trimIndent(src); } else { throw new Error(`Comment can be set only inside function`); } } context(src: string) { - if (this.#pendingName) { - this.#pendingContext = src; + if (this.pendingName) { + this.pendingContext = src; } else { throw new Error(`Context can be set only inside function`); } } currentContext() { - return this.#pendingName; + return this.pendingName; } // @@ -291,37 +285,29 @@ export class WriterContext { // inIndent = (handler: () => void) => { - this.#pendingWriter!.inIndent(handler); + this.pendingWriter!.inIndent(handler); }; append(src: string = "") { - this.#pendingWriter!.append(src); + this.pendingWriter!.append(src); } write(src: string = "") { - this.#pendingWriter!.write(src); + this.pendingWriter!.write(src); } - // - // Headers - // - - // header(src: string) { - // this.#headers.push(src); - // } - // // Utils // isRendered(key: string) { - return this.#rendered.has(key); + return this.rendered.has(key); } markRendered(key: string) { - if (this.#rendered.has(key)) { + if (this.rendered.has(key)) { throw new Error(`Key "${key}" already rendered`); } - this.#rendered.add(key); + this.rendered.add(key); } } From a1b42a093e4dd6f2b72e8adef98d3c9429d5a198 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 10 Sep 2024 03:27:05 +0000 Subject: [PATCH 144/162] feat(func): Expose public functions --- src/func/grammar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/func/grammar.ts b/src/func/grammar.ts index a5bb23dc1..2d53ce3b4 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -204,7 +204,7 @@ const funcBuiltinOperatorFunctions = [ "_<=>_", ]; -const funcBuiltinFunctions = [ +export const funcBuiltinFunctions = [ "divmod", "moddiv", "muldiv", From 8b5c98d3eb2d6690cfcb9487c3de2aae1bd070a0 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Tue, 10 Sep 2024 03:27:21 +0000 Subject: [PATCH 145/162] chore(codegen): Remove tests; they'll be rewritten --- src/codegen/codegen.spec.ts | 178 ------------------------------ src/codegen/contracts/Simple.tact | 5 - 2 files changed, 183 deletions(-) delete mode 100644 src/codegen/codegen.spec.ts delete mode 100644 src/codegen/contracts/Simple.tact diff --git a/src/codegen/codegen.spec.ts b/src/codegen/codegen.spec.ts deleted file mode 100644 index d16d395d9..000000000 --- a/src/codegen/codegen.spec.ts +++ /dev/null @@ -1,178 +0,0 @@ -import * as fs from "fs"; -import * as path from "path"; - -import { __DANGER_resetNodeId } from "../grammar/ast"; -import { compile } from "../pipeline/compile"; -import { precompile } from "../pipeline/precompile"; -import { getContracts } from "../types/resolveDescriptors"; -import { CompilationOutput, CompilationResults } from "../pipeline/compile"; -import { createNodeFileSystem } from "../vfs/createNodeFileSystem"; -import { CompilerContext } from "../context"; - -const CONTRACTS_DIR = path.join(__dirname, "./contracts/"); - -function capitalize(str: string): string { - if (str.length === 0) return str; - return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); -} - -/** - * Generates a Tact configuration file for the given contract (imported from Misti). - */ -export function generateConfig(contractName: string): string { - const config = { - projects: [ - { - name: `${contractName}`, - path: `./${contractName}.tact`, - output: `./output`, - options: {}, - }, - ], - }; - const configPath = path.join(CONTRACTS_DIR, `${contractName}.config.json`); - fs.writeFileSync(configPath, JSON.stringify(config), { - encoding: "utf8", - flag: "w", - }); - return configPath; -} - -/** - * Compiles the contract on the given filepath to CompilationResults replicating the Tact compiler pipeline. - */ -async function compileContract( - backend: "new" | "old", - contractName: string, -): Promise { - const _ = generateConfig(contractName); - - // see: pipeline/build.ts - const project = createNodeFileSystem(CONTRACTS_DIR, false); - const stdlib = createNodeFileSystem( - path.resolve(__dirname, "..", "..", "stdlib"), - false, - ); - let ctx: CompilerContext = new CompilerContext({ shared: {} }); - ctx = precompile(ctx, project, stdlib, contractName); - - return await Promise.all( - getContracts(ctx).map(async (contract) => { - const res = await compile( - ctx, - contract, - `${contractName}_${contract}`, - backend, - ); - return res; - }), - ); -} - -function compareCompilationOutputs( - newOut: CompilationOutput, - oldOut: CompilationOutput, -): void { - const errors: string[] = []; - - if (newOut === undefined || oldOut === undefined) { - errors.push("One of the outputs is undefined."); - } else { - try { - expect(newOut.entrypoint).toBe(oldOut.entrypoint); - } catch (error) { - if (error instanceof Error) { - errors.push(`Entrypoint mismatch: ${error.message}`); - } else { - errors.push(`Entrypoint mismatch: ${String(error)}`); - } - } - - try { - expect(newOut.abi).toBe(oldOut.abi); - } catch (error) { - if (error instanceof Error) { - errors.push(`ABI mismatch: ${error.message}`); - } else { - errors.push(`ABI mismatch: ${String(error)}`); - } - } - - const unmatchedFiles = new Set(oldOut.files.map((file) => file.name)); - - for (const newFile of newOut.files) { - const oldFile = oldOut.files.find( - (file) => file.name === newFile.name, - ); - if (oldFile) { - unmatchedFiles.delete(oldFile.name); - try { - expect(newFile.code).toBe(oldFile.code); - } catch (error) { - if (error instanceof Error) { - errors.push( - `Code mismatch in file ${newFile.name}: ${error.message}`, - ); - } else { - errors.push( - `Code mismatch in file ${newFile.name}: ${String(error)}`, - ); - } - } - } else { - errors.push( - `File ${newFile.name} is missing in the old output.`, - ); - } - } - - for (const missingFile of unmatchedFiles) { - errors.push(`File ${missingFile} is missing in the new output.`); - } - } - - if (errors.length > 0) { - throw new Error(errors.join("\n")); - } -} - -describe("codegen", () => { - beforeEach(async () => { - __DANGER_resetNodeId(); - }); - - fs.readdirSync(CONTRACTS_DIR).forEach((file) => { - if (!file.endsWith(".tact")) { - return; - } - const contractName = capitalize(file); - // Differential tests with the old backend - it(`Should compile the ${file} contract`, async () => { - Promise.all([ - compileContract("new", contractName), - compileContract("old", contractName), - ]) - .then(([resultsNew, resultsOld]) => { - if (resultsNew.length !== resultsOld.length) { - throw new Error("Not all contracts have been compiled"); - } - const zipped = resultsNew.map((value, idx) => [ - value, - resultsOld[idx], - ]); - zipped.forEach(([newRes, oldRes]) => { - compareCompilationOutputs( - newRes!.output, - oldRes!.output, - ); - }); - }) - .catch((error) => { - console.error( - "An error occurred during compilation:", - error, - ); - }); - }); - }); -}); diff --git a/src/codegen/contracts/Simple.tact b/src/codegen/contracts/Simple.tact deleted file mode 100644 index 4e06edb30..000000000 --- a/src/codegen/contracts/Simple.tact +++ /dev/null @@ -1,5 +0,0 @@ -contract A { - get fun foo(): Int { - return 1; - } -} From bcfef5441748252c133097bd5fef09683aa1be68 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 11 Sep 2024 11:02:42 +0000 Subject: [PATCH 146/162] feat: New codegen copied from the main version; `writeStdlib` is ported --- src/codegen/abi.ts | 26 - src/codegen/accessors.ts | 190 - src/codegen/context.ts | 277 - src/codegen/expression.ts | 691 - src/codegen/function.ts | 291 - src/codegen/generator.ts | 374 - src/codegen/index.ts | 15 - src/codegen/literal.ts | 174 - src/codegen/module.ts | 1539 --- src/codegen/statement.ts | 522 - src/codegen/storage.ts | 67 - src/codegen/type.ts | 464 - src/codegen/util.ts | 99 - src/generatorNew/Writer.ts | 414 + src/generatorNew/createABI.ts | 176 + src/generatorNew/emitter/createPadded.ts | 8 + src/generatorNew/emitter/emit.ts | 68 + src/generatorNew/writeProgram.ts | 409 + src/generatorNew/writeReport.ts | 100 + .../writeSerialization.spec.ts.snap | 10684 ++++++++++++++++ src/generatorNew/writers/cast.ts | 24 + src/generatorNew/writers/freshIdentifier.ts | 9 + src/generatorNew/writers/id.ts | 15 + src/generatorNew/writers/ops.ts | 82 + .../writers/resolveFuncFlatPack.ts | 58 + .../writers/resolveFuncFlatTypes.ts | 57 + .../writers/resolveFuncPrimitive.ts} | 16 +- .../writers/resolveFuncTupleType.ts | 55 + .../writers/resolveFuncType.spec.ts | 176 + src/generatorNew/writers/resolveFuncType.ts | 101 + .../writers/resolveFuncTypeFromAbi.ts | 55 + .../writers/resolveFuncTypeFromAbiUnpack.ts | 61 + .../writers/resolveFuncTypeUnpack.ts | 99 + src/generatorNew/writers/writeAccessors.ts | 318 + src/generatorNew/writers/writeConstant.ts | 84 + src/generatorNew/writers/writeContract.ts | 374 + .../writers/writeExpression.spec.ts | 102 + src/generatorNew/writers/writeExpression.ts | 692 + src/generatorNew/writers/writeFunction.ts | 726 ++ src/generatorNew/writers/writeInterfaces.ts | 26 + src/generatorNew/writers/writeRouter.ts | 502 + .../writers/writeSerialization.spec.ts | 96 + .../writers/writeSerialization.ts} | 472 +- .../writers/writeStdlib.ts} | 12 +- src/pipeline/compile.ts | 11 +- src/test/new-codegen/codegen.spec.ts | 171 + src/test/new-codegen/contracts/Simple.tact | 5 + .../contracts/Simple.tact.config.json | 1 + 48 files changed, 16032 insertions(+), 4956 deletions(-) delete mode 100644 src/codegen/abi.ts delete mode 100644 src/codegen/accessors.ts delete mode 100644 src/codegen/context.ts delete mode 100644 src/codegen/expression.ts delete mode 100644 src/codegen/function.ts delete mode 100644 src/codegen/generator.ts delete mode 100644 src/codegen/index.ts delete mode 100644 src/codegen/literal.ts delete mode 100644 src/codegen/module.ts delete mode 100644 src/codegen/statement.ts delete mode 100644 src/codegen/storage.ts delete mode 100644 src/codegen/type.ts delete mode 100644 src/codegen/util.ts create mode 100644 src/generatorNew/Writer.ts create mode 100644 src/generatorNew/createABI.ts create mode 100644 src/generatorNew/emitter/createPadded.ts create mode 100644 src/generatorNew/emitter/emit.ts create mode 100644 src/generatorNew/writeProgram.ts create mode 100644 src/generatorNew/writeReport.ts create mode 100644 src/generatorNew/writers/__snapshots__/writeSerialization.spec.ts.snap create mode 100644 src/generatorNew/writers/cast.ts create mode 100644 src/generatorNew/writers/freshIdentifier.ts create mode 100644 src/generatorNew/writers/id.ts create mode 100644 src/generatorNew/writers/ops.ts create mode 100644 src/generatorNew/writers/resolveFuncFlatPack.ts create mode 100644 src/generatorNew/writers/resolveFuncFlatTypes.ts rename src/{codegen/primitive.ts => generatorNew/writers/resolveFuncPrimitive.ts} (74%) create mode 100644 src/generatorNew/writers/resolveFuncTupleType.ts create mode 100644 src/generatorNew/writers/resolveFuncType.spec.ts create mode 100644 src/generatorNew/writers/resolveFuncType.ts create mode 100644 src/generatorNew/writers/resolveFuncTypeFromAbi.ts create mode 100644 src/generatorNew/writers/resolveFuncTypeFromAbiUnpack.ts create mode 100644 src/generatorNew/writers/resolveFuncTypeUnpack.ts create mode 100644 src/generatorNew/writers/writeAccessors.ts create mode 100644 src/generatorNew/writers/writeConstant.ts create mode 100644 src/generatorNew/writers/writeContract.ts create mode 100644 src/generatorNew/writers/writeExpression.spec.ts create mode 100644 src/generatorNew/writers/writeExpression.ts create mode 100644 src/generatorNew/writers/writeFunction.ts create mode 100644 src/generatorNew/writers/writeInterfaces.ts create mode 100644 src/generatorNew/writers/writeRouter.ts create mode 100644 src/generatorNew/writers/writeSerialization.spec.ts rename src/{codegen/serializers.ts => generatorNew/writers/writeSerialization.ts} (57%) rename src/{codegen/stdlib.ts => generatorNew/writers/writeStdlib.ts} (99%) create mode 100644 src/test/new-codegen/codegen.spec.ts create mode 100644 src/test/new-codegen/contracts/Simple.tact create mode 100644 src/test/new-codegen/contracts/Simple.tact.config.json diff --git a/src/codegen/abi.ts b/src/codegen/abi.ts deleted file mode 100644 index 0c30789db..000000000 --- a/src/codegen/abi.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { AstExpression, SrcInfo } from "../grammar/ast"; -import { CompilerContext } from "../context"; -import { TypeRef } from "../types/types"; -import { FuncAstExpression } from "../func/grammar"; - -/** - * A static map of functions defining Func expressions for Tact ABI functions and methods. - */ -export type AbiFunction = { - name: string; - resolve: (ctx: CompilerContext, args: TypeRef[], loc: SrcInfo) => TypeRef; - generate: ( - args: TypeRef[], - resolved: AstExpression[], - loc: SrcInfo, - ) => FuncAstExpression; -}; - -// TODO -export const MapFunctions: Map = new Map([]); - -// TODO -export const StructFunctions: Map = new Map([]); - -// TODO -export const GlobalFunctions: Map = new Map([]); diff --git a/src/codegen/accessors.ts b/src/codegen/accessors.ts deleted file mode 100644 index 74e81c02e..000000000 --- a/src/codegen/accessors.ts +++ /dev/null @@ -1,190 +0,0 @@ -import { WriterContext, Location } from "./context"; -import { contractErrors } from "../abi/errors"; -import { getType } from "../types/resolveDescriptors"; -import { TypeDescription } from "../types/types"; -import { FuncAstType } from "../func/grammar"; -import { FuncPrettyPrinter } from "../func/prettyPrinter"; -import { ops } from "./util"; -import { - resolveFuncTypeUnpack, - resolveFuncFlatPack, - resolveFuncFlatTypes, - resolveFuncTupleType, - resolveFuncType, -} from "./type"; - -export function writeAccessors(type: TypeDescription, ctx: WriterContext) { - const parse = (code: string) => - ctx.parse(code, { context: Location.type(type.name) }); - const ppty = (ty: FuncAstType): string => - new FuncPrettyPrinter().prettyPrintType(ty); - - // Getters - for (const f of type.fields) { - parse(`_ ${ops.typeField(type.name, f.name)}(${ppty(resolveFuncType(ctx.ctx, type))} v) inline { - var (${type.fields.map((v) => `v'${v.name}`).join(", ")}) = v; - return v'${f.name}; - } - `); - } - - // Tensor cast - parse( - `(${ppty(resolveFuncType(ctx.ctx, type))}) ${ops.typeTensorCast(type.name)}(${ppty(resolveFuncType(ctx.ctx, type))} v) asm "NOP";`, - ); - - // Not null - { - const flatPack = resolveFuncFlatPack(ctx.ctx, type, "vvv"); - const flatTypes = resolveFuncFlatTypes(ctx.ctx, type); - if (flatPack.length !== flatTypes.length) - throw Error("Flat pack and flat types length mismatch"); - const pairs = flatPack.map((v, i) => `${ppty(flatTypes[i]!)} ${v}`); - parse(`(${ppty(resolveFuncType(ctx.ctx, type))}) ${ops.typeNotNull(type.name)}(tuple v) inline { - throw_if(${contractErrors.null.id}, null?(v)); - (${pairs.join(", ")}) = __tact_tuple_destroy_${flatPack.length}(v); - return ${resolveFuncTypeUnpack(ctx.ctx, type, "vvv")}; - }`); - } - - // As optional - { - const flatPack = resolveFuncFlatPack(ctx.ctx, type, "v"); - parse(`tuple ${ops.typeAsOptional(type.name)}(${ppty(resolveFuncType(ctx.ctx, type))} v) inline { - var ${resolveFuncTypeUnpack(ctx.ctx, type, "v")} = v; - return __tact_tuple_create_${flatPack.length}(${flatPack.join(", ")}); - }`); - } - - // - // Convert to and from tuple representation - // - - { - const vars: string[] = []; - for (const f of type.fields) { - if (f.type.kind === "ref") { - const t = getType(ctx.ctx, f.type.name); - if (t.kind === "struct") { - if (f.type.optional) { - vars.push( - `${ops.typeToOptTuple(f.type.name)}(v'${f.name})`, - ); - } else { - vars.push( - `${ops.typeToTuple(f.type.name)}(v'${f.name})`, - ); - } - continue; - } - } - vars.push(`v'${f.name}`); - } - parse(`tuple ${ops.typeToTuple(type.name)}((${ppty(resolveFuncType(ctx.ctx, type))}) v) inline { - var (${type.fields.map((v) => `v'${v.name}`).join(", ")}) = v; - return __tact_tuple_create_${vars.length}(${vars.join(", ")}); - }`); - } - - parse(`tuple ${ops.typeToOptTuple(type.name)}(tuple v) inline { - if (null?(v)) { return null(); } - return ${ops.typeToTuple(type.name)}(${ops.typeNotNull(type.name)}(v)); - }`); - - { - const vars: string[] = []; - const out: string[] = []; - for (const f of type.fields) { - if (f.type.kind === "ref") { - const t = getType(ctx.ctx, f.type.name); - if (t.kind === "struct") { - vars.push(`tuple v'${f.name}`); - if (f.type.optional) { - out.push( - `${ops.typeFromOptTuple(f.type.name)}(v'${f.name})`, - ); - } else { - out.push( - `${ops.typeFromTuple(f.type.name)}(v'${f.name})`, - ); - } - continue; - } else if ( - t.kind === "primitive_type_decl" && - t.name === "Address" - ) { - if (f.type.optional) { - vars.push( - `${ppty(resolveFuncType(ctx.ctx, f.type))} v'${f.name}`, - ); - out.push( - `null?(v'${f.name}) ? null() : __tact_verify_address(v'${f.name})`, - ); - } else { - vars.push( - `${ppty(resolveFuncType(ctx.ctx, f.type))} v'${f.name}`, - ); - out.push(`__tact_verify_address(v'${f.name})`); - } - continue; - } - } - vars.push(`${ppty(resolveFuncType(ctx.ctx, f.type))} v'${f.name}`); - out.push(`v'${f.name}`); - } - parse(`(${type.fields.map((v) => `${ppty(resolveFuncType(ctx.ctx, v.type))}`).join(", ")}) ${ops.typeFromTuple(type.name)}(tuple v) inline { - (${vars.join(", ")}) = __tact_tuple_destroy_${vars.length}(v); - return (${out.join(", ")}); - }`); - } - - parse(`tuple ${ops.typeFromOptTuple(type.name)}(tuple v) inline { - if (null?(v)) { return null(); } - return ${ops.typeAsOptional(type.name)}(${ops.typeFromTuple(type.name)}(v)); - } - `); - - // - // Convert to and from external representation - // - - { - const vars: string[] = []; - for (const f of type.fields) { - if (f.type.kind === "ref") { - const t = getType(ctx.ctx, f.type.name); - if (t.kind === "struct") { - if (f.type.optional) { - vars.push( - `${ops.typeToOptTuple(f.type.name)}(v'${f.name})`, - ); - } else { - vars.push( - `${ops.typeToTuple(f.type.name)}(v'${f.name})`, - ); - } - continue; - } - } - vars.push(`v'${f.name}`); - } - parse(`(${type.fields - .map((v) => resolveFuncTupleType(ctx.ctx, v.type)) - .map((ty) => `${ppty(ty)}`) - .join( - ", ", - )}) ${ops.typeToExternal(type.name)}((${ppty(resolveFuncType(ctx.ctx, type))}) v) inline { - var (${type.fields.map((v) => `v'${v.name}`).join(", ")}) = v; - return (${vars.join(", ")}); - }`); - } - - parse(`tuple ${ops.typeToOptExternal(type.name)}(tuple v) inline { - var loaded = ${ops.typeToOptTuple(type.name)}(v); - if (null?(loaded)) { - return null(); - } else { - return (loaded); - } - }`); -} diff --git a/src/codegen/context.ts b/src/codegen/context.ts deleted file mode 100644 index 570e292e6..000000000 --- a/src/codegen/context.ts +++ /dev/null @@ -1,277 +0,0 @@ -import { CompilerContext } from "../context"; -import { topologicalSort } from "../utils/utils"; -import { - FuncAstFunctionDefinition, - FuncAstAsmFunctionDefinition, - FuncAstFunctionAttribute, - FuncAstId, - FuncAstModule, - FuncAstType, - FuncAstStatement, -} from "../func/grammar"; -import { asmfun, fun, FunParamValue } from "../func/syntaxConstructors"; -import { parse } from "../func/grammar"; -import { forEachExpression } from "../func/iterators"; - -import JSONbig from "json-bigint"; - -/** - * An additional information on how to handle the function definition. - * TODO: Refactor: we need only the boolean `skip` field in WrittenFunction. - * TODO: We don't need even `skip`. These are merely names without signature saved within the context. - * XXX: Writer.ts: `Body.kind` - */ -export type BodyKind = "asm" | "skip" | "generic"; - -export type FunctionInfo = { - kind: BodyKind; - context: LocationContext; - inMainContract: boolean; -}; - -/** - * Replicates the `ctx.context` parameter of the old backends Writer context. - * Basically, it tells in which file the context value should be located in the - * generated Func code. - * - * TODO: Should be refactored; `type` seems to be redundant - */ -export type LocationContext = - | { kind: "stdlib" } - | { kind: "constants" } - | { kind: "type"; value: string }; - -export function locEquals(lhs: LocationContext, rhs: LocationContext): boolean { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === "type" && rhs.kind === "type") { - return lhs.value === rhs.value; - } - return true; -} - -/** - * Returns string value of the location context "as in the old backend". - */ -export function locValue(loc: LocationContext): string { - return loc.kind === "type" ? `type:${loc.value}` : loc.kind; -} - -export class Location { - public static stdlib(): LocationContext { - return { kind: "stdlib" }; - } - - public static constants(): LocationContext { - return { kind: "constants" }; - } - - public static type(value: string): LocationContext { - return { kind: "type", value }; - } -} - -export type WrittenFunction = { - name: string; - definition: - | FuncAstFunctionDefinition - | FuncAstAsmFunctionDefinition - | undefined; - kind: BodyKind; - context: LocationContext | undefined; - depends: Set; - inMainContract: boolean; // true iff it should be placed in $main in the old backend -}; - -/** - * The context containing objects generated by the codegen and stores the - * required intermediate information. - * - * It implements the original WriterContext, but keeps AST elements instead and - * doesn't pretend to implement any formatting/code emitting logic. - */ -export class WriterContext { - public readonly ctx: CompilerContext; - - /** Generated functions. */ - private functions: Map = new Map(); - - constructor(ctx: CompilerContext) { - this.ctx = ctx; - } - - /** - * Analyses the AST of the function saving names of the functions it calls under the hood. - */ - private addDependencies( - fun: FuncAstFunctionDefinition, - depends: Set, - ): void { - forEachExpression(fun, (expr) => { - // TODO: It doesn't save receivers. But should it? - if ( - expr.kind === "expression_fun_call" && - expr.object.kind === "plain_id" - ) { - depends.add(expr.object.value); - } - }); - } - - /** - * Saves an information about the function in the context automatically extracting - * info about the dependencies: functions that it calls. - */ - public save( - value: - | FuncAstFunctionDefinition - | FuncAstAsmFunctionDefinition - | { name: string; kind: "name_only" }, - params: Partial = {}, - ): void { - const { - kind = "generic", - context = undefined, - inMainContract = false, - } = params; - let name: string; - let definition: - | FuncAstFunctionDefinition - | FuncAstAsmFunctionDefinition - | undefined; - if (value.kind === "name_only") { - name = value.name; - definition = undefined; - } else { - const defValue = value as - | FuncAstFunctionDefinition - | FuncAstAsmFunctionDefinition; - name = defValue.name.value; - definition = defValue; - } - const depends = new Set(); - if (value.kind === "function_definition") { - this.addDependencies(value, depends); - } - this.functions.set(name, { - name, - definition, - kind, - context, - depends, - inMainContract, - }); - } - - /** - * Parses the Func source code to the definition of function. - * @throws If the given code cannot be parsed as a simple function/asm function definition. - */ - public parse< - T extends FuncAstFunctionDefinition | FuncAstAsmFunctionDefinition, - >(code: string, params: Partial = {}): T | never { - const mod = parse(code) as FuncAstModule; - if ( - mod.items.length === 1 && - (mod.items[0]!.kind === "function_definition" || - mod.items[0]!.kind === "asm_function_definition") - ) { - const fun = mod.items[0] as T; - this.save(fun, params); - return fun; - } - // TODO(jubnzv): Add a custom error when merging w/ main - throw new Error( - `Incorrect function structure: ${JSONbig.stringify(mod)}`, - ); - } - - /** - * Wraps the function definition constructor saving it to the context. - * XXX: Replicates old WriterContext.fun - */ - public fun( - attrs: FuncAstFunctionAttribute[], - name: string | FuncAstId, - paramValues: FunParamValue[], - returnTy: FuncAstType, - body: FuncAstStatement[], - params: Partial = {}, - ): FuncAstFunctionDefinition { - const f = fun(name, paramValues, attrs, returnTy, body); - this.save(f, params); - return f; - } - - /** - * Saves the function name in the context. - * XXX: Replicates old WriterContext.skip - */ - public skip(name: string, params: Partial = {}): void { - this.save({ name, kind: "name_only" }, params); - } - - /** - * Wraps the asm function definition constructor saving it to the context. - * XXX: Replicates old WriterContext.asm - */ - public asm( - attrs: FuncAstFunctionAttribute[], - name: string | FuncAstId, - paramValues: FunParamValue[], - returnTy: FuncAstType, - rawAsm: string, - params: Partial = {}, - ): FuncAstAsmFunctionDefinition { - const f = asmfun(name, paramValues, attrs, returnTy, [rawAsm]); - this.save(f, params); - return f; - } - - public hasFunction(name: string): boolean { - return this.functions.has(name); - } - - private allFunctions(): WrittenFunction[] { - return Array.from(this.functions.values()); - } - - // Functions that are defined in the $main "section" of the old backend. - private mainFunctions(): WrittenFunction[] { - return this.allFunctions().filter((f) => f.inMainContract); - } - - public extract(debug: boolean = false): WrittenFunction[] { - // All functions - let all = this.allFunctions(); - - // Remove unused - const used: Set = new Set(); - const visit = (name: string) => { - used.add(name); - const f = this.functions.get(name); - if (f !== undefined) { - for (const d of f.depends) { - visit(d); - } - } - }; - this.mainFunctions().forEach((f) => visit(f.name)); - all = all.filter((v) => { - return used.has(v.name); - }); - - // Sort functions - const sorted = topologicalSort(all, (f) => { - if (f !== undefined) { - return Array.from(f.depends).map((v) => this.functions.get(v)!); - } else { - // TODO: This will be resolved when all the required functions are added to the new backend. - return []; - } - }).filter((f) => f !== undefined); - - return sorted; - } -} diff --git a/src/codegen/expression.ts b/src/codegen/expression.ts deleted file mode 100644 index d4f91a2a9..000000000 --- a/src/codegen/expression.ts +++ /dev/null @@ -1,691 +0,0 @@ -import { - TactConstEvalError, - throwCompilationError, - idTextErr, -} from "../errors"; -import { evalConstantExpression } from "../constEval"; -import { resolveFuncTypeUnpack } from "./type"; -import { MapFunctions, StructFunctions, GlobalFunctions } from "./abi"; -import { getExpType } from "../types/resolveExpression"; -import { FunctionGen, WriterContext, LiteralGen } from "."; -import { cast, funcIdOf, ops } from "./util"; -import { printTypeRef, TypeRef, Value, FieldDescription } from "../types/types"; -import { - getStaticConstant, - getType, - getStaticFunction, - hasStaticConstant, -} from "../types/resolveDescriptors"; -import { - idText, - AstExpression, - AstId, - eqNames, - tryExtractPath, -} from "../grammar/ast"; -import { FuncAstExpression, FuncOpUnary, FuncAstId } from "../func/grammar"; -import { - id, - call, - binop, - ternary, - unop, - bool, -} from "../func/syntaxConstructors"; - -function isNull(f: AstExpression): boolean { - return f.kind === "null"; -} - -function addUnary(op: FuncOpUnary, expr: FuncAstExpression): FuncAstExpression { - return unop(op, expr); -} - -function negate(expr: FuncAstExpression): FuncAstExpression { - return addUnary("~", expr); -} - -/** - * Creates a Func identifier in the following format: a'b'c. - * TODO: make it a static method - */ -export function writePathExpression(path: AstId[]): FuncAstId { - return id( - [funcIdOf(idText(path[0]!)), ...path.slice(1).map(idText)].join(`'`), - ); -} - -/** - * Encapsulates generation of Func expressions from the Tact expression. - */ -export class ExpressionGen { - /** - * @param tactExpr Expression to translate. - */ - private constructor( - private ctx: WriterContext, - private tactExpr: AstExpression, - ) {} - - static fromTact( - ctx: WriterContext, - tactExpr: AstExpression, - ): ExpressionGen { - return new ExpressionGen(ctx, tactExpr); - } - - public writeExpression(): FuncAstExpression { - // literals and constant expressions are covered here - try { - const value = evalConstantExpression(this.tactExpr, this.ctx.ctx); - return this.makeValue(value); - } catch (error) { - if (!(error instanceof TactConstEvalError) || error.fatal) - throw error; - } - - // - // ID Reference - // - if (this.tactExpr.kind === "id") { - const t = getExpType(this.ctx.ctx, this.tactExpr); - - // Handle packed type - if (t.kind === "ref") { - const tt = getType(this.ctx.ctx, t.name); - if (tt.kind === "contract" || tt.kind === "struct") { - const value = resolveFuncTypeUnpack( - this.ctx.ctx, - t, - funcIdOf(this.tactExpr.text), - ); - return id(value); - } - } - - if (t.kind === "ref_bounced") { - const tt = getType(this.ctx.ctx, t.name); - if (tt.kind === "struct") { - // TODO: ? - const value = resolveFuncTypeUnpack( - this.ctx.ctx, - t, - funcIdOf(this.tactExpr.text), - false, - true, - ); - } - } - - // Handle constant - if (hasStaticConstant(this.ctx.ctx, this.tactExpr.text)) { - const c = getStaticConstant(this.ctx.ctx, this.tactExpr.text); - return this.makeValue(c.value!); - } - - return id(funcIdOf(this.tactExpr.text)); - } - - // NOTE: We always wrap in parentheses to avoid operator precedence issues - if (this.tactExpr.kind === "op_binary") { - // Special case for non-integer types and nullable - if (this.tactExpr.op === "==" || this.tactExpr.op === "!=") { - if (isNull(this.tactExpr.left) && isNull(this.tactExpr.right)) { - return bool(this.tactExpr.op === "=="); - } else if ( - isNull(this.tactExpr.left) && - !isNull(this.tactExpr.right) - ) { - const callExpr = call("null?", [ - this.makeExpr(this.tactExpr.right), - ]); - return this.tactExpr.op === "==" - ? callExpr - : negate(callExpr); - } else if ( - !isNull(this.tactExpr.left) && - isNull(this.tactExpr.right) - ) { - const callExpr = call("null?", [ - this.makeExpr(this.tactExpr.left), - ]); - return this.tactExpr.op === "==" - ? callExpr - : negate(callExpr); - } - } - - // Special case for address - const lt = getExpType(this.ctx.ctx, this.tactExpr.left); - const rt = getExpType(this.ctx.ctx, this.tactExpr.right); - - // Case for addresses equality - if ( - lt.kind === "ref" && - rt.kind === "ref" && - lt.name === "Address" && - rt.name === "Address" - ) { - const maybeNegate = (call: any): any => { - if (this.tactExpr.kind !== "op_binary") { - throw new Error("Impossible"); - } - return this.tactExpr.op == "!=" ? negate(call) : call; - }; - if (lt.optional && rt.optional) { - return maybeNegate( - call("__tact_slice_eq_bits_nullable", [ - this.makeExpr(this.tactExpr.left), - this.makeExpr(this.tactExpr.right), - ]), - ); - } - if (lt.optional && !rt.optional) { - return maybeNegate( - call("__tact_slice_eq_bits_nullable_one", [ - this.makeExpr(this.tactExpr.left), - this.makeExpr(this.tactExpr.right), - ]), - ); - } - if (!lt.optional && rt.optional) { - return maybeNegate( - call("__tact_slice_eq_bits_nullable_one", [ - this.makeExpr(this.tactExpr.right), - this.makeExpr(this.tactExpr.left), - ]), - ); - } - return maybeNegate( - call("__tact_slice_eq_bits", [ - this.makeExpr(this.tactExpr.right), - this.makeExpr(this.tactExpr.left), - ]), - ); - } - - // Case for cells equality - if ( - lt.kind === "ref" && - rt.kind === "ref" && - lt.name === "Cell" && - rt.name === "Cell" - ) { - const op = this.tactExpr.op === "==" ? "eq" : "neq"; - if (lt.optional && rt.optional) { - return call(`__tact_cell_${op}_nullable`, [ - this.makeExpr(this.tactExpr.left), - this.makeExpr(this.tactExpr.right), - ]); - } - if (lt.optional && !rt.optional) { - return call(`__tact_cell_${op}_nullable_one`, [ - this.makeExpr(this.tactExpr.left), - this.makeExpr(this.tactExpr.right), - ]); - } - if (!lt.optional && rt.optional) { - return call(`__tact_cell_${op}_nullable_one`, [ - this.makeExpr(this.tactExpr.right), - this.makeExpr(this.tactExpr.left), - ]); - } - return call(`__tact_cell_${op}`, [ - this.makeExpr(this.tactExpr.right), - this.makeExpr(this.tactExpr.left), - ]); - } - - // Case for slices and strings equality - if ( - lt.kind === "ref" && - rt.kind === "ref" && - lt.name === rt.name && - (lt.name === "Slice" || lt.name === "String") - ) { - const op = this.tactExpr.op === "==" ? "eq" : "neq"; - if (lt.optional && rt.optional) { - return call(`__tact_slice_${op}_nullable`, [ - this.makeExpr(this.tactExpr.left), - this.makeExpr(this.tactExpr.right), - ]); - } - if (lt.optional && !rt.optional) { - return call(`__tact_slice_${op}_nullable_one`, [ - this.makeExpr(this.tactExpr.left), - this.makeExpr(this.tactExpr.right), - ]); - } - if (!lt.optional && rt.optional) { - return call(`__tact_slice_${op}_nullable_one`, [ - this.makeExpr(this.tactExpr.right), - this.makeExpr(this.tactExpr.left), - ]); - } - return call(`__tact_slice_${op}`, [ - this.makeExpr(this.tactExpr.right), - this.makeExpr(this.tactExpr.left), - ]); - } - - // Case for maps equality - if (lt.kind === "map" && rt.kind === "map") { - const op = this.tactExpr.op === "==" ? "eq" : "neq"; - return call(`__tact_cell_${op}_nullable`, [ - this.makeExpr(this.tactExpr.left), - this.makeExpr(this.tactExpr.right), - ]); - } - - // Check for int or boolean types - if ( - lt.kind !== "ref" || - rt.kind !== "ref" || - (lt.name !== "Int" && lt.name !== "Bool") || - (rt.name !== "Int" && rt.name !== "Bool") - ) { - const file = this.tactExpr.loc.file; - const loc_info = this.tactExpr.loc.interval.getLineAndColumn(); - throw Error( - `(Internal Compiler Error) Invalid types for binary operation: ${file}:${loc_info.lineNum}:${loc_info.colNum}`, - ); // Should be unreachable - } - - // Case for ints equality - if (this.tactExpr.op === "==" || this.tactExpr.op === "!=") { - const op = this.tactExpr.op === "==" ? "eq" : "neq"; - if (lt.optional && rt.optional) { - return call(`__tact_int_${op}_nullable`, [ - this.makeExpr(this.tactExpr.left), - this.makeExpr(this.tactExpr.right), - ]); - } - if (lt.optional && !rt.optional) { - return call(`__tact_int_${op}_nullable_one`, [ - this.makeExpr(this.tactExpr.left), - this.makeExpr(this.tactExpr.right), - ]); - } - if (!lt.optional && rt.optional) { - return call(`__tact_int_${op}_nullable_one`, [ - this.makeExpr(this.tactExpr.right), - this.makeExpr(this.tactExpr.left), - ]); - } - return binop( - this.makeExpr(this.tactExpr.left), - this.tactExpr.op === "==" ? "==" : "!=", - this.makeExpr(this.tactExpr.right), - ); - } - - // Case for "&&" operator - if (this.tactExpr.op === "&&") { - const cond = this.makeExpr(this.tactExpr.left); - const trueExpr = this.makeExpr(this.tactExpr.right); - return ternary(cond, trueExpr, bool(false)); - } - - // Case for "||" operator - if (this.tactExpr.op === "||") { - const cond = this.makeExpr(this.tactExpr.left); - const falseExpr = this.makeExpr(this.tactExpr.right); - return ternary(cond, bool(true), falseExpr); - } - - // Other ops - return binop( - this.makeExpr(this.tactExpr.left), - this.tactExpr.op, - this.makeExpr(this.tactExpr.right), - ); - } - - // Unary operations: !, -, +, !! - // NOTE: We always wrap in parenthesis to avoid operator precedence issues - if (this.tactExpr.kind === "op_unary") { - // NOTE: Logical not is written as a bitwise not - switch (this.tactExpr.op) { - case "!": - case "~": { - const expr = this.makeExpr(this.tactExpr.operand); - return negate(expr); - } - case "-": { - const expr = this.makeExpr(this.tactExpr.operand); - return addUnary("-", expr); - } - case "+": { - const expr = this.makeExpr(this.tactExpr.operand); - return addUnary("+", expr); - } - - // NOTE: Assert function that ensures that the value is not null - case "!!": { - const t = getExpType(this.ctx.ctx, this.tactExpr.operand); - if (t.kind === "ref") { - const tt = getType(this.ctx.ctx, t.name); - if (tt.kind === "struct") { - return call(ops.typeNotNull(tt.name), [ - this.makeExpr(this.tactExpr.operand), - ]); - } - } - return call("__tact_not_null", [ - this.makeExpr(this.tactExpr.operand), - ]); - } - } - } - - // - // Field Access - // NOTE: this branch resolves "a.b", where "a" is an expression and "b" is a field name - // - if (this.tactExpr.kind === "field_access") { - // Resolve the type of the expression - const src = getExpType(this.ctx.ctx, this.tactExpr.aggregate); - if ( - (src.kind !== "ref" || src.optional) && - src.kind !== "ref_bounced" - ) { - throwCompilationError( - `Cannot access field of non-struct type: "${printTypeRef(src)}"`, - this.tactExpr.loc, - ); - } - const srcT = getType(this.ctx.ctx, src.name); - - // Resolve field - let fields: FieldDescription[]; - - fields = srcT.fields; - if (src.kind === "ref_bounced") { - fields = fields.slice(0, srcT.partialFieldCount); - } - - const fieldExpr = this.tactExpr.field; - const field = fields.find((v) => eqNames(v.name, fieldExpr)); - const cst = srcT.constants.find((v) => eqNames(v.name, fieldExpr)); - if (!field && !cst) { - throwCompilationError( - `Cannot find field ${idTextErr(this.tactExpr.field)} in struct ${idTextErr(srcT.name)}`, - this.tactExpr.field.loc, - ); - } - - if (field) { - // Trying to resolve field as a path - const path = tryExtractPath(this.tactExpr); - if (path) { - // Prepare path - const idd = writePathExpression(path); - - // Special case for structs - if (field.type.kind === "ref") { - const ft = getType(this.ctx.ctx, field.type.name); - if (ft.kind === "struct" || ft.kind === "contract") { - return id( - resolveFuncTypeUnpack( - this.ctx.ctx, - field.type, - idd.value, - ), - ); - } - } - return idd; - } - - // Getter instead of direct field access - return call(ops.typeField(srcT.name, field.name), [ - this.makeExpr(this.tactExpr.aggregate), - ]); - } else { - return this.makeValue(cst!.value!); - } - } - - // - // Static Function Call - // - if (this.tactExpr.kind === "static_call") { - // Check global functions - if (GlobalFunctions.has(idText(this.tactExpr.function))) { - return GlobalFunctions.get( - idText(this.tactExpr.function), - )!.generate( - this.tactExpr.args.map((v) => getExpType(this.ctx.ctx, v)), - this.tactExpr.args, - this.tactExpr.loc, - ); - } - - const sf = getStaticFunction( - this.ctx.ctx, - idText(this.tactExpr.function), - ); - // if (sf.ast.kind === "native_function_decl") { - // n = idText(sf.ast.nativeName); - // if (n.startsWith("__tact")) { - // // wCtx.used(n); - // } - // } else { - // // wCtx.used(n); - // } - const fun = id(ops.global(idText(this.tactExpr.function))); - const args = this.tactExpr.args.map((argAst, i) => - this.makeCastedExpr(argAst, sf.params[i]!.type), - ); - return call(fun, args); - } - - // - // Struct Constructor - // - if (this.tactExpr.kind === "struct_instance") { - const src = getType(this.ctx.ctx, this.tactExpr.type); - - // Write a constructor - const constructor = FunctionGen.fromTact( - this.ctx, - ).writeStructConstructor( - src, - this.tactExpr.args.map((v) => v.field.text), - ); - - // Write an expression - const args = this.tactExpr.args.map((v) => - this.makeCastedExpr( - v.initializer, - src.fields.find((v2) => eqNames(v2.name, v.field))!.type, - ), - ); - return call(constructor.name, args); - } - - // - // Object-based function call - // - if (this.tactExpr.kind === "method_call") { - // Resolve source type - const src = getExpType(this.ctx.ctx, this.tactExpr.self); - - // Reference type - if (src.kind === "ref") { - if (src.optional) { - throwCompilationError( - `Cannot call function of non - direct type: "${printTypeRef(src)}"`, - this.tactExpr.loc, - ); - } - - // Render function call - const methodTy = getType(this.ctx.ctx, src.name); - - // Check struct ABI - if (methodTy.kind === "struct") { - if (StructFunctions.has(idText(this.tactExpr.method))) { - const abi = StructFunctions.get( - idText(this.tactExpr.method), - )!; - // return abi.generate( - // wCtx, - // [ - // src, - // ...this.tactExpr.args.map((v) => getExpType(this.ctx.ctx, v)), - // ], - // [this.tactExpr.self, ...this.tactExpr.args], - // this.tactExpr.loc, - // ); - } - } - - // Resolve function - const methodFun = methodTy.functions.get( - idText(this.tactExpr.method), - )!; - let name = ops.extension( - src.name, - idText(this.tactExpr.method), - ); - if ( - methodFun.ast.kind !== "function_def" && - methodFun.ast.kind !== "function_decl" - ) { - name = idText(methodFun.ast.nativeName); - } - - // Translate arguments - let argExprs = this.tactExpr.args.map((a, i) => - this.makeCastedExpr(a, methodFun.params[i]!.type), - ); - - // Hack to replace a single struct argument to a tensor wrapper since otherwise - // func would convert (int) type to just int and break mutating functions - if (methodFun.isMutating) { - if (this.tactExpr.args.length === 1) { - const t = getExpType( - this.ctx.ctx, - this.tactExpr.args[0]!, - ); - if (t.kind === "ref") { - const tt = getType(this.ctx.ctx, t.name); - if ( - (tt.kind === "contract" || - tt.kind === "struct") && - methodFun.params[0]!.type.kind === "ref" && - !methodFun.params[0]!.type.optional - ) { - argExprs = [ - call(ops.typeTensorCast(tt.name), [ - argExprs[0]!, - ]), - ]; - } - } - } - } - - // Generate function call - const selfExpr = this.makeExpr(this.tactExpr.self); - if (methodFun.isMutating) { - if ( - this.tactExpr.self.kind === "id" || - this.tactExpr.self.kind === "field_access" - ) { - if (selfExpr.kind !== "plain_id") { - throw new Error( - `Impossible self kind: ${selfExpr.kind}`, - ); - } - return call(`${selfExpr.value}~${name}`, argExprs); - } else { - return call(ops.nonModifying(name), [ - selfExpr, - ...argExprs, - ]); - } - } else { - return call(name, [selfExpr, ...argExprs]); - } - } - - // Map types - if (src.kind === "map") { - if (!MapFunctions.has(idText(this.tactExpr.method))) { - throwCompilationError( - `Map function "${idText(this.tactExpr.method)}" not found`, - this.tactExpr.loc, - ); - } - const abf = MapFunctions.get(idText(this.tactExpr.method))!; - return abf.generate( - [ - src, - ...this.tactExpr.args.map((v) => - getExpType(this.ctx.ctx, v), - ), - ], - [this.tactExpr.self, ...this.tactExpr.args], - this.tactExpr.loc, - ); - } - - if (src.kind === "ref_bounced") { - throw Error("Unimplemented"); - } - - throwCompilationError( - `Cannot call function of non - direct type: "${printTypeRef(src)}"`, - this.tactExpr.loc, - ); - } - - // - // Init of - // - if (this.tactExpr.kind === "init_of") { - const type = getType(this.ctx.ctx, this.tactExpr.contract); - return call(ops.contractInitChild(idText(this.tactExpr.contract)), [ - id("__tact_context_sys"), - ...this.tactExpr.args.map((a, i) => - this.makeCastedExpr(a, type.init!.params[i]!.type), - ), - ]); - } - - // - // Ternary operator - // - if (this.tactExpr.kind === "conditional") { - return ternary( - this.makeExpr(this.tactExpr.condition), - this.makeExpr(this.tactExpr.thenBranch), - this.makeExpr(this.tactExpr.elseBranch), - ); - } - - // - // Unreachable - // - throw Error(`Unknown expression: ${this.tactExpr.kind}`); - } - - private makeValue(val: Value): FuncAstExpression { - return LiteralGen.fromTact(this.ctx, val).writeValue(); - } - - private makeExpr(src: AstExpression): FuncAstExpression { - return ExpressionGen.fromTact(this.ctx, src).writeExpression(); - } - - public writeCastedExpression(to: TypeRef): FuncAstExpression { - const expr = getExpType(this.ctx.ctx, this.tactExpr); - return cast(this.ctx.ctx, expr, to, this.writeExpression()); - } - - private makeCastedExpr(src: AstExpression, to: TypeRef): FuncAstExpression { - return ExpressionGen.fromTact(this.ctx, src).writeCastedExpression(to); - } -} diff --git a/src/codegen/function.ts b/src/codegen/function.ts deleted file mode 100644 index ff78b1034..000000000 --- a/src/codegen/function.ts +++ /dev/null @@ -1,291 +0,0 @@ -import { enabledInline } from "../config/features"; -import { getType, resolveTypeRef } from "../types/resolveDescriptors"; -import { ops, funcIdOf } from "./util"; -import { FuncPrettyPrinter } from "../func/prettyPrinter"; -import { TypeDescription, FunctionDescription, TypeRef } from "../types/types"; -import { - FuncAstFunctionDefinition, - FuncAstStatement, - FuncAstFunctionAttribute, - FuncAstExpression, - FuncAstType, -} from "../func/grammar"; -import { idText, AstNativeFunctionDecl } from "../grammar/ast"; -import { - id, - call, - ret, - FunAttr, - vardef, - Type, - tensor, -} from "../func/syntaxConstructors"; -import { StatementGen, LiteralGen, WriterContext, Location } from "."; -import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; - -/** - * Encapsulates generation of Func functions from the Tact function. - */ -export class FunctionGen { - /** - * @param tactFun Type description of the Tact function. - */ - private constructor(private ctx: WriterContext) {} - - static fromTact(ctx: WriterContext): FunctionGen { - return new FunctionGen(ctx); - } - - private resolveFuncPrimitive( - descriptor: TypeRef | TypeDescription | string, - ): boolean { - // String - if (typeof descriptor === "string") { - return this.resolveFuncPrimitive(getType(this.ctx.ctx, descriptor)); - } - - // TypeRef - if (descriptor.kind === "ref") { - return this.resolveFuncPrimitive( - getType(this.ctx.ctx, descriptor.name), - ); - } - if (descriptor.kind === "map") { - return true; - } - if (descriptor.kind === "ref_bounced") { - throw Error("Unimplemented: ref_bounced descriptor"); - } - if (descriptor.kind === "void") { - return true; - } - - // TypeDescription - if (descriptor.kind === "primitive_type_decl") { - if (descriptor.name === "Int") { - return true; - } else if (descriptor.name === "Bool") { - return true; - } else if (descriptor.name === "Slice") { - return true; - } else if (descriptor.name === "Cell") { - return true; - } else if (descriptor.name === "Builder") { - return true; - } else if (descriptor.name === "Address") { - return true; - } else if (descriptor.name === "String") { - return true; - } else if (descriptor.name === "StringBuilder") { - return true; - } else { - throw Error(`Unknown primitive type: ${descriptor.name}`); - } - } else if (descriptor.kind === "struct") { - return false; - } else if (descriptor.kind === "contract") { - return false; - } - - // Unreachable - throw Error(`Unknown type: ${descriptor.kind}`); - } - - public writeNativeFunction(f: FunctionDescription): void | never { - if (f.ast.kind !== "native_function_decl") { - throw new Error(`Unsupported function kind: ${f.ast.kind}`); - } - if (f.isMutating) { - const ppty = (ty: FuncAstType): string => - new FuncPrettyPrinter().prettyPrintType(ty); - const nonMutName = ops.nonModifying(idText(f.ast.nativeName)); - const returns = ppty(resolveFuncType(this.ctx.ctx, f.returns)); - const params = this.getFunParams(f); - const code = ` - ${returns} ${nonMutName}(${params.map(([name, ty]) => `${ppty(ty)} ${name}`).join(", ")}) impure ${enabledInline(this.ctx.ctx) || f.isInline ? "inline" : ""} { - return ${funcIdOf("self")}~${idText((f.ast as AstNativeFunctionDecl).nativeName)}(${f.ast.params - .slice(1) - .map((arg) => funcIdOf(arg.name)) - .join(", ")}); - }`; - f.origin === "stdlib" - ? this.ctx.parse(code, { context: Location.stdlib() }) - : this.ctx.parse(code); - } - } - - private getFunParams(f: FunctionDescription): [string, FuncAstType][] { - const self = this.getSelf(f); - return f.params.reduce( - (acc, a) => { - acc.push([ - funcIdOf(a.name), - resolveFuncType(this.ctx.ctx, a.type), - ]); - return acc; - }, - self - ? [[funcIdOf("self"), resolveFuncType(this.ctx.ctx, self)]] - : [], - ); - } - - private getSelf(f: FunctionDescription): TypeDescription | undefined { - return f.self ? getType(this.ctx.ctx, f.self) : undefined; - } - - /** - * Generates Func function from the Tact funciton description. - * - * @return The generated function or `undefined` if no function was generated. - */ - public writeFunctionDefinition( - f: FunctionDescription, - ): FuncAstFunctionDefinition | never { - let returnTy = resolveFuncType(this.ctx.ctx, f.returns); - const self = this.getSelf(f); - if (self !== undefined && f.isMutating) { - // Add `self` to the method signature as it is mutating in the body. - const selfTy = resolveFuncType(this.ctx.ctx, self); - returnTy = Type.tensor(selfTy, returnTy); - } - - const params: [string, FuncAstType][] = this.getFunParams(f); - - if (f.ast.kind !== "function_def") { - throw new Error(`Unknown function kind: ${f.ast.kind}`); - } - - // TODO: handle native functions delcs. should be in a separatre funciton - - const name = self - ? ops.extension(self.name, f.name) - : ops.global(f.name); - - // Prepare function attributes - let attrs: FuncAstFunctionAttribute[] = [FunAttr.impure()]; - if (enabledInline(this.ctx.ctx) || f.isInline) { - attrs.push(FunAttr.inline()); - } - // TODO: handle stdlib - // if (f.origin === "stdlib") { - // ctx.context("stdlib"); - // } - - // Write function body - const body: FuncAstStatement[] = []; - - // Add arguments - if (self) { - const varName = resolveFuncTypeUnpack( - this.ctx.ctx, - self, - funcIdOf("self"), - ); - const init: FuncAstExpression = id(funcIdOf("self")); - body.push(vardef("_", varName, init)); - } - for (const a of f.ast.params) { - if ( - !this.resolveFuncPrimitive(resolveTypeRef(this.ctx.ctx, a.type)) - ) { - const name = resolveFuncTypeUnpack( - this.ctx.ctx, - resolveTypeRef(this.ctx.ctx, a.type), - funcIdOf(a.name), - ); - const init: FuncAstExpression = id(funcIdOf(a.name)); - body.push(vardef("_", name, init)); - } - } - - const selfName = - self !== undefined - ? resolveFuncTypeUnpack(this.ctx.ctx, self, funcIdOf("self")) - : undefined; - // Process statements - f.ast.statements.forEach((stmt) => { - const funcStmts = StatementGen.fromTact( - this.ctx, - stmt, - selfName, - f.returns, - ).writeStatement(); - body.push(...funcStmts); - }); - - return this.ctx.fun(attrs, name, params, returnTy, body); - } - - public writeFunction(f: FunctionDescription): void | never { - switch (f.ast.kind) { - case "native_function_decl": - this.writeNativeFunction(f); - return; - case "function_def": - this.writeFunctionDefinition(f); - return; - default: - throw new Error(`Unsupported function kind: ${f.ast.kind}`); - } - } - - /** - * Creates a Func function that represents a constructor for the Tact struct, e.g.: - * ``` - * ((int, int)) $MyStruct$_constructor_f1_f2(int $f1, int $f2) inline { - * return ($f1, $f2); - * } - * ``` - * - * The generated constructor will be saved in the context. - * - * @param type Type description of the struct for which the constructor is generated - * @param args Names of the arguments - */ - public writeStructConstructor( - type: TypeDescription, - args: string[], - ): FuncAstFunctionDefinition { - const attrs: FuncAstFunctionAttribute[] = [FunAttr.inline()]; - const name = ops.typeConstructor( - type.name, - args.map((a) => a), - ); - const returnTy = resolveFuncType(this.ctx.ctx, type); - // Rename a struct constructor formal parameter to avoid - // name clashes with FunC keywords, e.g. `struct Foo {type: Int}` - // is a perfectly fine Tact structure, but its constructor would - // have the wrong parameter name: `$Foo$_constructor_type(int type)` - const avoidFunCKeywordNameClash = (p: string) => `$${p}`; - const params: [string, FuncAstType][] = args.map((arg: string) => [ - avoidFunCKeywordNameClash(arg), - resolveFuncType( - this.ctx.ctx, - type.fields.find((v2) => v2.name === arg)!.type, - ), - ]); - // Create expressions used in actual arguments - const values: FuncAstExpression[] = type.fields.map((v) => { - const arg = args.find((v2) => v2 === v.name); - if (arg) { - return id(avoidFunCKeywordNameClash(arg)); - } else if (v.default !== undefined) { - return LiteralGen.fromTact(this.ctx, v.default).writeValue(); - } else { - throw Error( - `Missing argument for field "${v.name}" in struct "${type.name}"`, - ); // Must not happen - } - }); - const body = - values.length === 0 && returnTy.kind === "type_tuple" - ? [ret(call("empty_tuple", []))] - : [ret(tensor(...values))]; - const constructor = this.ctx.fun(attrs, name, params, returnTy, body); - this.ctx.save(constructor, { - context: Location.type(type.name), - }); - return constructor; - } -} diff --git a/src/codegen/generator.ts b/src/codegen/generator.ts deleted file mode 100644 index 78da78bc7..000000000 --- a/src/codegen/generator.ts +++ /dev/null @@ -1,374 +0,0 @@ -import { CompilationOutput } from "../pipeline/compile"; -import { getSortedTypes } from "../storage/resolveAllocation"; -import { CompilerContext } from "../context"; -import { idToHex } from "../utils/idToHex"; -import { LocationContext, Location, locEquals, locValue } from "."; -import { WriterContext, ModuleGen, WrittenFunction } from "."; -import { getRawAST } from "../grammar/store"; -import { ContractABI } from "@ton/core"; -import { FuncPrettyPrinter } from "../func/prettyPrinter"; -import { - FuncAstModule, - FuncAstFunctionDefinition, - FuncAstAsmFunctionDefinition, -} from "../func/grammar"; -import { deepCopy } from "../func/syntaxUtils"; -import { - comment, - mod, - pragma, - version, - Type, - include, - global, - toDeclaration, - FunAttr, -} from "../func/syntaxConstructors"; -import { calculateIPFSlink } from "../utils/calculateIPFSlink"; - -export type GeneratedFilesInfo = { - files: { name: string; code: string }[]; - imported: string[]; -}; - -/** - * Func version used to compile the generated code. - */ -export const CODEGEN_FUNC_VERSION = "0.4.4"; - -/** - * Generates Func files that correspond to the input Tact project. - */ -export class FuncGenerator { - private tactCtx: CompilerContext; - /** An ABI structure of the project generated by the Tact compiler. */ - private abiSrc: ContractABI; - /** Basename used e.g. to name the generated Func files. */ - private basename: string; - private funcCtx: WriterContext; - - private constructor( - tactCtx: CompilerContext, - abiSrc: ContractABI, - basename: string, - ) { - this.tactCtx = tactCtx; - this.abiSrc = abiSrc; - this.basename = basename; - this.funcCtx = new WriterContext(tactCtx); - } - - static fromTactProject( - tactCtx: CompilerContext, - abiSrc: ContractABI, - basename: string, - ): FuncGenerator { - return new FuncGenerator(tactCtx, abiSrc, basename); - } - - /** - * Translates the whole Tact project to Func. - * @returns Information about generated Func files and their code. - */ - public async writeProgram(): Promise { - const abi = JSON.stringify(this.abiSrc); - const abiLink = await calculateIPFSlink(Buffer.from(abi)); - - const m = ModuleGen.fromTact( - this.funcCtx, - this.abiSrc.name!, - abiLink, - ).writeAll(); - const functions = this.funcCtx.extract(); - - // - // Emit files - // - const generated: GeneratedFilesInfo = { files: [], imported: [] }; - - // - // Headers - // - this.generateHeaders(generated, functions); - - // - // stdlib - // - this.generateStdlib(generated, functions); - - // - // native - // - this.generateNative(generated); - - // - // constants - // - this.generateConstants(generated, functions); - - // - // storage - // - this.generateStorage(generated, functions); - - // - // Remaining - // - // TODO - - // Finalize and dump the main contract, as we have just obtained the structure of the project - m.items.unshift(...generated.files.map((f) => include(f.name))); - m.items.push(version("=", CODEGEN_FUNC_VERSION)); - m.items.push(pragma("allow-post-modification")); - m.items.push(pragma("compute-asm-ltr")); - generated.files.push({ - name: `${this.basename}.code.fc`, - code: new FuncPrettyPrinter().prettyPrint(m), - }); - - // header.push(""); - // header.push(";;"); - // header.push(`;; Contract ${abiSrc.name} functions`); - // header.push(";;"); - // header.push(""); - // const code = emit({ - // header: header.join("\n"), - // functions: remainingFunctions, - // }); - // files.push({ - // name: basename + ".code.fc", - // code, - // }); - - return { - entrypoint: `${this.basename}.code.fc`, - files: generated.files, - abi, - }; - } - - /** - * Generates a file that contains declarations of all the generated Func functions. - */ - private generateHeaders( - generated: GeneratedFilesInfo, - functions: WrittenFunction[], - ): void { - // FIXME: We should add only contract methods and special methods here => add attribute and register them in the context - const m = mod(); - m.items.push( - comment( - "", - `Header files for ${this.abiSrc.name}`, - "NOTE: declarations are sorted for optimal order", - "", - ), - ); - functions.forEach((f) => { - if ( - f.kind === "generic" && - f.definition !== undefined && - f.definition.kind === "function_definition" - ) { - m.items.push( - comment(f.definition.name.value, { skipCR: true }), - ); - const copiedDefinition = deepCopy(f.definition); - if ( - copiedDefinition.attributes.find( - (attr) => - attr.kind !== "impure" && attr.kind !== "inline", - ) - ) { - copiedDefinition.attributes.push(FunAttr.inline_ref()); - } - m.items.push(toDeclaration(copiedDefinition)); - } - }); - generated.files.push({ - name: `${this.basename}.headers.fc`, - code: new FuncPrettyPrinter().prettyPrint(m), - }); - } - - private generateStdlib( - generated: GeneratedFilesInfo, - functions: WrittenFunction[], - ): void { - const m = mod(); - m.items.push( - global( - Type.tensor(Type.int(), Type.slice(), Type.int(), Type.slice()), - "__tact_context", - ), - ); - m.items.push(global(Type.slice(), "__tact_context_sender")); - m.items.push(global(Type.cell(), "__tact_context_sys")); - m.items.push(global(Type.int(), "__tact_randomized")); - - const stdlibFunctions = this.tryExtractModule( - functions, - Location.stdlib(), - [], - ); - if (stdlibFunctions) { - generated.imported.push("stdlib"); - } - stdlibFunctions.forEach((f) => { - if (f.definition !== undefined) m.items.push(f.definition); - }); - generated.files.push({ - name: `${this.basename}.stdlib.fc`, - code: new FuncPrettyPrinter().prettyPrint(m), - }); - } - - private generateNative(generated: GeneratedFilesInfo): void { - const nativeSources = getRawAST(this.funcCtx.ctx).funcSources; - if (nativeSources.length > 0) { - generated.imported.push("native"); - generated.files.push({ - name: `${this.basename}.native.fc`, - code: [...nativeSources.map((v) => v.code)].join("\n\n"), - }); - } - } - - private generateConstants( - generated: GeneratedFilesInfo, - functions: WrittenFunction[], - ): void { - const constantsFunctions = this.tryExtractModule( - functions, - Location.constants(), - generated.imported, - ); - if (constantsFunctions) { - generated.imported.push("constants"); - generated.files.push({ - name: `${this.basename}.constants.fc`, - code: new FuncPrettyPrinter().prettyPrint( - mod( - ...constantsFunctions.reduce( - (acc, v) => { - if (v.definition !== undefined) - acc.push(v.definition); - return acc; - }, - [] as ( - | FuncAstFunctionDefinition - | FuncAstAsmFunctionDefinition - )[], - ), - ), - ), - }); - } - } - - private generateStorage( - generated: GeneratedFilesInfo, - functions: WrittenFunction[], - ): void { - const generatedModules: FuncAstModule[] = []; - const types = getSortedTypes(this.funcCtx.ctx); - for (const t of types) { - const ffs: WrittenFunction[] = []; - if ( - t.kind === "struct" || - t.kind === "contract" || - t.kind == "trait" - ) { - const typeFunctions = this.tryExtractModule( - functions, - Location.type(t.name), - generated.imported, - ); - if (typeFunctions) { - generated.imported.push(`type:${t.name}`); - ffs.push(...typeFunctions); - } - } - if (t.kind === "contract") { - const typeFunctions = this.tryExtractModule( - functions, - Location.type(`${t.name}$init`), - generated.imported, - ); - if (typeFunctions) { - generated.imported.push("type:" + t.name + "$init"); - ffs.push(...typeFunctions); - } - } - const comments: string[] = []; - if (ffs.length > 0) { - comments.push(""); - comments.push(`Type: ${t.name}`); - if (t.header !== null) { - comments.push(`Header: 0x${idToHex(t.header)}`); - } - if (t.tlb) { - comments.push(`TLB: ${t.tlb}`); - } - comments.push(""); - } - generatedModules.push( - mod( - ...[ - comment(...comments), - ...ffs.reduce( - (acc, f) => { - if (f.definition !== undefined) - acc.push(f.definition); - return acc; - }, - [] as ( - | FuncAstFunctionDefinition - | FuncAstAsmFunctionDefinition - )[], - ), - ], - ), - ); - } - if (generatedModules.length > 0) { - generated.files.push({ - name: `${this.basename}.storage.fc`, - code: generatedModules - .map((m) => new FuncPrettyPrinter().prettyPrint(m)) - .join("\n\n"), - }); - } - } - - private tryExtractModule( - functions: WrittenFunction[], - location: LocationContext, - imported: string[], - ): WrittenFunction[] { - // Put to map - const maps: Map = new Map(); - for (const f of functions) { - maps.set(f.name, f); - } - - // Extract functions of a context - const ctxFunctions: WrittenFunction[] = functions - .filter((v) => v.kind !== "skip") - .filter((v) => { - if (location !== undefined && v.context !== undefined) { - return locEquals(v.context, location); - } else { - return ( - v.context === undefined || - !imported.includes(locValue(v.context)) - ); - } - }); - if (ctxFunctions.length === 0) { - return []; - } - - return ctxFunctions; - } -} diff --git a/src/codegen/index.ts b/src/codegen/index.ts deleted file mode 100644 index ec32a3785..000000000 --- a/src/codegen/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export { - WriterContext, - WrittenFunction, - Location, - LocationContext, - BodyKind, - locEquals, - locValue, -} from "./context"; -export { ModuleGen } from "./module"; -export { FunctionGen } from "./function"; -export { StatementGen } from "./statement"; -export { ExpressionGen, writePathExpression } from "./expression"; -export { FuncGenerator } from "./generator"; -export { LiteralGen } from "./literal"; diff --git a/src/codegen/literal.ts b/src/codegen/literal.ts deleted file mode 100644 index b5e1755e4..000000000 --- a/src/codegen/literal.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { WriterContext, FunctionGen, Location } from "."; -import { FuncAstExpression } from "../func/grammar"; -import { Address, beginCell, Cell } from "@ton/core"; -import { Value, CommentValue } from "../types/types"; -import { call, Type, int, id, nil, bool } from "../func/syntaxConstructors"; -import { getType } from "../types/resolveDescriptors"; - -import JSONbig from "json-bigint"; - -/** - * Encapsulates generation of Func literal values from Tact values. - */ -export class LiteralGen { - /** - * @param tactExpr Expression to translate. - */ - private constructor( - private ctx: WriterContext, - private tactValue: Value, - ) {} - - static fromTact(ctx: WriterContext, tactValue: Value): LiteralGen { - return new LiteralGen(ctx, tactValue); - } - - /** - * Saves/retrieves a function from the context and returns its name. - */ - private writeRawSlice( - prefix: string, - comment: string, - cell: Cell, - ): FuncAstExpression { - const h = cell.hash().toString("hex"); - const t = cell.toBoc({ idx: false }).toString("hex"); - const funName = `__gen_slice_${prefix}_${h}`; - if (!this.ctx.hasFunction(funName)) { - // TODO: Add docstring: `comment` - const fun = this.ctx.asm( - [], - funName, - [], - Type.slice(), - `B{${t}} B>boc boc PUSHREF`, - ); - this.ctx.save(fun, { - kind: "asm", - context: Location.constants(), - }); - } - return id(funName); - } - - /** - * Generates FunC literals from Tact ones. - */ - public writeValue(): FuncAstExpression { - const val = this.tactValue; - if (typeof val === "bigint") { - return int(val); - } - if (typeof val === "string") { - return call(this.writeString(val), []); - } - if (typeof val === "boolean") { - return bool(val); - } - if (Address.isAddress(val)) { - return call(this.writeAddress(val), []); - } - if (val instanceof Cell) { - return call(this.writeCell(val), []); - } - if (val === null) { - return nil(); - } - if (val instanceof CommentValue) { - return call(this.writeComment(val.comment), []); - } - if (typeof val === "object" && "$tactStruct" in val) { - // this is a struct value - const structDescription = getType( - this.ctx.ctx, - val["$tactStruct"] as string, - ); - const fields = structDescription.fields.map((field) => field.name); - const constructor = FunctionGen.fromTact( - this.ctx, - ).writeStructConstructor(structDescription, fields); - const fieldValues = structDescription.fields.map((field) => { - if (field.name in val) { - return this.makeValue(val[field.name]!); - } else { - throw Error( - `Struct value is missing a field: ${field.name}`, - val, - ); - } - }); - return call(constructor.name, fieldValues); - } - throw Error(`Invalid value: ${JSONbig.stringify(val, null, 2)}`); - } - - private makeValue(val: Value): FuncAstExpression { - return LiteralGen.fromTact(this.ctx, val).writeValue(); - } -} diff --git a/src/codegen/module.ts b/src/codegen/module.ts deleted file mode 100644 index 3f87c9afc..000000000 --- a/src/codegen/module.ts +++ /dev/null @@ -1,1539 +0,0 @@ -import { - getAllTypes, - getAllStaticFunctions, - getType, - toBounced, -} from "../types/resolveDescriptors"; -import { enabledInline } from "../config/features"; -import { LiteralGen, Location } from "."; -import { - ReceiverDescription, - TypeDescription, - InitDescription, - TypeRef, - FunctionDescription, -} from "../types/types"; -import { writeStorageOps } from "./storage"; -import { - writeBouncedParser, - writeOptionalParser, - writeOptionalSerializer, - writeParser, - writeSerializer, -} from "./serializers"; -import { CompilerContext } from "../context"; -import { getSortedTypes, getAllocation } from "../storage/resolveAllocation"; -import { getMethodId } from "../utils/utils"; -import { idTextErr } from "../errors"; -import { contractErrors } from "../abi/errors"; -import { writeStdlib } from "./stdlib"; -import { writeAccessors } from "./accessors"; -import { - resolveFuncTypeUnpack, - resolveFuncType, - resolveFuncTupleType, -} from "./type"; -import { resolveFuncPrimitive } from "./primitive"; -import { getSupportedInterfaces } from "../types/getSupportedInterfaces"; -import { funcIdOf, funcInitIdOf, ops } from "./util"; -import { - FuncAstModule, - FuncAstStatement, - FuncAstExpression, - FuncAstFunctionAttribute, - FuncAstType, - FuncAstFunctionDefinition, -} from "../func/grammar"; -import { - cr, - unop, - comment, - FunParamValue, - assign, - expr, - unit, - call, - binop, - bool, - int, - hex, - string, - ret, - tensor, - Type, - ternary, - FunAttr, - vardef, - mod, - condition, - id, -} from "../func/syntaxConstructors"; -import { FunctionGen, StatementGen, WriterContext } from "."; -import { beginCell } from "@ton/core"; - -import JSONbig from "json-bigint"; - -export function commentPseudoOpcode(comment: string): string { - return beginCell() - .storeUint(0, 32) - .storeBuffer(Buffer.from(comment, "utf8")) - .endCell() - .hash() - .toString("hex", 0, 64); -} - -export function unwrapExternal( - ctx: CompilerContext, - targetName: string, - sourceName: string, - type: TypeRef, -): FuncAstStatement { - if (type.kind === "ref") { - const t = getType(ctx, type.name); - if (t.kind === "struct") { - if (type.optional) { - return vardef( - resolveFuncType(ctx, type), - targetName, - call(ops.typeFromOptTuple(t.name), [id(sourceName)]), - ); - } else { - return vardef( - resolveFuncType(ctx, type), - targetName, - call(ops.typeFromTuple(t.name), [id(sourceName)]), - ); - } - } else if (t.kind === "primitive_type_decl" && t.name === "Address") { - if (type.optional) { - const init = ternary( - call("null?", [id(sourceName)]), - call("null", []), - call("__tact_verify_address", [id(sourceName)]), - ); - return vardef(resolveFuncType(ctx, type), targetName, init); - } else { - return vardef( - resolveFuncType(ctx, type), - targetName, - call("__tact_verify_address", [id(sourceName)]), - ); - } - } - } - return vardef(resolveFuncType(ctx, type), targetName, id(sourceName)); -} - -/** - * Encapsulates generation of the main Func compilation module from the main Tact module. - */ -export class ModuleGen { - private constructor( - private ctx: WriterContext, - private contractName: string, - private abiLink: string, - ) {} - - static fromTact( - ctx: WriterContext, - contractName: string, - abiLink: string, - ): ModuleGen { - return new ModuleGen(ctx, contractName, abiLink); - } - - /** - * Adds stdlib definitions to the generated module. - */ - private writeStdlib(): void { - writeStdlib(this.ctx); - } - - private addSerializers(sortedTypes: TypeDescription[]): void { - for (const t of sortedTypes) { - if (t.kind === "contract" || t.kind === "struct") { - const allocation = getAllocation(this.ctx.ctx, t.name); - const allocationBounced = getAllocation( - this.ctx.ctx, - toBounced(t.name), - ); - writeSerializer( - t.name, - t.kind === "contract", - allocation, - this.ctx, - ); - writeOptionalSerializer(t.name, this.ctx); - writeParser( - t.name, - t.kind === "contract", - allocation, - this.ctx, - ); - writeOptionalParser(t.name, this.ctx); - writeBouncedParser( - t.name, - t.kind === "contract", - allocationBounced, - this.ctx, - ); - } - } - } - - private addAccessors(allTypes: TypeDescription[]): void { - for (const t of allTypes) { - if (t.kind === "contract" || t.kind === "struct") { - writeAccessors(t, this.ctx); - } - } - } - - private addInitSerializer(sortedTypes: TypeDescription[]): void { - for (const t of sortedTypes) { - if (t.kind === "contract" && t.init) { - const allocation = getAllocation( - this.ctx.ctx, - funcInitIdOf(t.name), - ); - writeSerializer( - funcInitIdOf(t.name), - true, - allocation, - this.ctx, - ); - writeParser(funcInitIdOf(t.name), false, allocation, this.ctx); - } - } - } - - private addStorageFunctions(sortedTypes: TypeDescription[]): void { - for (const t of sortedTypes) { - if (t.kind === "contract") { - writeStorageOps(t, this.ctx); - } - } - } - - private addStaticFunctions(): void { - const sf = getAllStaticFunctions(this.ctx.ctx); - Object.values(sf).forEach((f) => { - const gen = FunctionGen.fromTact(this.ctx); - gen.writeFunction(f); - }); - } - - private addExtensions(allTypes: TypeDescription[]): void { - for (const c of allTypes) { - if (c.kind !== "contract" && c.kind !== "trait") { - // We are rendering contract functions separately - for (const f of c.functions.values()) { - const gen = FunctionGen.fromTact(this.ctx); - gen.writeFunction(f); - } - } - } - } - - /** - * Generates a method that returns the supported interfaces, e.g.: - * ``` - * _ supported_interfaces() method_id { - * return ( - * "org.ton.introspection.v0"H >> 128, - * "org.ton.abi.ipfs.v0"H >> 128, - * "org.ton.deploy.lazy.v0"H >> 128, - * "org.ton.chain.workchain.v0"H >> 128); - * } - * ``` - */ - private writeInterfaces(type: TypeDescription): FuncAstFunctionDefinition { - const supported: string[] = []; - supported.push("org.ton.introspection.v0"); - supported.push(...getSupportedInterfaces(type, this.ctx.ctx)); - const shiftExprs: FuncAstExpression[] = supported.map((item) => - binop(string(item, "H"), ">>", int(128)), - ); - return this.ctx.fun( - [FunAttr.method_id()], - "supported_interfaces", - [], - Type.hole(), - [ret(tensor(...shiftExprs))], - { inMainContract: true }, - ); - } - - /** - * Adds the init function and the init utility function to the context. - * - * TODO: Create two separate functions when refactoring - */ - private writeInit(t: TypeDescription, init: InitDescription) { - { - const returnTy = resolveFuncType(this.ctx.ctx, t); - const funName = ops.contractInit(t.name); - const paramValues: FunParamValue[] = init.params.map((v) => [ - funcIdOf(v.name), - resolveFuncType(this.ctx.ctx, v.type), - ]); - const attrs = [FunAttr.impure()]; - const body: FuncAstStatement[] = []; - - // Unpack parameters - for (const a of init.params) { - if (!resolveFuncPrimitive(this.ctx.ctx, a.type)) { - body.push( - vardef( - "_", - resolveFuncTypeUnpack( - this.ctx.ctx, - a.type, - funcIdOf(a.name), - ), - id(funcIdOf(a.name)), - ), - ); - } - } - - // Generate self initial tensor - const initValues: FuncAstExpression[] = t.fields.map((tField) => - tField.default === undefined - ? call("null", []) - : LiteralGen.fromTact( - this.ctx, - tField.default!, - ).writeValue(), - ); - if (initValues.length > 0) { - // Special case for empty contracts - body.push( - vardef( - "_", - resolveFuncTypeUnpack( - this.ctx.ctx, - t, - funcIdOf("self"), - ), - tensor(...initValues), - ), - ); - } else { - body.push( - vardef(Type.tuple(), funcIdOf("self"), call("null", [])), - ); - } - - // Generate statements - const returns = resolveFuncTypeUnpack( - this.ctx.ctx, - t, - funcIdOf("self"), - ); - for (const s of init.ast.statements) { - body.push( - ...StatementGen.fromTact( - this.ctx, - s, - returns, - ).writeStatement(), - ); - } - - // Return result - if ( - init.ast.statements.length === 0 || - init.ast.statements[init.ast.statements.length - 1]!.kind !== - "statement_return" - ) { - body.push(ret(id(returns))); - } - - this.ctx.fun(attrs, funName, paramValues, returnTy, body); - } - - { - const returnTy = Type.tensor(Type.cell(), Type.cell()); - const funName = ops.contractInitChild(t.name); - const paramValues: FunParamValue[] = [ - ["sys", Type.cell()], - ...init.params.map( - (v) => - [ - funcIdOf(v.name), - resolveFuncType(this.ctx.ctx, v.type), - ] as FunParamValue, - ), - ]; - const attrs = [ - ...(enabledInline(this.ctx.ctx) ? [FunAttr.inline()] : []), - ]; - const body: FuncAstStatement[] = []; - - // slice sc' = sys'.begin_parse(); - // cell source = sc'~load_dict(); - // cell contracts = new_dict(); - // - // ;; Contract Code: ${t.name} - // cell mine = __tact_dict_get_code(source, ${t.uid}); - // contracts = __tact_dict_set_code(contracts, ${t.uid}, mine); - body.push( - vardef( - Type.slice(), - "sc'", - call("begin_parse", [], { receiver: id("sys'") }), - ), - ); - body.push(vardef(Type.cell(), "source", call("sc'~load_dict", []))); - body.push(vardef(Type.cell(), "contracts", call("new_dict", []))); - body.push(cr()); - body.push(comment(`Contract Code: ${t.name}`)); - body.push( - vardef( - Type.cell(), - "mine", - call("__tact_dict_get_code", [id("source"), int(t.uid)]), - ), - ); - body.push( - expr( - assign( - id("contracts"), - call("__tact_dict_set_code", [ - id("contracts"), - int(t.uid), - id("mine"), - ]), - ), - ), - ); - - // Copy contracts code - for (const c of t.dependsOn) { - // ;; Contract Code: ${c.name} - // cell code_${c.uid} = __tact_dict_get_code(source, ${c.uid}); - // contracts = __tact_dict_set_code(contracts, ${c.uid}, code_${c.uid}); - body.push(cr()); - body.push(comment(`Contract Code: ${c.name}`)); - body.push( - vardef( - Type.cell(), - `code_${c.uid}`, - call("__tact_dict_get_code", [ - id("source"), - int(c.uid), - ]), - ), - ); - body.push( - expr( - assign( - id("contracts"), - call("__tact_dict_set_code", [ - id("contracts"), - int(c.uid), - id(`code_${c.uid}`), - ]), - ), - ), - ); - } - - // Build cell - body.push(cr()); - body.push(comment("Build cell")); - body.push(vardef(Type.builder(), "b", call("begin_cell", []))); - // b = b.store_ref(begin_cell().store_dict(contracts).end_cell()); - body.push( - expr( - assign( - id("b"), - call( - "store_ref", - [ - call("end_cell", [], { - receiver: call( - "store_dict", - [id("contracts")], - { receiver: call("begin_cell", []) }, - ), - }), - ], - { receiver: id("b") }, - ), - ), - ), - ); - // b = b.store_int(false, 1); - body.push( - expr( - assign( - id("b"), - call("store_int", [bool(false), int(1)], { - receiver: id("b"), - }), - ), - ), - ); - const args = - t.init!.params.length > 0 - ? [ - call( - "b", - t.init!.params.map((a) => id(funcIdOf(a.name))), - ), - ] - : [id("b"), call("null", [])]; - body.push( - expr( - assign( - id("b"), - call(`${ops.writer(funcInitIdOf(t.name))}`, args), - ), - ), - ); - body.push( - ret( - tensor( - id("mine"), - call("end_cell", [], { receiver: id("b") }), - ), - ), - ); - - this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - context: Location.type("type:" + t.name + "$init"), - }); - } - } - - /** - * Adds functions defined within the Tact contract to the generated Func module. - * TODO: Why do we need function from *all* the contracts? - */ - private addContractFunctions(m: FuncAstModule, c: TypeDescription): void { - m.items.push(comment("", `Contract ${c.name} functions`, "")); - - if (c.init) { - this.writeInit(c, c.init); - } - - for (const tactFun of c.functions.values()) { - const funcFun = FunctionGen.fromTact(this.ctx).writeFunctionDefinition( - tactFun, - ); - // TODO: Should we really put them here? - m.items.push(funcFun); - } - } - - private commentPseudoOpcode(comment: string): string { - return beginCell() - .storeUint(0, 32) - .storeBuffer(Buffer.from(comment, "utf8")) - .endCell() - .hash() - .toString("hex", 0, 64); - } - - // TODO: refactor this bs asap: - // + two different functions depending on `kind` - // + extract methods - // + separate file - private writeRouter( - type: TypeDescription, - kind: "internal" | "external", - ): FuncAstFunctionDefinition { - const internal = kind === "internal"; - const attrs: FuncAstFunctionAttribute[] = [ - FunAttr.impure(), - FunAttr.inline_ref(), - ]; - const name = ops.contractRouter(type.name, kind); - const returnTy = Type.tensor( - resolveFuncType(this.ctx.ctx, type), - Type.int(), - ); - const paramValues: [string, FuncAstType][] = internal - ? [ - ["self", resolveFuncType(this.ctx.ctx, type)], - ["msg_bounced", Type.int()], - ["in_msg", Type.slice()], - ] - : [ - ["self", resolveFuncType(this.ctx.ctx, type)], - ["in_msg", Type.slice()], - ]; - const functionBody: FuncAstStatement[] = []; - - // ;; Handle bounced messages - // if (msg_bounced) { - // ... - // } - if (internal) { - functionBody.push(comment("Handle bounced messages")); - const body: FuncAstStatement[] = []; - const bounceReceivers = type.receivers.filter((r) => { - return r.selector.kind === "bounce-binary"; - }); - - const fallbackReceiver = type.receivers.find((r) => { - return r.selector.kind === "bounce-fallback"; - }); - - const condBody: FuncAstStatement[] = []; - if (fallbackReceiver ?? bounceReceivers.length > 0) { - // ;; Skip 0xFFFFFFFF - // in_msg~skip_bits(32); - condBody.push(comment("Skip 0xFFFFFFFF")); - condBody.push(expr(call("in_msg~skip_bits", [int(32)]))); - } - - if (bounceReceivers.length > 0) { - // ;; Parse op - // int op = 0; - // if (slice_bits(in_msg) >= 32) { - // op = in_msg.preload_uint(32); - // } - condBody.push(comment("Parse op")); - condBody.push(vardef(Type.int(), "op", int(0))); - condBody.push( - condition( - binop( - call("slice_bits", [id("in_msg")]), - ">=", - int(30), - ), - [ - expr( - assign( - id("op"), - call(id("in_msg.preload_uint"), [int(32)]), - ), - ), - ], - ), - ); - } - - for (const r of bounceReceivers) { - const selector = r.selector; - if (selector.kind !== "bounce-binary") - throw Error(`Invalid selector type: ${selector.kind}`); // Should not happen - body.push( - comment(`Bounced handler for ${selector.type} message`), - ); - // XXX: We assert `header` to be non-null only in the new backend; otherwise it could be a compiler bug - body.push( - condition( - binop( - id("op"), - "==", - int(getType(this.ctx.ctx, selector.type).header!), - ), - [ - vardef( - "_", - "msg", - call( - id( - `in_msg~${selector.bounced ? ops.readerBounced(selector.type) : ops.reader(selector.type)}`, - ), - [], - ), - ), - expr( - call( - id( - `self~${ops.receiveTypeBounce(type.name, selector.type)}`, - ), - [id("msg")], - ), - ), - ret(tensor(id("self"), bool(true))), - ], - ), - ); - } - - if (fallbackReceiver) { - const selector = fallbackReceiver.selector; - if (selector.kind !== "bounce-fallback") - throw Error("Invalid selector type: " + selector.kind); - body.push(comment("Fallback bounce receiver")); - body.push( - expr( - call(id(`self~${ops.receiveBounceAny(type.name)}`), [ - id("in_msg"), - ]), - ), - ); - body.push(ret(tensor(id("self"), bool(true)))); - } else { - body.push(ret(tensor(id("self"), bool(true)))); - } - const cond = condition(id("msg_bounced"), body); - functionBody.push(cond); - functionBody.push(cr()); - } - - // ;; Parse incoming message - // int op = 0; - // if (slice_bits(in_msg) >= 32) { - // op = in_msg.preload_uint(32); - // } - functionBody.push(comment("Parse incoming message")); - functionBody.push(vardef(Type.int(), "op", int(0))); - functionBody.push( - condition( - binop(call(id("slice_bits"), [id("in_msg")]), ">=", int(32)), - [ - expr( - assign( - id("op"), - call("in_msg.preload_uint", [int(32)]), - ), - ), - ], - ), - ); - functionBody.push(cr()); - - // Non-empty receivers - for (const f of type.receivers) { - const selector = f.selector; - - // Generic receiver - if ( - selector.kind === - (internal ? "internal-binary" : "external-binary") - ) { - const allocation = getType(this.ctx.ctx, selector.type); - if (!allocation.header) { - throw Error(`Invalid allocation: ${selector.type}`); - } - functionBody.push(comment(`Receive ${selector.type} message`)); - functionBody.push( - condition(binop(id("op"), "==", int(allocation.header)), [ - vardef( - "_", - "msg", - call(`in_msg~${ops.reader(selector.type)}`, []), - ), - expr( - call( - `self~${ops.receiveType(type.name, kind, selector.type)}`, - [id("msg")], - ), - ), - ]), - ); - } - - if ( - selector.kind === - (internal ? "internal-empty" : "external-empty") - ) { - // ;; Receive empty message - // if ((op == 0) & (slice_bits(in_msg) <= 32)) { - // self~${ops.receiveEmpty(type.name, kind)}(); - // return (self, true); - // } - functionBody.push(comment("Receive empty message")); - functionBody.push( - condition( - binop( - binop(id("op"), "==", int(0)), - "&", - binop( - call("slice_bits", [id("in_msg")]), - "<=", - int(32), - ), - ), - [ - expr( - call( - `self~${ops.receiveEmpty(type.name, kind)}`, - [], - ), - ), - ret(tensor(id("self"), bool(true))), - ], - ), - ); - functionBody.push(cr()); - } - } - - // Text resolvers - const hasComments = !!type.receivers.find((v) => - internal - ? v.selector.kind === "internal-comment" || - v.selector.kind === "internal-comment-fallback" - : v.selector.kind === "external-comment" || - v.selector.kind === "external-comment-fallback", - ); - if (hasComments) { - // ;; Text Receivers - // if (op == 0) { - // ... - // } - functionBody.push(comment("Text Receivers")); - const cond = binop(id("op"), "==", int(0)); - const condBody: FuncAstStatement[] = []; - if ( - type.receivers.find( - (v) => - v.selector.kind === - (internal ? "internal-comment" : "external-comment"), - ) - ) { - // var text_op = slice_hash(in_msg); - condBody.push( - vardef("_", "text_op", call("slice_hash", [id("in_msg")])), - ); - for (const r of type.receivers) { - if ( - r.selector.kind === - (internal ? "internal-comment" : "external-comment") - ) { - // ;; Receive "increment" message - // if (text_op == 0xc4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae) { - // self~$A$_internal_text_c4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae(); - // return (self, true); - // } - const hash = this.commentPseudoOpcode( - r.selector.comment, - ); - condBody.push( - comment(`Receive "${r.selector.comment}" message`), - ); - condBody.push( - condition(binop(id("text_op"), "==", hex(hash)), [ - expr( - call( - `self~${ops.receiveText(type.name, kind, hash)}`, - [], - ), - ), - ret(tensor(id("self"), bool(true))), - ]), - ); - } - } - } - - // Comment fallback resolver - const fallback = type.receivers.find( - (v) => - v.selector.kind === - (internal - ? "internal-comment-fallback" - : "external-comment-fallback"), - ); - if (fallback) { - condBody.push( - condition( - binop( - call("slice_bits", [id("in_msg")]), - ">=", - int(32), - ), - [ - expr( - call( - id( - `self~${ops.receiveAnyText(type.name, kind)}`, - ), - [call("in_msg.skip_bits", [int(32)])], - ), - ), - ret(tensor(id("self"), bool(true))), - ], - ), - ); - } - functionBody.push(condition(cond, condBody)); - functionBody.push(cr()); - } - - // Fallback - const fallbackReceiver = type.receivers.find( - (v) => - v.selector.kind === - (internal ? "internal-fallback" : "external-fallback"), - ); - if (fallbackReceiver) { - // ;; Receiver fallback - // self~${ops.receiveAny(type.name, kind)}(in_msg); - // return (self, true); - functionBody.push(comment("Receiver fallback")); - functionBody.push( - expr( - call(`self~${ops.receiveAny(type.name, kind)}`, [ - id("in_msg"), - ]), - ), - ); - functionBody.push(ret(tensor(id("self"), bool(true)))); - } else { - // return (self, false); - functionBody.push(ret(tensor(id("self"), bool(false)))); - } - - return this.ctx.fun(attrs, name, paramValues, returnTy, functionBody, { - inMainContract: true, - }); - } - - private writeReceiver( - self: TypeDescription, - f: ReceiverDescription, - ): FuncAstFunctionDefinition { - const selector = f.selector; - const selfRes = resolveFuncTypeUnpack( - this.ctx.ctx, - self, - funcIdOf("self"), - ); - const selfType = resolveFuncType(this.ctx.ctx, self); - const selfUnpack = vardef( - "_", - resolveFuncTypeUnpack(this.ctx.ctx, self, funcIdOf("self")), - id(funcIdOf("self")), - ); - - // Binary receiver - if ( - selector.kind === "internal-binary" || - selector.kind === "external-binary" - ) { - const returnTy = Type.tensor(selfType, unit()); - const funName = ops.receiveType( - self.name, - selector.kind === "internal-binary" ? "internal" : "external", - selector.type, - ); - const paramValues: FunParamValue[] = [ - [funcIdOf("self"), selfType], - [ - funcIdOf(selector.name), - resolveFuncType(this.ctx.ctx, selector.type), - ], - ]; - const attrs: FuncAstFunctionAttribute[] = [ - FunAttr.impure(), - FunAttr.inline(), - ]; - const body: FuncAstStatement[] = [selfUnpack]; - body.push( - vardef( - "_", - resolveFuncTypeUnpack( - this.ctx.ctx, - selector.type, - funcIdOf(selector.name), - ), - id(funcIdOf(selector.name)), - ), - ); - f.ast.statements.forEach((s) => - body.push( - ...StatementGen.fromTact( - this.ctx, - s, - selfRes, - ).writeStatement(), - ), - ); - if ( - f.ast.statements.length === 0 || - f.ast.statements[f.ast.statements.length - 1]!.kind !== - "statement_return" - ) { - body.push(ret(tensor(id(selfRes), unit()))); - } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - // Empty receiver - if ( - selector.kind === "internal-empty" || - selector.kind === "external-empty" - ) { - const returnTy = Type.tensor(selfType, unit()); - const funName = ops.receiveEmpty( - self.name, - selector.kind === "internal-empty" ? "internal" : "external", - ); - const paramValues: FunParamValue[] = [[funcIdOf("self"), selfType]]; - const attrs: FuncAstFunctionAttribute[] = [ - FunAttr.impure(), - FunAttr.inline(), - ]; - const body: FuncAstStatement[] = [selfUnpack]; - f.ast.statements.forEach((s) => - body.push( - ...StatementGen.fromTact( - this.ctx, - s, - selfRes, - ).writeStatement(), - ), - ); - if ( - f.ast.statements.length === 0 || - f.ast.statements[f.ast.statements.length - 1]!.kind !== - "statement_return" - ) { - body.push(ret(tensor(id(selfRes), unit()))); - } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - // Comment receiver - if ( - selector.kind === "internal-comment" || - selector.kind === "external-comment" - ) { - const hash = commentPseudoOpcode(selector.comment); - const returnTy = Type.tensor(selfType, unit()); - const funName = ops.receiveText( - self.name, - selector.kind === "internal-comment" ? "internal" : "external", - hash, - ); - const paramValues: FunParamValue[] = [[funcIdOf("self"), selfType]]; - const attrs: FuncAstFunctionAttribute[] = [ - FunAttr.impure(), - FunAttr.inline(), - ]; - const body: FuncAstStatement[] = [selfUnpack]; - f.ast.statements.forEach((s) => - body.push( - ...StatementGen.fromTact( - this.ctx, - s, - selfRes, - ).writeStatement(), - ), - ); - if ( - f.ast.statements.length === 0 || - f.ast.statements[f.ast.statements.length - 1]!.kind !== - "statement_return" - ) { - body.push(ret(tensor(id(selfRes), unit()))); - } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - // Fallback - if ( - selector.kind === "internal-comment-fallback" || - selector.kind === "external-comment-fallback" - ) { - const returnTy = Type.tensor(selfType, unit()); - const funName = ops.receiveAnyText( - self.name, - selector.kind === "internal-comment-fallback" - ? "internal" - : "external", - ); - const paramValues: FunParamValue[] = [ - [funcIdOf("self"), selfType], - [funcIdOf(selector.name), Type.slice()], - ]; - const attrs: FuncAstFunctionAttribute[] = [ - FunAttr.impure(), - FunAttr.inline(), - ]; - const body: FuncAstStatement[] = [selfUnpack]; - f.ast.statements.forEach((s) => - body.push( - ...StatementGen.fromTact( - this.ctx, - s, - selfRes, - ).writeStatement(), - ), - ); - if ( - f.ast.statements.length === 0 || - f.ast.statements[f.ast.statements.length - 1]!.kind !== - "statement_return" - ) { - body.push(ret(tensor(id(selfRes), unit()))); - } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - // Fallback - if (selector.kind === "internal-fallback") { - const returnTy = Type.tensor(selfType, unit()); - const funName = ops.receiveAny(self.name, "internal"); - const paramValues: FunParamValue[] = [ - [funcIdOf("self"), selfType], - [funcIdOf(selector.name), Type.slice()], - ]; - const attrs: FuncAstFunctionAttribute[] = [ - FunAttr.impure(), - FunAttr.inline(), - ]; - const body: FuncAstStatement[] = [selfUnpack]; - f.ast.statements.forEach((s) => - body.push( - ...StatementGen.fromTact( - this.ctx, - s, - selfRes, - ).writeStatement(), - ), - ); - if ( - f.ast.statements.length === 0 || - f.ast.statements[f.ast.statements.length - 1]!.kind !== - "statement_return" - ) { - body.push(ret(tensor(id(selfRes), unit()))); - } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - // Bounced - if (selector.kind === "bounce-fallback") { - const returnTy = Type.tensor(selfType, unit()); - const funName = ops.receiveBounceAny(self.name); - const paramValues: FunParamValue[] = [ - [funcIdOf("self"), selfType], - [funcIdOf(selector.name), Type.slice()], - ]; - const attrs: FuncAstFunctionAttribute[] = [ - FunAttr.impure(), - FunAttr.inline(), - ]; - const body: FuncAstStatement[] = [selfUnpack]; - f.ast.statements.forEach((s) => - body.push( - ...StatementGen.fromTact( - this.ctx, - s, - selfRes, - ).writeStatement(), - ), - ); - if ( - f.ast.statements.length === 0 || - f.ast.statements[f.ast.statements.length - 1]!.kind !== - "statement_return" - ) { - body.push(ret(tensor(id(selfRes), unit()))); - } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - if (selector.kind === "bounce-binary") { - const returnTy = Type.tensor(selfType, unit()); - const funName = ops.receiveTypeBounce(self.name, selector.type); - const paramValues: FunParamValue[] = [ - [funcIdOf("self"), selfType], - [ - funcIdOf(selector.name), - resolveFuncType( - this.ctx.ctx, - selector.type, - false, - selector.bounced, - ), - ], - ]; - const attrs: FuncAstFunctionAttribute[] = [ - FunAttr.impure(), - FunAttr.inline(), - ]; - const body: FuncAstStatement[] = [selfUnpack]; - body.push( - vardef( - "_", - resolveFuncTypeUnpack( - this.ctx.ctx, - selector.type, - funcIdOf(selector.name), - false, - selector.bounced, - ), - id(funcIdOf(selector.name)), - ), - ); - f.ast.statements.forEach((s) => - body.push( - ...StatementGen.fromTact( - this.ctx, - s, - selfRes, - ).writeStatement(), - ), - ); - if ( - f.ast.statements.length === 0 || - f.ast.statements[f.ast.statements.length - 1]!.kind !== - "statement_return" - ) { - body.push(ret(tensor(id(selfRes), unit()))); - } - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - throw new Error( - `Unknown selector ${selector.kind}:\n${JSONbig.stringify(selector, null, 2)}`, - ); - } - - private writeGetter(f: FunctionDescription): FuncAstFunctionDefinition { - // Render tensors - const self = f.self !== null ? getType(this.ctx.ctx, f.self) : null; - if (!self) { - throw new Error(`No self type for getter ${idTextErr(f.name)}`); // Impossible - } - const returnTy = Type.hole(); - const funName = `%${f.name}`; - const paramValues: FunParamValue[] = f.params.map((v) => [ - funcIdOf(v.name), - resolveFuncTupleType(this.ctx.ctx, v.type), - ]); - const attrs = [FunAttr.method_id(getMethodId(f.name))]; - - const body: FuncAstStatement[] = []; - // Unpack parameters - for (const param of f.params) { - unwrapExternal( - this.ctx.ctx, - funcIdOf(param.name), - funcIdOf(param.name), - param.type, - ); - } - // Load contract state - body.push(vardef("_", "self", call(ops.contractLoad(self.name), []))); - // Execute get method - body.push( - vardef( - "_", - "res", - call( - `self~${ops.extension(self.name, f.name)}`, - f.params.map((v) => id(funcIdOf(v.name))), - ), - ), - ); - // Pack if needed - if (f.returns.kind === "ref") { - const t = getType(this.ctx.ctx, f.returns.name); - if (t.kind === "struct") { - if (f.returns.optional) { - body.push( - ret(call(ops.typeToOptExternal(t.name), [id("res")])), - ); - } else { - body.push( - ret(call(ops.typeToExternal(t.name), [id("res")])), - ); - } - return this.ctx.fun( - attrs, - funName, - paramValues, - returnTy, - body, - { inMainContract: true }, - ); - } - } - // Return result - body.push(ret(id("res"))); - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - private makeInternalReceiver( - type: TypeDescription, - ): FuncAstFunctionDefinition { - // () recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure - const returnTy = unit(); - const funName = "recv_internal"; - const paramValues: FunParamValue[] = [ - ["msg_value", Type.int()], - ["in_msg_cell", Type.cell()], - ["in_msg", Type.slice()], - ]; - const attrs = [FunAttr.impure()]; - const body: FuncAstStatement[] = []; - - // Load context - body.push(comment("Context")); - body.push( - vardef( - "_", - "cs", - call("begin_parse", [], { receiver: id("in_msg_cell") }), - ), - ); - body.push(vardef("_", "msg_flags", call("cs~load_uint", [int(4)]))); // int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool - body.push( - vardef( - "_", - "msg_bounced", - unop("-", binop(id("msg_flags"), "&", int(1))), - ), - ); - body.push( - vardef( - Type.slice(), - "msg_sender_addr", - call("__tact_verify_address", [call("cs~load_msg_addr", [])]), - ), - ); - body.push( - expr( - assign( - id("__tact_context"), - tensor( - id("msg_bounced"), - id("msg_sender_addr"), - id("msg_value"), - id("cs"), - ), - ), - ), - ); - body.push( - expr(assign(id("__tact_context_sender"), id("msg_sender_addr"))), - ); - body.push(cr()); - - // Load self - body.push(comment("Load contract data")); - body.push(vardef("_", "self", call(ops.contractLoad(type.name), []))); - body.push(cr()); - - // Process operation - body.push(comment("Handle operation")); - body.push( - vardef( - Type.int(), - "handled", - call(`self~${ops.contractRouter(type.name, "internal")}`, [ - id("msg_bounced"), - id("in_msg"), - ]), - ), - ); - body.push(cr()); - - // Throw if not handled - body.push(comment("Throw if not handled")); - body.push( - expr( - call("throw_unless", [ - int(contractErrors.invalidMessage.id), - id("handled"), - ]), - ), - ); - body.push(cr()); - - // Persist state - body.push(comment("Persist state")); - body.push(expr(call(ops.contractStore(type.name), [id("self")]))); - - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - private makeExternalReceiver( - type: TypeDescription, - ): FuncAstFunctionDefinition { - // () recv_external(slice in_msg) impure - const returnTy = unit(); - const funName = "recv_internal"; - const paramValues: FunParamValue[] = [ - ["msg_value", Type.int()], - ["in_msg_cell", Type.cell()], - ["in_msg", Type.slice()], - ]; - const attrs = [FunAttr.impure()]; - const body: FuncAstStatement[] = []; - - // Load self - body.push(comment("Load contract data")); - body.push(vardef("_", "self", call(ops.contractLoad(type.name), []))); - body.push(cr()); - - // Process operation - body.push(comment("Handle operation")); - body.push( - vardef( - Type.int(), - "handled", - call(`self~${ops.contractRouter(type.name, "external")}`, [ - id("in_msg"), - ]), - ), - ); - body.push(cr()); - - // Throw if not handled - body.push(comment("Throw if not handled")); - body.push( - expr( - call("throw_unless", [ - int(contractErrors.invalidMessage.id), - id("handled"), - ]), - ), - ); - body.push(cr()); - - // Persist state - body.push(comment("Persist state")); - body.push(expr(call(ops.contractStore(type.name), [id("self")]))); - - return this.ctx.fun(attrs, funName, paramValues, returnTy, body, { - inMainContract: true, - }); - } - - /** - * Adds items from the main Tact contract creating a program containing the entrypoint. - * - * XXX: In the old backend, they simply push multiply functions here, creating an entry - * for a non-existent `$main` function. - */ - private writeMainContract( - m: FuncAstModule, - contractTy: TypeDescription, - ): void { - m.items.push( - comment("", `Receivers of a Contract ${contractTy.name}`, ""), - ); - - // Write receivers - for (const r of Object.values(contractTy.receivers)) { - m.items.push(this.writeReceiver(contractTy, r)); - } - - m.items.push( - comment("", `Get methods of a Contract ${contractTy.name}`, ""), - ); - - // Getters - for (const f of contractTy.functions.values()) { - if (f.isGetter) { - m.items.push(this.writeGetter(f)); - } - } - - // Interfaces - m.items.push(this.writeInterfaces(contractTy)); - - // ABI: - // _ get_abi_ipfs() method_id { - // return "${abiLink}"; - // } - m.items.push( - this.ctx.fun( - [FunAttr.method_id()], - "get_abi_ipfs", - [], - Type.hole(), - [ret(string(this.abiLink))], - { inMainContract: true }, - ), - ); - - // Deployed - //_ lazy_deployment_completed() method_id { - // return get_data().begin_parse().load_int(1); - // } - m.items.push( - this.ctx.fun( - [FunAttr.method_id()], - "lazy_deployment_completed", - [], - Type.hole(), - [ - ret( - call("load_int", [int(1)], { - receiver: call("begin_parse", [], { - receiver: call("get_data", []), - }), - }), - ), - ], - { inMainContract: true }, - ), - ); - - m.items.push( - comment("", `Routing of a Contract ${contractTy.name}`, ""), - ); - const hasExternal = contractTy.receivers.find((v) => - v.selector.kind.startsWith("external-"), - ); - m.items.push(this.writeRouter(contractTy, "internal")); - if (hasExternal) { - m.items.push(this.writeRouter(contractTy, "external")); - } - - // Render internal receiver - m.items.push(this.makeInternalReceiver(contractTy)); - if (hasExternal) { - // Render external receiver - m.items.push(this.makeExternalReceiver(contractTy)); - } - } - - public writeAll(): FuncAstModule { - const m: FuncAstModule = mod(); - - const allTypes = Object.values(getAllTypes(this.ctx.ctx)); - const contracts = allTypes.filter((v) => v.kind === "contract"); - const contract = contracts.find((v) => v.name === this.contractName); - if (contract === undefined) { - throw Error(`Contract "${this.contractName}" not found`); - } - - this.writeStdlib(); - - const sortedTypes = getSortedTypes(this.ctx.ctx); - - this.addSerializers(sortedTypes); - this.addAccessors(allTypes); - this.addInitSerializer(sortedTypes); - this.addStorageFunctions(sortedTypes); - this.addStaticFunctions(); - this.addExtensions(allTypes); - contracts.forEach((c) => this.addContractFunctions(m, c)); - this.writeMainContract(m, contract); - - return m; - } -} diff --git a/src/codegen/statement.ts b/src/codegen/statement.ts deleted file mode 100644 index b70cd09e3..000000000 --- a/src/codegen/statement.ts +++ /dev/null @@ -1,522 +0,0 @@ -import { throwInternalCompilerError } from "../errors"; -import { funcIdOf, cast, ops, freshIdentifier } from "./util"; -import { getType, resolveTypeRef } from "../types/resolveDescriptors"; -import { getExpType } from "../types/resolveExpression"; -import { TypeRef } from "../types/types"; -import { - AstCondition, - AstStatementReturn, - AstStatementUntil, - AstStatementRepeat, - AstStatementTryCatch, - AstStatementTry, - AstStatementWhile, - AstStatementForEach, - AstStatementAugmentedAssign, - AstStatementAssign, - AstStatementLet, - AstExpression, - AstStatement, - isWildcard, - tryExtractPath, -} from "../grammar/ast"; -import { ExpressionGen, writePathExpression, WriterContext } from "."; -import { resolveFuncTypeUnpack, resolveFuncType } from "./type"; -import { - FuncAstStatement, - FuncAstStatementCondition, - FuncAstExpression, - FuncCatchDefintions, -} from "../func/grammar"; -import { - id, - expr, - call, - ret, - while_, - try_, - doUntil, - int, - repeat, - augassign, - tensor, - assign, - unit, - condition, - tryCatch, - conditionElseif, - vardef, - Type, -} from "../func/syntaxConstructors"; - -/** - * Encapsulates generation of Func statements from the Tact statement. - */ -export class StatementGen { - /** - * @param tactStmt Tact AST statement - * @param selfName Actual name of the `self` parameter present in the Func code. - * @param returns The return value of the return statement. - */ - private constructor( - private ctx: WriterContext, - private tactStmt: AstStatement, - private selfName?: string, - private returns?: TypeRef, - ) {} - - static fromTact( - ctx: WriterContext, - tactStmt: AstStatement, - selfVarName?: string, - returns?: TypeRef, - ): StatementGen { - return new StatementGen(ctx, tactStmt, selfVarName, returns); - } - - /** - * Translates an expression in the current context. - */ - private makeExpr(expr: AstExpression): FuncAstExpression { - return ExpressionGen.fromTact(this.ctx, expr).writeExpression(); - } - - private writeCastedExpr( - expr: AstExpression, - to: TypeRef, - ): FuncAstExpression { - return ExpressionGen.fromTact(this.ctx, expr).writeCastedExpression(to); - } - - /** - * Tranforms the Tact conditional statement to the Func one. - */ - private writeCondition(f: AstCondition): FuncAstStatementCondition { - const writeStmt = (stmt: AstStatement) => - StatementGen.fromTact( - this.ctx, - stmt, - this.selfName, - this.returns, - ).writeStatement(); - const cond = this.makeExpr(f.condition); - const thenBlock = f.trueStatements.map(writeStmt).flat(); - const elseBlock = f.falseStatements?.map(writeStmt).flat(); - if (f.elseif) { - return conditionElseif( - cond, - thenBlock, - this.makeExpr(f.elseif.condition), - f.elseif.trueStatements.map(writeStmt).flat(), - elseBlock, - ); - } else { - return condition(cond, thenBlock, elseBlock); - } - } - - public writeStatement(): FuncAstStatement[] | never { - switch (this.tactStmt.kind) { - case "statement_return": { - return [this.writeReturnStatement(this.tactStmt)]; - } - case "statement_let": { - return [this.writeLetStatement(this.tactStmt)]; - } - case "statement_assign": { - return [this.writeAssignStatement(this.tactStmt)]; - } - case "statement_augmentedassign": { - return [this.writeAugmentedAssignStatement(this.tactStmt)]; - } - case "statement_condition": { - return [this.writeCondition(this.tactStmt)]; - } - case "statement_expression": { - return [expr(this.makeExpr(this.tactStmt.expression))]; - } - case "statement_while": { - return [this.writeWhileStatement(this.tactStmt)]; - } - case "statement_until": { - return [this.writeUntilStatement(this.tactStmt)]; - } - case "statement_repeat": { - return [this.writeRepeatStatement(this.tactStmt)]; - } - case "statement_try": { - return [this.writeTryStatement(this.tactStmt)]; - } - case "statement_try_catch": { - return [this.writeTryCatchStatement(this.tactStmt)]; - } - case "statement_foreach": { - return this.writeForeachStatement(this.tactStmt); - } - default: { - throw Error(`Unknown statement: ${this.tactStmt}`); - } - } - } - - private writeReturnStatement(stmt: AstStatementReturn): FuncAstStatement { - const selfVar = this.selfName ? id(this.selfName) : undefined; - const getValue = (expr: FuncAstExpression): FuncAstExpression => - this.selfName ? tensor(selfVar!, expr) : expr; - - if (stmt.expression) { - const castedReturns = this.writeCastedExpr( - stmt.expression, - this.returns!, - ); - return ret(getValue(castedReturns)); - } else { - return ret(getValue(unit())); - } - } - - private writeLetStatement(stmt: AstStatementLet): FuncAstStatement { - // Underscore name case - if (isWildcard(stmt.name)) { - return expr(this.makeExpr(stmt.expression)); - } - - // Contract/struct case - const t = - stmt.type === null - ? getExpType(this.ctx.ctx, stmt.expression) - : resolveTypeRef(this.ctx.ctx, stmt.type); - - if (t.kind === "ref") { - const tt = getType(this.ctx.ctx, t.name); - if (tt.kind === "contract" || tt.kind === "struct") { - if (t.optional) { - const name = funcIdOf(stmt.name); - const init = this.writeCastedExpr(stmt.expression, t); - return vardef(Type.tuple(), name, init); - } else { - const name = resolveFuncTypeUnpack( - this.ctx.ctx, - t, - funcIdOf(stmt.name), - ); - const init = this.writeCastedExpr(stmt.expression, t); - return vardef("_", name, init); - } - } - } - - const ty = resolveFuncType(this.ctx.ctx, t); - const name = funcIdOf(stmt.name); - const init = this.writeCastedExpr(stmt.expression, t); - return vardef(ty, name, init); - } - - private writeAssignStatement(stmt: AstStatementAssign): FuncAstStatement { - const lvaluePath = tryExtractPath(stmt.path); - if (lvaluePath === null) { - throwInternalCompilerError( - [ - `Assignments are allowed only into path expressions, i.e. identifiers, or sequences`, - `of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, - ].join(" "), - stmt.path.loc, - ); - } - const path = writePathExpression(lvaluePath); - const t = getExpType(this.ctx.ctx, stmt.path); - if (t.kind === "ref") { - const tt = getType(this.ctx.ctx, t.name); - if (tt.kind === "contract" || tt.kind === "struct") { - const lhs = id( - resolveFuncTypeUnpack(this.ctx.ctx, t, path.value), - ); - const rhs = this.writeCastedExpr(stmt.expression, t); - return expr(assign(lhs, rhs)); - } - } - const rhs = this.writeCastedExpr(stmt.expression, t); - return expr(assign(path, rhs)); - } - - private writeAugmentedAssignStatement( - stmt: AstStatementAugmentedAssign, - ): FuncAstStatement { - const lvaluePath = tryExtractPath(stmt.path); - if (lvaluePath === null) { - throwInternalCompilerError( - [ - `Assignments are allowed only into path expressions, i.e. identifiers, or sequences`, - `of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, - ].join(" "), - stmt.path.loc, - ); - } - const path = writePathExpression(lvaluePath); - const t = getExpType(this.ctx.ctx, stmt.path); - return expr( - assign( - path, - cast( - this.ctx.ctx, - t, - t, - augassign( - path, - `${stmt.op}=`, - this.makeExpr(stmt.expression), - ), - ), - ), - ); - } - - private writeWhileStatement(stmt: AstStatementWhile): FuncAstStatement { - const condition = this.makeExpr(stmt.condition); - const body = stmt.statements - .map((s) => - StatementGen.fromTact( - this.ctx, - s, - this.selfName, - this.returns, - ).writeStatement(), - ) - .flat(); - return while_(condition, body); - } - - private writeUntilStatement(stmt: AstStatementUntil): FuncAstStatement { - const condition = this.makeExpr(stmt.condition); - const body = stmt.statements - .map((s) => - StatementGen.fromTact( - this.ctx, - s, - this.selfName, - this.returns, - ).writeStatement(), - ) - .flat(); - return doUntil(condition, body); - } - - private writeRepeatStatement(stmt: AstStatementRepeat): FuncAstStatement { - const iterations = this.makeExpr(stmt.iterations); - const body = stmt.statements - .map((s) => - StatementGen.fromTact( - this.ctx, - s, - this.selfName, - this.returns, - ).writeStatement(), - ) - .flat(); - return repeat(iterations, body); - } - - private writeTryStatement(stmt: AstStatementTry): FuncAstStatement { - const body = stmt.statements - .map((s) => - StatementGen.fromTact( - this.ctx, - s, - this.selfName, - this.returns, - ).writeStatement(), - ) - .flat(); - return try_(body); - } - - private writeTryCatchStatement( - stmt: AstStatementTryCatch, - ): FuncAstStatement { - const generateStatements = (statements: any[]) => - statements - .map((s) => - StatementGen.fromTact( - this.ctx, - s, - this.selfName, - this.returns, - ).writeStatement(), - ) - .flat(); - const body = generateStatements(stmt.statements); - const catchStmts = generateStatements(stmt.catchStatements); - const catchNames: "_" | FuncCatchDefintions = isWildcard(stmt.catchName) - ? "_" - : ({ - exceptionName: id("_"), - exitCodeName: id(funcIdOf(stmt.catchName)), - } as FuncCatchDefintions); - return tryCatch(body, catchNames, catchStmts); - } - - private writeForeachStatement( - stmt: AstStatementForEach, - ): FuncAstStatement[] { - const mapPath = tryExtractPath(stmt.map); - if (mapPath === null) { - throwInternalCompilerError( - [ - "foreach is only allowed over maps that are path expressions, i.e. identifiers, or sequences", - `of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, - ].join(" "), - stmt.map.loc, - ); - } - const path = writePathExpression(mapPath); - const t = getExpType(this.ctx.ctx, stmt.map); - if (t.kind !== "map") { - throw Error("Unknown map type"); - } - const flag = freshIdentifier("flag"); - const key = isWildcard(stmt.keyName) - ? freshIdentifier("underscore") - : funcIdOf(stmt.keyName); - const value = isWildcard(stmt.valueName) - ? freshIdentifier("underscore") - : funcIdOf(stmt.valueName); - - // Handle Int key - if (t.key === "Int") { - // Generates FunC code for non-struct values - const generatePrimitive = ( - varFun: FuncAstExpression, - funcall: FuncAstExpression, - ): FuncAstStatement[] => { - let whileBody: FuncAstStatement[] = []; - for (const s of stmt.statements) { - whileBody = whileBody.concat( - StatementGen.fromTact( - this.ctx, - s, - this.selfName, - this.returns, - ).writeStatement(), - ); - } - whileBody.push( - expr(assign(tensor(id(key), id(value), id(flag)), funcall)), - ); - return [ - vardef("_", [key, value, flag], varFun), - while_(id(flag), whileBody), - ]; - }; - let bits = 257; - let kind = "int"; - if (t.keyAs?.startsWith("int")) { - bits = parseInt(t.keyAs.slice(3), 10); - } else if (t.keyAs?.startsWith("uint")) { - bits = parseInt(t.keyAs.slice(4), 10); - kind = "uint"; - } - if (t.value === "Int") { - let vBits = 257; - let vKind = "int"; - if (t.valueAs?.startsWith("int")) { - vBits = parseInt(t.valueAs.slice(3), 10); - } else if (t.valueAs?.startsWith("uint")) { - vKind = "uint"; - } - return generatePrimitive( - call(`__tact_dict_min_${kind}_${vKind}`, [ - path, - int(bits), - int(vBits), - ]), - call(`__tact_dict_next_${kind}_${vKind}`, [ - path, - id(key), - int(bits), - int(vBits), - ]), - ); - } else if (t.value === "Bool") { - return generatePrimitive( - call(`__tact_dict_min_${kind}_int`, [ - path, - int(bits), - int(1), - ]), - call(`__tact_dict_next_${kind}_int`, [ - path, - int(bits), - id(key), - int(1), - ]), - ); - } else if (t.value === "Cell") { - return generatePrimitive( - call(`__tact_dict_next_${kind}_cell`, [ - path, - int(bits), - id(key), - ]), - call(`__tact_dict_next_${kind}_cell`, [ - path, - int(bits), - id(key), - ]), - ); - } else if (t.value === "Address") { - return generatePrimitive( - call(`__tact_dict_min_${kind}_slice`, [path, int(bits)]), - call(`__tact_dict_next_${kind}_slice`, [ - path, - int(bits), - id(key), - ]), - ); - } else { - // Value is a struct - const v = vardef( - "_", - [key, value, flag], - call(`__tact_dict_min_${kind}_cell`, [path, int(bits)]), - ); - let whileBody: FuncAstStatement[] = []; - whileBody.push( - vardef( - "_", - resolveFuncTypeUnpack( - this.ctx.ctx, - t.value, - funcIdOf(stmt.valueName), - ), - call(ops.typeNotNull(t.value), [id(value)]), - ), - ); - for (const s of stmt.statements) { - whileBody = whileBody.concat( - StatementGen.fromTact( - this.ctx, - s, - this.selfName, - this.returns, - ).writeStatement(), - ); - } - whileBody.push( - expr( - assign( - tensor(id(key), id(value), id(flag)), - call(`__tact_dict_next_${kind}_cell`, [ - path, - int(bits), - id(key), - ]), - ), - ), - ); - return [v, while_(id(flag), whileBody)]; - } - } - - return []; - } -} diff --git a/src/codegen/storage.ts b/src/codegen/storage.ts deleted file mode 100644 index 914a54e1d..000000000 --- a/src/codegen/storage.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { contractErrors } from "../abi/errors"; -import { enabledMasterchain } from "../config/features"; -import { TypeDescription } from "../types/types"; -import { WriterContext, Location } from "./context"; -import { FuncPrettyPrinter } from "../func/prettyPrinter"; -import { FuncAstType } from "../func/grammar"; -import { funcIdOf, funcInitIdOf, ops } from "./util"; -import { resolveFuncType } from "./type"; - -export function writeStorageOps(type: TypeDescription, ctx: WriterContext) { - const parse = (code: string) => - ctx.parse(code, { context: Location.type(`${type.name}$init`) }); - const ppty = (ty: FuncAstType): string => - new FuncPrettyPrinter().prettyPrintType(ty); - - // Load function - parse(`${ppty(resolveFuncType(ctx.ctx, type))} ${ops.contractLoad(type.name)}() impure { - slice $sc = get_data().begin_parse(); - - ;; Load context - __tact_context_sys = $sc~load_ref(); - int $loaded = $sc~load_int(1); - - ;; Load data - if ($loaded) { - ${type.fields.length > 0 ? `return $sc~${ops.reader(type.name)}();` : `return null();`} - } else { - ${ - !enabledMasterchain(ctx.ctx) - ? ` - ;; Allow only workchain deployments - throw_unless(${contractErrors.masterchainNotEnabled.id}, my_address().preload_uint(11) == 1024); - ` - : "" - } - - ${ - type.init!.params.length > 0 - ? ` - (${type.init!.params.map((v) => ppty(resolveFuncType(ctx.ctx, v.type)) + " " + funcIdOf(v.name)).join(", ")}) = $sc~${ops.reader(funcInitIdOf(type.name))}(); - $sc.end_parse(); - ` - : "" - } - - return ${ops.contractInit(type.name)}(${[...type.init!.params.map((v) => funcIdOf(v.name))].join(", ")}); - } - }`); - - // Store function - parse(`() ${ops.contractStore(type.name)}(${ppty(resolveFuncType(ctx.ctx, type))} v) impure inline { - builder b = begin_cell(); - - ;; Persist system cell - b = b.store_ref(__tact_context_sys); - - ;; Persist deployment flag - b = b.store_int(true, 1); - - ;; Build data - ${type.fields.length > 0 ? `b = ${ops.writer(type.name)}(b, v);` : ""} - - ;; Persist data - set_data(b.end_cell()); - } -`); -} diff --git a/src/codegen/type.ts b/src/codegen/type.ts deleted file mode 100644 index abb9b6332..000000000 --- a/src/codegen/type.ts +++ /dev/null @@ -1,464 +0,0 @@ -import { CompilerContext } from "../context"; -import { TypeDescription, TypeRef } from "../types/types"; -import { getType } from "../types/resolveDescriptors"; -import { FuncAstType } from "../func/grammar"; -import { Type, unit } from "../func/syntaxConstructors"; -import { ABITypeRef } from "@ton/core"; - -/** - * Unpacks string representation of a user-defined Tact type from its type description. - * The generated string represents an identifier avialable in the current scope. - */ -export function resolveFuncTypeUnpack( - ctx: CompilerContext, - descriptor: TypeRef | TypeDescription | string, - name: string, - optional: boolean = false, - usePartialFields: boolean = false, -): string { - // String - if (typeof descriptor === "string") { - return resolveFuncTypeUnpack( - ctx, - getType(ctx, descriptor), - name, - false, - usePartialFields, - ); - } - - // TypeRef - if (descriptor.kind === "ref") { - return resolveFuncTypeUnpack( - ctx, - getType(ctx, descriptor.name), - name, - descriptor.optional, - usePartialFields, - ); - } - if (descriptor.kind === "map") { - return name; - } - if (descriptor.kind === "ref_bounced") { - return resolveFuncTypeUnpack( - ctx, - getType(ctx, descriptor.name), - name, - false, - true, - ); - } - if (descriptor.kind === "void") { - throw Error(`Void type is not allowed in function arguments: ${name}`); - } - - // TypeDescription - if (descriptor.kind === "primitive_type_decl") { - return name; - } else if (descriptor.kind === "struct") { - const fieldsToUse = usePartialFields - ? descriptor.fields.slice(0, descriptor.partialFieldCount) - : descriptor.fields; - if (optional || fieldsToUse.length === 0) { - return name; - } else { - return ( - "(" + - fieldsToUse - .map((v) => - resolveFuncTypeUnpack( - ctx, - v.type, - name + `'` + v.name, - false, - usePartialFields, - ), - ) - .join(", ") + - ")" - ); - } - } else if (descriptor.kind === "contract") { - if (optional || descriptor.fields.length === 0) { - return name; - } else { - return ( - "(" + - descriptor.fields - .map((v) => - resolveFuncTypeUnpack( - ctx, - v.type, - name + `'` + v.name, - false, - usePartialFields, - ), - ) - .join(", ") + - ")" - ); - } - } - - // Unreachable - throw Error(`Unknown type: ${descriptor.kind}`); -} - -/** - * Generates Func type from the Tact type. - */ -export function resolveFuncType( - ctx: CompilerContext, - descriptor: TypeRef | TypeDescription | string, - optional: boolean = false, - usePartialFields: boolean = false, -): FuncAstType { - // String - if (typeof descriptor === "string") { - return resolveFuncType( - ctx, - getType(ctx, descriptor), - false, - usePartialFields, - ); - } - - // TypeRef - if (descriptor.kind === "ref") { - return resolveFuncType( - ctx, - getType(ctx, descriptor.name), - descriptor.optional, - usePartialFields, - ); - } - if (descriptor.kind === "map") { - return Type.cell(); - } - if (descriptor.kind === "ref_bounced") { - return resolveFuncType(ctx, getType(ctx, descriptor.name), false, true); - } - if (descriptor.kind === "void") { - return unit(); - } - - // TypeDescription - if (descriptor.kind === "primitive_type_decl") { - if (descriptor.name === "Int") { - return Type.int(); - } else if (descriptor.name === "Bool") { - return Type.int(); - } else if (descriptor.name === "Slice") { - return Type.slice(); - } else if (descriptor.name === "Cell") { - return Type.cell(); - } else if (descriptor.name === "Builder") { - return Type.builder(); - } else if (descriptor.name === "Address") { - return Type.slice(); - } else if (descriptor.name === "String") { - return Type.slice(); - } else if (descriptor.name === "StringBuilder") { - return Type.tuple(); - } else { - throw Error(`Unknown primitive type: ${descriptor.name}`); - } - } else if (descriptor.kind === "struct") { - const fieldsToUse = usePartialFields - ? descriptor.fields.slice(0, descriptor.partialFieldCount) - : descriptor.fields; - if (optional || fieldsToUse.length === 0) { - return Type.tuple(); - } else { - return Type.tensor( - ...fieldsToUse.map((v) => - resolveFuncType(ctx, v.type, false, usePartialFields), - ), - ); - } - } else if (descriptor.kind === "contract") { - if (optional || descriptor.fields.length === 0) { - return Type.tuple(); - } else { - return Type.tensor( - ...descriptor.fields.map((v) => - resolveFuncType(ctx, v.type, false, usePartialFields), - ), - ); - } - } - - // Unreachable - throw Error(`Unknown type: ${descriptor.kind}`); -} - -export function resolveFuncTupleType( - ctx: CompilerContext, - descriptor: TypeRef | TypeDescription | string, -): FuncAstType { - // String - if (typeof descriptor === "string") { - return resolveFuncTupleType(ctx, getType(ctx, descriptor)); - } - - // TypeRef - if (descriptor.kind === "ref") { - return resolveFuncTupleType(ctx, getType(ctx, descriptor.name)); - } - if (descriptor.kind === "map") { - return Type.cell(); - } - if (descriptor.kind === "ref_bounced") { - throw Error("Unimplemented"); - } - if (descriptor.kind === "void") { - return Type.tensor(); - } - - // TypeDescription - if (descriptor.kind === "primitive_type_decl") { - if (descriptor.name === "Int") { - return Type.int(); - } else if (descriptor.name === "Bool") { - return Type.int(); - } else if (descriptor.name === "Slice") { - return Type.slice(); - } else if (descriptor.name === "Cell") { - return Type.cell(); - } else if (descriptor.name === "Builder") { - return Type.builder(); - } else if (descriptor.name === "Address") { - return Type.slice(); - } else if (descriptor.name === "String") { - return Type.slice(); - } else if (descriptor.name === "StringBuilder") { - return Type.tuple(); - } else { - throw Error(`Unknown primitive type: ${descriptor.name}`); - } - } else if (descriptor.kind === "struct") { - return Type.tuple(); - } - - // Unreachable - throw Error(`Unknown type: ${descriptor.kind}`); -} - -export function resolveFuncFlatPack( - ctx: CompilerContext, - descriptor: TypeRef | TypeDescription | string, - name: string, - optional: boolean = false, -): string[] { - // String - if (typeof descriptor === "string") { - return resolveFuncFlatPack(ctx, getType(ctx, descriptor), name); - } - - // TypeRef - if (descriptor.kind === "ref") { - return resolveFuncFlatPack( - ctx, - getType(ctx, descriptor.name), - name, - descriptor.optional, - ); - } - if (descriptor.kind === "map") { - return [name]; - } - if (descriptor.kind === "ref_bounced") { - throw Error("Unimplemented"); - } - if (descriptor.kind === "void") { - throw Error("Void type is not allowed in function arguments: " + name); - } - - // TypeDescription - if (descriptor.kind === "primitive_type_decl") { - return [name]; - } else if (descriptor.kind === "struct") { - if (optional || descriptor.fields.length === 0) { - return [name]; - } else { - return descriptor.fields.flatMap((v) => - resolveFuncFlatPack(ctx, v.type, name + `'` + v.name), - ); - } - } else if (descriptor.kind === "contract") { - if (optional || descriptor.fields.length === 0) { - return [name]; - } else { - return descriptor.fields.flatMap((v) => - resolveFuncFlatPack(ctx, v.type, name + `'` + v.name), - ); - } - } - - // Unreachable - throw Error("Unknown type: " + descriptor.kind); -} - -export function resolveFuncFlatTypes( - ctx: CompilerContext, - descriptor: TypeRef | TypeDescription | string, - optional: boolean = false, -): FuncAstType[] { - // String - if (typeof descriptor === "string") { - return resolveFuncFlatTypes(ctx, getType(ctx, descriptor)); - } - - // TypeRef - if (descriptor.kind === "ref") { - return resolveFuncFlatTypes( - ctx, - getType(ctx, descriptor.name), - descriptor.optional, - ); - } - if (descriptor.kind === "map") { - return [Type.cell()]; - } - if (descriptor.kind === "ref_bounced") { - throw Error("Unimplemented"); - } - if (descriptor.kind === "void") { - throw Error("Void type is not allowed in function arguments"); - } - - // TypeDescription - if (descriptor.kind === "primitive_type_decl") { - return [resolveFuncType(ctx, descriptor)]; - } else if (descriptor.kind === "struct") { - if (optional || descriptor.fields.length === 0) { - return [Type.tuple()]; - } else { - return descriptor.fields.flatMap((v) => - resolveFuncFlatTypes(ctx, v.type), - ); - } - } else if (descriptor.kind === "contract") { - if (optional || descriptor.fields.length === 0) { - return [Type.tuple()]; - } else { - return descriptor.fields.flatMap((v) => - resolveFuncFlatTypes(ctx, v.type), - ); - } - } - - // Unreachable - throw Error("Unknown type: " + descriptor.kind); -} - -export function resolveFuncTypeFromAbi( - ctx: CompilerContext, - fields: ABITypeRef[], -): string { - if (fields.length === 0) { - return "tuple"; - } - const res: string[] = []; - for (const f of fields) { - switch (f.kind) { - case "dict": - { - res.push("cell"); - } - break; - case "simple": { - if ( - f.type === "int" || - f.type === "uint" || - f.type === "bool" - ) { - res.push("int"); - } else if (f.type === "cell") { - res.push("cell"); - } else if (f.type === "slice") { - res.push("slice"); - } else if (f.type === "builder") { - res.push("builder"); - } else if (f.type === "address") { - res.push("slice"); - } else if (f.type === "fixed-bytes") { - res.push("slice"); - } else if (f.type === "string") { - res.push("slice"); - } else { - const t = getType(ctx, f.type); - if (t.kind !== "struct") { - throw Error("Unsupported type: " + t.kind); - } - if (f.optional ?? t.fields.length === 0) { - res.push("tuple"); - } else { - const loaded = t.fields.map((v) => v.abi.type); - res.push(resolveFuncTypeFromAbi(ctx, loaded)); - } - } - } - } - } - return `(${res.join(", ")})`; -} - -export function resolveFuncTypeFromAbiUnpack( - ctx: CompilerContext, - name: string, - fields: { name: string; type: ABITypeRef }[], -): string { - if (fields.length === 0) { - return name; - } - const res: string[] = []; - for (const f of fields) { - switch (f.type.kind) { - case "dict": - { - res.push(`${name}'${f.name}`); - } - break; - case "simple": - { - if ( - f.type.type === "int" || - f.type.type === "uint" || - f.type.type === "bool" - ) { - res.push(`${name}'${f.name}`); - } else if (f.type.type === "cell") { - res.push(`${name}'${f.name}`); - } else if (f.type.type === "slice") { - res.push(`${name}'${f.name}`); - } else if (f.type.type === "builder") { - res.push(`${name}'${f.name}`); - } else if (f.type.type === "address") { - res.push(`${name}'${f.name}`); - } else if (f.type.type === "fixed-bytes") { - res.push(`${name}'${f.name}`); - } else if (f.type.type === "string") { - res.push(`${name}'${f.name}`); - } else { - const t = getType(ctx, f.type.type); - if (f.type.optional ?? t.fields.length === 0) { - res.push(`${name}'${f.name}`); - } else { - const loaded = t.fields.map((v) => v.abi); - res.push( - resolveFuncTypeFromAbiUnpack( - ctx, - `${name}'${f.name}`, - loaded, - ), - ); - } - } - } - break; - } - } - return `(${res.join(", ")})`; -} diff --git a/src/codegen/util.ts b/src/codegen/util.ts deleted file mode 100644 index 5cc6866a4..000000000 --- a/src/codegen/util.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { getType } from "../types/resolveDescriptors"; -import { CompilerContext } from "../context"; -import { TypeRef } from "../types/types"; -import { FuncAstExpression } from "../func/grammar"; -import { id, call } from "../func/syntaxConstructors"; -import { AstId, idText } from "../grammar/ast"; - -export const ops = { - // Type operations - writer: (type: string) => `$${type}$_store`, - writerCell: (type: string) => `$${type}$_store_cell`, - writerCellOpt: (type: string) => `$${type}$_store_opt`, - reader: (type: string) => `$${type}$_load`, - readerNonModifying: (type: string) => `$${type}$_load_not_mut`, - readerBounced: (type: string) => `$${type}$_load_bounced`, - readerOpt: (type: string) => `$${type}$_load_opt`, - typeField: (type: string, name: string) => `$${type}$_get_${name}`, - typeTensorCast: (type: string) => `$${type}$_tensor_cast`, - typeNotNull: (type: string) => `$${type}$_not_null`, - typeAsOptional: (type: string) => `$${type}$_as_optional`, - typeToTuple: (type: string) => `$${type}$_to_tuple`, - typeToOptTuple: (type: string) => `$${type}$_to_opt_tuple`, - typeFromTuple: (type: string) => `$${type}$_from_tuple`, - typeFromOptTuple: (type: string) => `$${type}$_from_opt_tuple`, - typeToExternal: (type: string) => `$${type}$_to_external`, - typeToOptExternal: (type: string) => `$${type}$_to_opt_external`, - typeConstructor: (type: string, fields: string[]) => - `$${type}$_constructor_${fields.join("_")}`, - - // Contract operations - contractInit: (type: string) => `$${type}$_contract_init`, - contractInitChild: (type: string) => `$${type}$_init_child`, - contractLoad: (type: string) => `$${type}$_contract_load`, - contractStore: (type: string) => `$${type}$_contract_store`, - contractRouter: (type: string, kind: "internal" | "external") => - `$${type}$_contract_router_${kind}`, // Not rendered as dependency - - // Router operations - receiveEmpty: (type: string, kind: "internal" | "external") => - `%$${type}$_${kind}_empty`, - receiveType: (type: string, kind: "internal" | "external", msg: string) => - `$${type}$_${kind}_binary_${msg}`, - receiveAnyText: (type: string, kind: "internal" | "external") => - `$${type}$_${kind}_any_text`, - receiveText: (type: string, kind: "internal" | "external", hash: string) => - `$${type}$_${kind}_text_${hash}`, - receiveAny: (type: string, kind: "internal" | "external") => - `$${type}$_${kind}_any`, - receiveTypeBounce: (type: string, msg: string) => - `$${type}$_receive_binary_bounce_${msg}`, - receiveBounceAny: (type: string) => `$${type}$_receive_bounce`, - - // Functions - extension: (type: string, name: string) => `$${type}$_fun_${name}`, - global: (name: string) => `$global_${name}`, - nonModifying: (name: string) => `${name}$not_mut`, - - // Constants - str: (id: string) => `__gen_str_${id}`, -}; - -/** - * Wraps the expression in `_as_optional()` if needed. - */ -export function cast( - ctx: CompilerContext, - from: TypeRef, - to: TypeRef, - expr: FuncAstExpression, -): FuncAstExpression { - if (from.kind === "ref" && to.kind === "ref") { - if (from.name !== to.name) { - throw Error(`Impossible: ${from.name} != ${to.name}`); - } - if (!from.optional && to.optional) { - const type = getType(ctx, from.name); - if (type.kind === "struct") { - return call(id(ops.typeAsOptional(type.name)), [expr]); - } - } - } - return expr; -} - -export function funcIdOf(ident: AstId | string): string { - return typeof ident === "string" ? `$${ident}` : `$${idText(ident)}`; -} -export function funcInitIdOf(ident: AstId | string): string { - return typeof ident === "string" - ? `${ident}$init` - : idText(ident) + "$init"; -} - -let NEXT_IDENTIFIER = 0; -export function freshIdentifier(prefix: string): string { - const fresh = `fresh$${prefix}_${NEXT_IDENTIFIER}`; - NEXT_IDENTIFIER += 1; - return funcIdOf(fresh); -} diff --git a/src/generatorNew/Writer.ts b/src/generatorNew/Writer.ts new file mode 100644 index 000000000..85bc9d93d --- /dev/null +++ b/src/generatorNew/Writer.ts @@ -0,0 +1,414 @@ +import { CompilerContext } from "../context"; +import { escapeUnicodeControlCodes, trimIndent } from "../utils/text"; +import { topologicalSort } from "../utils/utils"; +import { Writer } from "../utils/Writer"; +import { FuncPrettyPrinter } from "../func/prettyPrinter"; +import { + FuncAstFunctionDefinition, + FuncAstAsmFunctionDefinition, + FuncAstModule, + funcBuiltinFunctions, + parse, +} from "../func/grammar"; +import { forEachExpression } from "../func/iterators"; +import JSONbig from "json-bigint"; + +type Flag = "inline" | "impure" | "inline_ref"; + +type Body = + | { + kind: "generic"; + code: string; + } + | { + kind: "asm"; + shuffle: string; + code: string; + } + | { + kind: "skip"; + }; + +export type WrittenFunction = { + name: string; + code: Body; + signature: string; + flags: Set; + depends: Set; + comment: string | null; + context: string | null; + parsed: boolean; +}; + +export class WriterContext { + readonly ctx: CompilerContext; + name: string; + functions: Map = new Map(); + functionsRendering: Set = new Set(); + pendingWriter: Writer | null = null; + pendingCode: Body | null = null; + pendingDepends: Set | null = null; + pendingName: string | null = null; + pendingSignature: string | null = null; + pendingFlags: Set | null = null; + pendingComment: string | null = null; + pendingContext: string | null = null; + nextId = 0; + rendered: Set = new Set(); + + constructor(ctx: CompilerContext, name: string) { + this.ctx = ctx; + this.name = name; + } + + clone() { + const res = new WriterContext(this.ctx, this.name); + res.functions = new Map(this.functions); + res.nextId = this.nextId; + res.rendered = new Set(this.rendered); + return res; + } + + // + // New FunC backend functionality + // + + /** + * Collects names of the functions the given function calls. + */ + private collectDependencies(fun: FuncAstFunctionDefinition): Set { + const depends = new Set(); + forEachExpression(fun, (expr) => { + // XXX: It doesn't save receivers. But should it? + if ( + expr.kind === "expression_fun_call" && + expr.object.kind === "plain_id" && + !funcBuiltinFunctions.includes(expr.object.value) + ) { + depends.add(expr.object.value); + } + }); + return depends; + } + + /** + * Parses the FunC function definition saving it to this context. + * + * @param src FunC source that includes exactly one function definition. + * @throws If the given source cannot be parsed as a simple function/asm function definition. + */ + public parse< + T extends FuncAstFunctionDefinition | FuncAstAsmFunctionDefinition, + >( + src: string, + { + context = "", + comment = "", + }: Partial<{ context: string; comment: string }>, + ): T | never { + const mod = parse(src) as FuncAstModule; + if ( + mod.items.length !== 1 || + !["function_definition", "asm_function_definition"].includes( + mod.items[0]!.kind, + ) + ) { + console.error(); + throw new Error( + `Incorrect function structure: ${JSONbig.stringify(mod)}`, + ); + } + const fundef = mod.items[0]! as T; + const name = fundef.name.value; + this.throwIfDefined(name); + const pp = new FuncPrettyPrinter(); + const code: Body = + fundef.kind === "function_definition" + ? { + kind: "generic", + code: pp.prettyPrintStatements(fundef.statements), + } + : { + kind: "asm", + shuffle: "", + code: pp.prettyPrintAsmStrings(fundef.asmStrings), + }; + const depends = + fundef.kind === "function_definition" + ? this.collectDependencies(fundef) + : new Set(); + const signature = pp.prettyPrintFunctionSignature( + fundef.returnTy, + fundef.name, + fundef.parameters, + fundef.attributes, + ); + const flags = fundef.attributes.reduce((set, attr) => { + if ( + attr.kind === "inline" || + attr.kind === "impure" || + attr.kind === "inline_ref" + ) { + set.add(attr.kind); + } + return set; + }, new Set()); + this.functions.set(name, { + name, + code, + depends, + signature, + flags, + comment, + context, + parsed: true, + }); + return fundef; + } + + // + // Rendering + // + + extract(debug: boolean = false) { + // Remove unavailable dependencies + for (const f of this.functions.values()) { + const updatedDepends = new Set(); + for (const d of f.depends) { + if (this.functions.has(d)) { + updatedDepends.add(d); + } + } + f.depends = updatedDepends; + } + + // All functions + let all = Array.from(this.functions.values()); + + // Remove unused + if (!debug) { + const used: Set = new Set(); + const visit = (name: string) => { + used.add(name); + const f = this.functions.get(name)!; + for (const d of f.depends) { + visit(d); + } + }; + visit("$main"); + all = all.filter((v) => used.has(v.name)); + } + + // Sort functions + const sorted = topologicalSort(all, (f) => + Array.from(f.depends).map((v) => this.functions.get(v)!), + ); + + return sorted; + } + + // + // Declaration + // + + skip(name: string) { + this.fun(name, () => { + this.signature(""); + this.context("stdlib"); + this.pendingCode = { kind: "skip" }; + }); + } + + private throwIfDefined(name: string): void | never { + if (this.functions.has(name)) { + throw new Error(`Function "${name}" already defined`); + } + if (this.functionsRendering.has(name)) { + throw new Error(`Function "${name}" already rendering`); + } + } + + fun(name: string, handler: () => void) { + this.throwIfDefined(name); + + // + // Nesting check + // + + if (this.pendingName) { + const w = this.pendingWriter; + const d = this.pendingDepends; + const n = this.pendingName; + const s = this.pendingSignature; + const f = this.pendingFlags; + const c = this.pendingCode; + const cc = this.pendingComment; + const cs = this.pendingContext; + this.pendingDepends = null; + this.pendingWriter = null; + this.pendingName = null; + this.pendingSignature = null; + this.pendingFlags = null; + this.pendingCode = null; + this.pendingComment = null; + this.pendingContext = null; + this.fun(name, handler); + this.pendingSignature = s; + this.pendingDepends = d; + this.pendingWriter = w; + this.pendingName = n; + this.pendingFlags = f; + this.pendingCode = c; + this.pendingComment = cc; + this.pendingContext = cs; + return; + } + + // Write function + this.functionsRendering.add(name); + this.pendingWriter = null; + this.pendingDepends = new Set(); + this.pendingName = name; + this.pendingSignature = null; + this.pendingFlags = new Set(); + this.pendingCode = null; + this.pendingComment = null; + this.pendingContext = null; + handler(); + const depends = this.pendingDepends; + const signature = this.pendingSignature!; + const flags = this.pendingFlags; + const code = this.pendingCode; + const comment = this.pendingComment; + const context = this.pendingContext; + if (!signature && name !== "$main") { + throw new Error(`Function "${name}" signature not set`); + } + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (!code) { + throw new Error(`Function "${name}" body not set`); + } + this.pendingDepends = null; + this.pendingWriter = null; + this.pendingName = null; + this.pendingSignature = null; + this.pendingFlags = null; + this.functionsRendering.delete(name); + this.functions.set(name, { + name, + code, + depends, + signature, + flags, + comment, + context, + parsed: false, + }); + } + + asm(shuffle: string, code: string) { + if (this.pendingName) { + this.pendingCode = { + kind: "asm", + shuffle, + code, + }; + } else { + throw new Error(`ASM can be set only inside function`); + } + } + + body(handler: () => void) { + if (this.pendingWriter) { + throw new Error(`Body can be set only once`); + } + this.pendingWriter = new Writer(); + handler(); + this.pendingCode = { + kind: "generic", + code: this.pendingWriter!.end(), + }; + } + + main(handler: () => void) { + this.fun("$main", () => { + this.body(() => { + handler(); + }); + }); + } + + signature(sig: string) { + if (this.pendingName) { + this.pendingSignature = sig; + } else { + throw new Error(`Signature can be set only inside function`); + } + } + + flag(flag: Flag) { + if (this.pendingName) { + this.pendingFlags!.add(flag); + } else { + throw new Error(`Flag can be set only inside function`); + } + } + + used(name: string) { + if (this.pendingName !== name) { + this.pendingDepends!.add(name); + } + return name; + } + + comment(src: string) { + if (this.pendingName) { + this.pendingComment = escapeUnicodeControlCodes(trimIndent(src)); + } else { + throw new Error(`Comment can be set only inside function`); + } + } + + context(src: string) { + if (this.pendingName) { + this.pendingContext = src; + } else { + throw new Error(`Context can be set only inside function`); + } + } + + currentContext() { + return this.pendingName; + } + + // + // Writers + // + + inIndent = (handler: () => void) => { + this.pendingWriter!.inIndent(handler); + }; + + append(src: string = "") { + this.pendingWriter!.append(src); + } + + write(src: string = "") { + this.pendingWriter!.write(src); + } + + // + // Utils + // + + isRendered(key: string) { + return this.rendered.has(key); + } + + markRendered(key: string) { + if (this.rendered.has(key)) { + throw new Error(`Key "${key}" already rendered`); + } + this.rendered.add(key); + } +} diff --git a/src/generatorNew/createABI.ts b/src/generatorNew/createABI.ts new file mode 100644 index 000000000..406606370 --- /dev/null +++ b/src/generatorNew/createABI.ts @@ -0,0 +1,176 @@ +import { ABIGetter, ABIReceiver, ABIType, ContractABI } from "@ton/core"; +import { contractErrors } from "../abi/errors"; +import { CompilerContext } from "../context"; +import { idText } from "../grammar/ast"; +import { getSupportedInterfaces } from "../types/getSupportedInterfaces"; +import { createABITypeRefFromTypeRef } from "../types/resolveABITypeRef"; +import { getAllTypes } from "../types/resolveDescriptors"; +import { getAllErrors } from "../types/resolveErrors"; + +export function createABI(ctx: CompilerContext, name: string): ContractABI { + const allTypes = getAllTypes(ctx); + + // Contract + const contract = allTypes.find((v) => v.name === name); + if (!contract) { + throw Error(`Contract "${name}" not found`); + } + if (contract.kind !== "contract") { + throw Error("Not a contract"); + } + + // Structs + const types: ABIType[] = []; + for (const t of allTypes) { + if (t.kind === "struct") { + types.push({ + name: t.name, + header: Number(t.header?.value), + fields: t.fields.map((v) => v.abi), + }); + } else if (t.kind === "contract") { + types.push({ + name: t.name + "$Data", + header: Number(t.header?.value), + fields: t.fields.map((v) => v.abi), + }); + } + } + + // // Receivers + const receivers: ABIReceiver[] = []; + for (const r of contract.receivers) { + if (r.selector.kind === "internal-binary") { + receivers.push({ + receiver: "internal", + message: { + kind: "typed", + type: r.selector.type, + }, + }); + } else if (r.selector.kind === "external-binary") { + receivers.push({ + receiver: "external", + message: { + kind: "typed", + type: r.selector.type, + }, + }); + } else if (r.selector.kind === "internal-empty") { + receivers.push({ + receiver: "internal", + message: { + kind: "empty", + }, + }); + } else if (r.selector.kind === "external-empty") { + receivers.push({ + receiver: "external", + message: { + kind: "empty", + }, + }); + } else if (r.selector.kind === "internal-comment") { + receivers.push({ + receiver: "internal", + message: { + kind: "text", + text: r.selector.comment, + }, + }); + } else if (r.selector.kind === "external-comment") { + receivers.push({ + receiver: "external", + message: { + kind: "text", + text: r.selector.comment, + }, + }); + } else if (r.selector.kind === "internal-comment-fallback") { + receivers.push({ + receiver: "internal", + message: { + kind: "text", + }, + }); + } else if (r.selector.kind === "external-comment-fallback") { + receivers.push({ + receiver: "external", + message: { + kind: "text", + }, + }); + } else if (r.selector.kind === "internal-fallback") { + receivers.push({ + receiver: "internal", + message: { + kind: "any", + }, + }); + } else if (r.selector.kind === "external-fallback") { + receivers.push({ + receiver: "external", + message: { + kind: "any", + }, + }); + } + } + + // Getters + const getters: ABIGetter[] = []; + for (const f of contract.functions.values()) { + if (f.isGetter) { + getters.push({ + name: f.name, + arguments: f.params.map((v) => ({ + name: idText(v.name), + type: createABITypeRefFromTypeRef(ctx, v.type, v.loc), + })), + returnType: + f.returns.kind !== "void" + ? createABITypeRefFromTypeRef(ctx, f.returns, f.ast.loc) + : null, + }); + } + } + + // Errors + const errors: Record = {}; + errors["2"] = { message: "Stack underflow" }; + errors["3"] = { message: "Stack overflow" }; + errors["4"] = { message: "Integer overflow" }; + errors["5"] = { message: "Integer out of expected range" }; + errors["6"] = { message: "Invalid opcode" }; + errors["7"] = { message: "Type check error" }; + errors["8"] = { message: "Cell overflow" }; + errors["9"] = { message: "Cell underflow" }; + errors["10"] = { message: "Dictionary error" }; + errors["13"] = { message: "Out of gas error" }; + errors["32"] = { message: "Method ID not found" }; + errors["34"] = { message: "Action is invalid or not supported" }; + errors["37"] = { message: "Not enough TON" }; + errors["38"] = { message: "Not enough extra-currencies" }; + for (const e of Object.values(contractErrors)) { + errors[e.id] = { message: e.message }; + } + const codeErrors = getAllErrors(ctx); + for (const c of codeErrors) { + errors[c.id + ""] = { message: c.value }; + } + + // Interfaces + const interfaces = [ + "org.ton.introspection.v0", + ...getSupportedInterfaces(contract, ctx), + ]; + + return { + name: contract.name, + types, + receivers, + getters, + errors, + interfaces, + } as object; +} diff --git a/src/generatorNew/emitter/createPadded.ts b/src/generatorNew/emitter/createPadded.ts new file mode 100644 index 000000000..eff2f620e --- /dev/null +++ b/src/generatorNew/emitter/createPadded.ts @@ -0,0 +1,8 @@ +import { trimIndent } from "../../utils/text"; + +export function createPadded(src: string) { + return trimIndent(src) + .split("\n") + .map((v) => " ".repeat(4) + v) + .join("\n"); +} diff --git a/src/generatorNew/emitter/emit.ts b/src/generatorNew/emitter/emit.ts new file mode 100644 index 000000000..b445083c6 --- /dev/null +++ b/src/generatorNew/emitter/emit.ts @@ -0,0 +1,68 @@ +import { Maybe } from "@ton/core/dist/utils/maybe"; +import { trimIndent } from "../../utils/text"; +import { WrittenFunction } from "../Writer"; +import { createPadded } from "./createPadded"; + +export function emit(args: { + header?: Maybe; + functions?: Maybe; +}) { + // Emit header + let res = ""; + if (args.header) { + res = trimIndent(args.header); + } + + // Emit functions + if (args.functions) { + for (const f of args.functions) { + if (f.name === "$main") { + continue; + } else { + if (res !== "") { + res += "\n\n"; + } + if (f.comment) { + for (const s of f.comment.split("\n")) { + res += `;; ${s}\n`; + } + } + if (f.code.kind === "generic") { + let sig = f.signature; + if (f.flags.has("impure")) { + sig = `${sig} impure`; + } + if (f.flags.has("inline")) { + sig = `${sig} inline`; + } else { + sig = `${sig} inline_ref`; + } + + res += `${sig} {\n${createPadded(f.code.code)}\n}`; + } else if (f.code.kind === "asm") { + let sig = f.signature; + if (f.flags.has("impure")) { + sig = `${sig} impure`; + } + res += `${sig} asm${f.code.shuffle} "${f.code.code}";`; + } else { + throw new Error(`Unknown function body kind`); + } + } + } + + // Emit main + const m = args.functions.find((v) => v.name === "$main"); + if (m) { + if (m.code.kind !== "generic") { + throw new Error(`Main function should have generic body`); + } + if (res !== "") { + res += "\n\n"; + } + res += m.code.code; + } + } + + return res; +} diff --git a/src/generatorNew/writeProgram.ts b/src/generatorNew/writeProgram.ts new file mode 100644 index 000000000..51acceea6 --- /dev/null +++ b/src/generatorNew/writeProgram.ts @@ -0,0 +1,409 @@ +import { CompilerContext } from "../context"; +import { getAllocation, getSortedTypes } from "../storage/resolveAllocation"; +import { + getAllStaticFunctions, + getAllTypes, + toBounced, +} from "../types/resolveDescriptors"; +import { WriterContext, WrittenFunction } from "./Writer"; +import { + writeBouncedParser, + writeOptionalParser, + writeOptionalSerializer, + writeParser, + writeSerializer, +} from "./writers/writeSerialization"; +import { writeStdlib } from "./writers/writeStdlib"; +import { writeAccessors } from "./writers/writeAccessors"; +import { ContractABI } from "@ton/core"; +import { writeFunction } from "./writers/writeFunction"; +import { calculateIPFSlink } from "../utils/calculateIPFSlink"; +import { getRawAST } from "../grammar/store"; +import { emit } from "./emitter/emit"; +import { + writeInit, + writeMainContract, + writeStorageOps, +} from "./writers/writeContract"; +import { funcInitIdOf } from "./writers/id"; +import { idToHex } from "../utils/idToHex"; +import { trimIndent } from "../utils/text"; + +export async function writeProgram( + ctx: CompilerContext, + abiSrc: ContractABI, + basename: string, + debug: boolean = false, +) { + // + // Load ABI (required for generator) + // + + const abi = JSON.stringify(abiSrc); + const abiLink = await calculateIPFSlink(Buffer.from(abi)); + + // + // Render contract + // + + const wCtx = new WriterContext(ctx, abiSrc.name!); + writeAll(ctx, wCtx, abiSrc.name!, abiLink); + const functions = wCtx.extract(debug); + + // + // Emit files + // + + const files: { name: string; code: string }[] = []; + const imported: string[] = []; + + // + // Headers + // + + const headers: string[] = []; + headers.push(`;;`); + headers.push(`;; Header files for ${abiSrc.name}`); + headers.push(`;; NOTE: declarations are sorted for optimal order`); + headers.push(`;;`); + headers.push(``); + // const sortedHeaders = [...functions].sort((a, b) => a.name.localeCompare(b.name)); + for (const f of functions) { + if (f.code.kind === "generic" && f.signature) { + headers.push(`;; ${f.name}`); + let sig = f.signature; + if (f.flags.has("impure")) { + sig = sig + " impure"; + } + if (f.flags.has("inline")) { + sig = sig + " inline"; + } else { + sig = sig + " inline_ref"; + } + headers.push(sig + ";"); + headers.push(""); + } + } + files.push({ + name: basename + ".headers.fc", + code: headers.join("\n"), + }); + + // + // stdlib + // + + const stdlibHeader = trimIndent(` + global (int, slice, int, slice) __tact_context; + global slice __tact_context_sender; + global cell __tact_context_sys; + global int __tact_randomized; + `); + + const stdlibFunctions = tryExtractModule(functions, "stdlib", []); + if (stdlibFunctions) { + imported.push("stdlib"); + } + + const stdlib = emit({ + header: stdlibHeader, + functions: stdlibFunctions, + }); + + files.push({ + name: basename + ".stdlib.fc", + code: stdlib, + }); + + // + // native + // + + const nativeSources = getRawAST(ctx).funcSources; + if (nativeSources.length > 0) { + imported.push("native"); + files.push({ + name: basename + ".native.fc", + code: emit({ + header: [...nativeSources.map((v) => v.code)].join("\n\n"), + }), + }); + } + + // + // constants + // + + const constantsFunctions = tryExtractModule( + functions, + "constants", + imported, + ); + if (constantsFunctions) { + imported.push("constants"); + files.push({ + name: basename + ".constants.fc", + code: emit({ functions: constantsFunctions }), + }); + } + + // + // storage + // + + const emittedTypes: string[] = []; + const types = getSortedTypes(ctx); + for (const t of types) { + const ffs: WrittenFunction[] = []; + if (t.kind === "struct" || t.kind === "contract" || t.kind == "trait") { + const typeFunctions = tryExtractModule( + functions, + "type:" + t.name, + imported, + ); + if (typeFunctions) { + imported.push("type:" + t.name); + ffs.push(...typeFunctions); + } + } + if (t.kind === "contract") { + const typeFunctions = tryExtractModule( + functions, + "type:" + t.name + "$init", + imported, + ); + if (typeFunctions) { + imported.push("type:" + t.name + "$init"); + ffs.push(...typeFunctions); + } + } + if (ffs.length > 0) { + const header: string[] = []; + header.push(";;"); + header.push(`;; Type: ${t.name}`); + if (t.header !== null) { + header.push(`;; Header: 0x${idToHex(Number(t.header.value))}`); + } + if (t.tlb) { + header.push(`;; TLB: ${t.tlb}`); + } + header.push(";;"); + + emittedTypes.push( + emit({ + functions: ffs, + header: header.join("\n"), + }), + ); + } + } + if (emittedTypes.length > 0) { + files.push({ + name: basename + ".storage.fc", + code: [...emittedTypes].join("\n\n"), + }); + } + + // const storageFunctions = tryExtractModule(functions, 'storage', imported); + // if (storageFunctions) { + // imported.push('storage'); + // files.push({ + // name: basename + '.storage.fc', + // code: emit({ functions: storageFunctions }) + // }); + // } + + // + // Remaining + // + + const remainingFunctions = tryExtractModule(functions, null, imported); + const header: string[] = []; + header.push("#pragma version =0.4.4;"); + header.push("#pragma allow-post-modification;"); + header.push("#pragma compute-asm-ltr;"); + header.push(""); + for (const i of files.map((v) => `#include "${v.name}";`)) { + header.push(i); + } + header.push(""); + header.push(";;"); + header.push(`;; Contract ${abiSrc.name} functions`); + header.push(";;"); + header.push(""); + const code = emit({ + header: header.join("\n"), + functions: remainingFunctions, + }); + files.push({ + name: basename + ".code.fc", + code, + }); + + return { + entrypoint: basename + ".code.fc", + files, + abi, + }; +} + +function tryExtractModule( + functions: WrittenFunction[], + context: string | null, + imported: string[], +): WrittenFunction[] | null { + // Put to map + const maps: Map = new Map(); + for (const f of functions) { + maps.set(f.name, f); + } + + // Extract functions of a context + const ctxFunctions: WrittenFunction[] = functions + .filter((v) => v.code.kind !== "skip") + .filter((v) => { + if (context) { + return v.context === context; + } else { + return v.context === null || !imported.includes(v.context); + } + }); + if (ctxFunctions.length === 0) { + return null; + } + + // Check dependencies + // if (context) { + // for (let f of ctxFunctions) { + // for (let d of f.depends) { + // let c = maps.get(d)!.context; + // if (!c) { + // console.warn(`Function ${f.name} depends on ${d} with generic context, but ${context} is needed`); + // return null; // Found dependency to unknown function + // } + // if (c !== context && (c !== null && !imported.includes(c))) { + // console.warn(`Function ${f.name} depends on ${d} with ${c} context, but ${context} is needed`); + // return null; // Found dependency to another context + // } + // } + // } + // } + + return ctxFunctions; +} + +function writeAll( + ctx: CompilerContext, + wCtx: WriterContext, + name: string, + abiLink: string, +) { + // Load all types + const allTypes = getAllTypes(ctx); + const contracts = allTypes.filter((v) => v.kind === "contract"); + const c = contracts.find((v) => v.name === name); + if (!c) { + throw Error(`Contract "${name}" not found`); + } + + // Stdlib + writeStdlib(wCtx); + + // Serializers + const sortedTypes = getSortedTypes(ctx); + for (const t of sortedTypes) { + if (t.kind === "contract" || t.kind === "struct") { + const allocation = getAllocation(ctx, t.name); + const allocationBounced = getAllocation(ctx, toBounced(t.name)); + writeSerializer( + t.name, + t.kind === "contract", + allocation, + t.origin, + wCtx, + ); + writeOptionalSerializer(t.name, t.origin, wCtx); + writeParser( + t.name, + t.kind === "contract", + allocation, + t.origin, + wCtx, + ); + writeOptionalParser(t.name, t.origin, wCtx); + writeBouncedParser( + t.name, + t.kind === "contract", + allocationBounced, + t.origin, + wCtx, + ); + } + } + + // Accessors + for (const t of allTypes) { + if (t.kind === "contract" || t.kind === "struct") { + writeAccessors(t, t.origin, wCtx); + } + } + + // Init serializers + for (const t of sortedTypes) { + if (t.kind === "contract" && t.init) { + const allocation = getAllocation(ctx, funcInitIdOf(t.name)); + writeSerializer( + funcInitIdOf(t.name), + true, + allocation, + t.origin, + wCtx, + ); + writeParser( + funcInitIdOf(t.name), + false, + allocation, + t.origin, + wCtx, + ); + } + } + + // Storage Functions + for (const t of sortedTypes) { + if (t.kind === "contract") { + writeStorageOps(t, t.origin, wCtx); + } + } + + // Static functions + getAllStaticFunctions(ctx).forEach((f) => { + writeFunction(f, wCtx); + }); + + // Extensions + for (const c of allTypes) { + if (c.kind !== "contract" && c.kind !== "trait") { + // We are rendering contract functions separately + for (const f of c.functions.values()) { + writeFunction(f, wCtx); + } + } + } + + // Contract functions + for (const c of contracts) { + // Init + if (c.init) { + writeInit(c, c.init, wCtx); + } + + // Functions + for (const f of c.functions.values()) { + writeFunction(f, wCtx); + } + } + + // Write contract main + writeMainContract(c, abiLink, wCtx); +} diff --git a/src/generatorNew/writeReport.ts b/src/generatorNew/writeReport.ts new file mode 100644 index 000000000..b6f580a85 --- /dev/null +++ b/src/generatorNew/writeReport.ts @@ -0,0 +1,100 @@ +import { ContractABI } from "@ton/core"; +import { CompilerContext } from "../context"; +import { PackageFileFormat } from "../packaging/fileFormat"; +import { getType } from "../types/resolveDescriptors"; +import { Writer } from "../utils/Writer"; +import { TypeDescription } from "../types/types"; + +export function writeReport(ctx: CompilerContext, pkg: PackageFileFormat) { + const w = new Writer(); + const abi = JSON.parse(pkg.abi) as ContractABI; + w.write(` + # TACT Compilation Report + Contract: ${pkg.name} + BOC Size: ${Buffer.from(pkg.code, "base64").length} bytes + `); + w.append(); + + // Types + w.write(`# Types`); + w.write("Total Types: " + abi.types!.length); + w.append(); + for (const t of abi.types!) { + const tt = getType( + ctx, + t.name.endsWith("$Data") ? t.name.slice(0, -5) : t.name, + ); + w.write(`## ${t.name}`); + w.write(`TLB: \`${tt.tlb!}\``); + w.write(`Signature: \`${tt.signature!}\``); + w.append(); + } + + // Get methods + w.write(`# Get Methods`); + w.write("Total Get Methods: " + abi.getters!.length); + w.append(); + for (const t of abi.getters!) { + w.write(`## ${t.name}`); + for (const arg of t.arguments!) { + w.write(`Argument: ${arg.name}`); + } + w.append(); + } + + // Error Codes + w.write(`# Error Codes`); + Object.entries(abi.errors!).forEach(([t, abiError]) => { + w.write(`${t}: ${abiError.message}`); + }); + w.append(); + + const t = getType(ctx, pkg.name); + const writtenEdges: Set = new Set(); + + // Trait Inheritance Diagram + w.write(`# Trait Inheritance Diagram`); + w.append(); + w.write("```mermaid"); + w.write("graph TD"); + function writeTraits(t: TypeDescription) { + for (const trait of t.traits) { + const edge = `${t.name} --> ${trait.name}`; + if (writtenEdges.has(edge)) { + continue; + } + writtenEdges.add(edge); + w.write(edge); + writeTraits(trait); + } + } + w.write(t.name); + writeTraits(t); + w.write("```"); + w.append(); + + writtenEdges.clear(); + + // Contract Dependency Diagram + w.write(`# Contract Dependency Diagram`); + w.append(); + w.write("```mermaid"); + w.write("graph TD"); + function writeDependencies(t: TypeDescription) { + for (const dep of t.dependsOn) { + const edge = `${t.name} --> ${dep.name}`; + if (writtenEdges.has(edge)) { + continue; + } + writtenEdges.add(edge); + w.write(edge); + writeDependencies(dep); + } + } + writtenEdges.clear(); + w.write(t.name); + writeDependencies(t); + w.write("```"); + + return w.end(); +} diff --git a/src/generatorNew/writers/__snapshots__/writeSerialization.spec.ts.snap b/src/generatorNew/writers/__snapshots__/writeSerialization.spec.ts.snap new file mode 100644 index 000000000..b7815dc4f --- /dev/null +++ b/src/generatorNew/writers/__snapshots__/writeSerialization.spec.ts.snap @@ -0,0 +1,10684 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`writeSerialization should write serializer for A 1`] = ` +[ + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_set", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_nop", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_str_to_slice", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_slice_to_str", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_address_to_slice", + "signature": "", + }, + { + "code": { + "code": "throw_unless(136, address.slice_bits() == 267); +var h = address.preload_uint(11); +throw_if(137, h == 1279); +throw_unless(136, h == 1024); +return address;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + "inline", + }, + "name": "__tact_verify_address", + "signature": "slice __tact_verify_address(slice address)", + }, + { + "code": { + "code": "slice raw = cs~load_msg_addr(); +return (cs, __tact_verify_address(raw));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_load_address", + "signature": "(slice, slice) __tact_load_address(slice cs)", + }, + { + "code": { + "code": "if (cs.preload_uint(2) != 0) { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); +} else { + cs~skip_bits(2); + return (cs, null()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_load_address_opt", + "signature": "(slice, slice) __tact_load_address_opt(slice cs)", + }, + { + "code": { + "code": "return b.store_slice(__tact_verify_address(address));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_store_address", + "signature": "builder __tact_store_address(builder b, slice address)", + }, + { + "code": { + "code": "if (null?(address)) { + b = b.store_uint(0, 2); + return b; +} else { + return __tact_store_address(b, address); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_store_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_store_address_opt", + "signature": "builder __tact_store_address_opt(builder b, slice address)", + }, + { + "code": { + "code": "var b = begin_cell(); +b = b.store_uint(2, 2); +b = b.store_uint(0, 1); +b = b.store_int(chain, 8); +b = b.store_uint(hash, 256); +var addr = b.end_cell().begin_parse(); +return __tact_verify_address(addr);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_create_address", + "signature": "slice __tact_create_address(int chain, int hash)", + }, + { + "code": { + "code": "var b = begin_cell(); +b = b.store_uint(0, 2); +b = b.store_uint(3, 2); +b = b.store_uint(0, 1); +b = b.store_ref(code); +b = b.store_ref(data); +var hash = cell_hash(b.end_cell()); +return __tact_create_address(chain, hash);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_create_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_compute_contract_address", + "signature": "slice __tact_compute_contract_address(int chain, cell code, cell data)", + }, + { + "code": { + "code": "throw_if(128, null?(x)); return x;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + "inline", + }, + "name": "__tact_not_null", + "signature": "forall X -> X __tact_not_null(X x)", + }, + { + "code": { + "code": "DICTDEL", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete", + "signature": "(cell, int) __tact_dict_delete(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTIDEL", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete_int", + "signature": "(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index)", + }, + { + "code": { + "code": "DICTUDEL", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete_uint", + "signature": "(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index)", + }, + { + "code": { + "code": "DICTSETREF", + "kind": "asm", + "shuffle": "(value index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_set_ref", + "signature": "((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value)", + }, + { + "code": { + "code": "DICTGET NULLSWAPIFNOT", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_get", + "signature": "(slice, int) __tact_dict_get(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTDELGET NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete_get", + "signature": "(cell, (slice, int)) __tact_dict_delete_get(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTGETREF NULLSWAPIFNOT", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_get_ref", + "signature": "(cell, int) __tact_dict_get_ref(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTMIN NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(dict key_len -> 1 0 2)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_min", + "signature": "(slice, slice, int) __tact_dict_min(cell dict, int key_len)", + }, + { + "code": { + "code": "DICTMINREF NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(dict key_len -> 1 0 2)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_min_ref", + "signature": "(slice, cell, int) __tact_dict_min_ref(cell dict, int key_len)", + }, + { + "code": { + "code": "DICTGETNEXT NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(pivot dict key_len -> 1 0 2)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_next", + "signature": "(slice, slice, int) __tact_dict_next(cell dict, int key_len, slice pivot)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(dict, key_len, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set {}, + "name": "__tact_dict_next_ref", + "signature": "(slice, cell, int) __tact_dict_next_ref(cell dict, int key_len, slice pivot)", + }, + { + "code": { + "code": "STRDUMP DROP STRDUMP DROP s0 DUMP DROP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + }, + "name": "__tact_debug", + "signature": "forall X -> () __tact_debug(X value, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "STRDUMP DROP STRDUMP DROP STRDUMP DROP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + }, + "name": "__tact_debug_str", + "signature": "() __tact_debug_str(slice value, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "if (value) { + __tact_debug_str("true", debug_print_1, debug_print_2); +} else { + __tact_debug_str("false", debug_print_1, debug_print_2); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_debug_str", + }, + "flags": Set { + "impure", + }, + "name": "__tact_debug_bool", + "signature": "() __tact_debug_bool(int value, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "SDSUBSTR", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_preload_offset", + "signature": "(slice) __tact_preload_offset(slice s, int offset, int bits)", + }, + { + "code": { + "code": "slice new_data = begin_cell() + .store_slice(data) + .store_slice("0000"s) +.end_cell().begin_parse(); +int reg = 0; +while (~ new_data.slice_data_empty?()) { + int byte = new_data~load_uint(8); + int mask = 0x80; + while (mask > 0) { + reg <<= 1; + if (byte & mask) { + reg += 1; + } + mask >>= 1; + if (reg > 0xffff) { + reg &= 0xffff; + reg ^= 0x1021; + } + } +} +(int q, int r) = divmod(reg, 256); +return begin_cell() + .store_uint(q, 8) + .store_uint(r, 8) +.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline_ref", + }, + "name": "__tact_crc16", + "signature": "(slice) __tact_crc16(slice data)", + }, + { + "code": { + "code": "slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; +builder res = begin_cell(); + +while (data.slice_bits() >= 24) { + (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); + + int n = (bs1 << 16) | (bs2 << 8) | bs3; + + res = res + .store_slice(__tact_preload_offset(chars, ((n >> 18) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 12) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 6) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n ) & 63) * 8, 8)); +} + +return res.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_preload_offset", + }, + "flags": Set {}, + "name": "__tact_base64_encode", + "signature": "(slice) __tact_base64_encode(slice data)", + }, + { + "code": { + "code": "(int wc, int hash) = address.parse_std_addr(); + +slice user_friendly_address = begin_cell() + .store_slice("11"s) + .store_uint((wc + 0x100) % 0x100, 8) + .store_uint(hash, 256) +.end_cell().begin_parse(); + +slice checksum = __tact_crc16(user_friendly_address); +slice user_friendly_address_with_checksum = begin_cell() + .store_slice(user_friendly_address) + .store_slice(checksum) +.end_cell().begin_parse(); + +return __tact_base64_encode(user_friendly_address_with_checksum);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_crc16", + "__tact_base64_encode", + }, + "flags": Set {}, + "name": "__tact_address_to_user_friendly", + "signature": "(slice) __tact_address_to_user_friendly(slice address)", + }, + { + "code": { + "code": "__tact_debug_str(__tact_address_to_user_friendly(address), debug_print_1, debug_print_2);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_debug_str", + "__tact_address_to_user_friendly", + }, + "flags": Set { + "impure", + }, + "name": "__tact_debug_address", + "signature": "() __tact_debug_address(slice address, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "STRDUMP DROP STRDUMP DROP DUMPSTK", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + }, + "name": "__tact_debug_stack", + "signature": "() __tact_debug_stack(slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "return __tact_context;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_context_get", + "signature": "(int, slice, int, slice) __tact_context_get()", + }, + { + "code": { + "code": "return __tact_context_sender;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_context_get_sender", + "signature": "slice __tact_context_get_sender()", + }, + { + "code": { + "code": "if (null?(__tact_randomized)) { + randomize_lt(); + __tact_randomized = true; +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + "inline", + }, + "name": "__tact_prepare_random", + "signature": "() __tact_prepare_random()", + }, + { + "code": { + "code": "return b.store_int(v, 1);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_store_bool", + "signature": "builder __tact_store_bool(builder b, int v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_to_tuple", + "signature": "forall X -> tuple __tact_to_tuple(X x)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_from_tuple", + "signature": "forall X -> X __tact_from_tuple(tuple x)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_int", + "signature": "(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +if (ok) { + return r~load_int(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_int", + "signature": "int __tact_dict_get_int_int(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min?(d, kl); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_int", + "signature": "(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_int", + "signature": "(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_uint", + "signature": "(cell, ()) __tact_dict_set_int_uint(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +if (ok) { + return r~load_uint(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_uint", + "signature": "int __tact_dict_get_int_uint(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min?(d, kl); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_uint", + "signature": "(int, int, int) __tact_dict_min_int_uint(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_uint", + "signature": "(int, int, int) __tact_dict_next_int_uint(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_int", + "signature": "(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +if (ok) { + return r~load_int(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_int", + "signature": "int __tact_dict_get_uint_int(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min?(d, kl); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_int", + "signature": "(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_int", + "signature": "(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_uint", + "signature": "(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +if (ok) { + return r~load_uint(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_uint", + "signature": "int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min?(d, kl); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_uint", + "signature": "(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_uint", + "signature": "(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set_ref(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_cell", + "signature": "(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v)", + }, + { + "code": { + "code": "var (r, ok) = idict_get_ref?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_cell", + "signature": "cell __tact_dict_get_int_cell(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min_ref?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_cell", + "signature": "(int, cell, int) __tact_dict_min_int_cell(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_cell", + "signature": "(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set_ref(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_cell", + "signature": "(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v)", + }, + { + "code": { + "code": "var (r, ok) = udict_get_ref?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_cell", + "signature": "cell __tact_dict_get_uint_cell(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min_ref?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_cell", + "signature": "(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_cell", + "signature": "(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_slice", + "signature": "(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_slice", + "signature": "slice __tact_dict_get_int_slice(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_slice", + "signature": "(int, slice, int) __tact_dict_min_int_slice(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_slice", + "signature": "(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_slice", + "signature": "(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_slice", + "signature": "slice __tact_dict_get_uint_slice(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_slice", + "signature": "(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_slice", + "signature": "(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_int", + "signature": "(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +if (ok) { + return r~load_int(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_int", + "signature": "int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min(d, kl); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_int", + "signature": "(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(d, kl, pivot); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_int", + "signature": "(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_uint", + "signature": "(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +if (ok) { + return r~load_uint(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_uint", + "signature": "int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min(d, kl); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_uint", + "signature": "(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(d, kl, pivot); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_uint", + "signature": "(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return __tact_dict_set_ref(d, kl, k, v); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + "__tact_dict_set_ref", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_cell", + "signature": "(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get_ref(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get_ref", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_cell", + "signature": "cell __tact_dict_get_slice_cell(cell d, int kl, slice k)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min_ref(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min_ref", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_cell", + "signature": "(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(d, kl, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_cell", + "signature": "(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_slice", + "signature": "(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_slice", + "signature": "slice __tact_dict_get_slice_slice(cell d, int kl, slice k)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_slice", + "signature": "(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl)", + }, + { + "code": { + "code": "return __tact_dict_next(d, kl, pivot);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_slice", + "signature": "(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot)", + }, + { + "code": { + "code": "return equal_slices_bits(a, b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_bits", + "signature": "int __tact_slice_eq_bits(slice a, slice b)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (equal_slices_bits(a, b));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_bits_nullable_one", + "signature": "int __tact_slice_eq_bits_nullable_one(slice a, slice b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( equal_slices_bits(a, b) ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_bits_nullable", + "signature": "int __tact_slice_eq_bits_nullable(slice a, slice b)", + }, + { + "code": { + "code": "(slice key, slice value, int flag) = __tact_dict_min(a, kl); +while (flag) { + (slice value_b, int flag_b) = b~__tact_dict_delete_get(kl, key); + ifnot (flag_b) { + return 0; + } + ifnot (value.slice_hash() == value_b.slice_hash()) { + return 0; + } + (key, value, flag) = __tact_dict_next(a, kl, key); +} +return null?(b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + "__tact_dict_delete_get", + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_eq", + "signature": "int __tact_dict_eq(cell a, cell b, int kl)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (a == b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_eq_nullable_one", + "signature": "int __tact_int_eq_nullable_one(int a, int b)", + }, + { + "code": { + "code": "return (null?(a)) ? (true) : (a != b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_neq_nullable_one", + "signature": "int __tact_int_neq_nullable_one(int a, int b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a == b ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_eq_nullable", + "signature": "int __tact_int_eq_nullable(int a, int b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a != b ) : ( true ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_neq_nullable", + "signature": "int __tact_int_neq_nullable(int a, int b)", + }, + { + "code": { + "code": "return (a.cell_hash() == b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_eq", + "signature": "int __tact_cell_eq(cell a, cell b)", + }, + { + "code": { + "code": "return (a.cell_hash() != b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_neq", + "signature": "int __tact_cell_neq(cell a, cell b)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_eq_nullable_one", + "signature": "int __tact_cell_eq_nullable_one(cell a, cell b)", + }, + { + "code": { + "code": "return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_neq_nullable_one", + "signature": "int __tact_cell_neq_nullable_one(cell a, cell b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() == b.cell_hash() ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_eq_nullable", + "signature": "int __tact_cell_eq_nullable(cell a, cell b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() != b.cell_hash() ) : ( true ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_neq_nullable", + "signature": "int __tact_cell_neq_nullable(cell a, cell b)", + }, + { + "code": { + "code": "return (a.slice_hash() == b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq", + "signature": "int __tact_slice_eq(slice a, slice b)", + }, + { + "code": { + "code": "return (a.slice_hash() != b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_neq", + "signature": "int __tact_slice_neq(slice a, slice b)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_nullable_one", + "signature": "int __tact_slice_eq_nullable_one(slice a, slice b)", + }, + { + "code": { + "code": "return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_neq_nullable_one", + "signature": "int __tact_slice_neq_nullable_one(slice a, slice b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() == b.slice_hash() ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_nullable", + "signature": "int __tact_slice_eq_nullable(slice a, slice b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() != b.slice_hash() ) : ( true ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_neq_nullable", + "signature": "int __tact_slice_neq_nullable(slice a, slice b)", + }, + { + "code": { + "code": "return udict_set_ref(dict, 16, id, code);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_code", + "signature": "cell __tact_dict_set_code(cell dict, int id, cell code)", + }, + { + "code": { + "code": "var (data, ok) = udict_get_ref?(dict, 16, id); +throw_unless(135, ok); +return data;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_code", + "signature": "cell __tact_dict_get_code(cell dict, int id)", + }, + { + "code": { + "code": "NIL", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_0", + "signature": "tuple __tact_tuple_create_0()", + }, + { + "code": { + "code": "return ();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_tuple_destroy_0", + "signature": "() __tact_tuple_destroy_0()", + }, + { + "code": { + "code": "1 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_1", + "signature": "forall X0 -> tuple __tact_tuple_create_1((X0) v)", + }, + { + "code": { + "code": "1 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_1", + "signature": "forall X0 -> (X0) __tact_tuple_destroy_1(tuple v)", + }, + { + "code": { + "code": "2 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_2", + "signature": "forall X0, X1 -> tuple __tact_tuple_create_2((X0, X1) v)", + }, + { + "code": { + "code": "2 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_2", + "signature": "forall X0, X1 -> (X0, X1) __tact_tuple_destroy_2(tuple v)", + }, + { + "code": { + "code": "3 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_3", + "signature": "forall X0, X1, X2 -> tuple __tact_tuple_create_3((X0, X1, X2) v)", + }, + { + "code": { + "code": "3 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_3", + "signature": "forall X0, X1, X2 -> (X0, X1, X2) __tact_tuple_destroy_3(tuple v)", + }, + { + "code": { + "code": "4 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_4", + "signature": "forall X0, X1, X2, X3 -> tuple __tact_tuple_create_4((X0, X1, X2, X3) v)", + }, + { + "code": { + "code": "4 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_4", + "signature": "forall X0, X1, X2, X3 -> (X0, X1, X2, X3) __tact_tuple_destroy_4(tuple v)", + }, + { + "code": { + "code": "5 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_5", + "signature": "forall X0, X1, X2, X3, X4 -> tuple __tact_tuple_create_5((X0, X1, X2, X3, X4) v)", + }, + { + "code": { + "code": "5 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_5", + "signature": "forall X0, X1, X2, X3, X4 -> (X0, X1, X2, X3, X4) __tact_tuple_destroy_5(tuple v)", + }, + { + "code": { + "code": "6 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_6", + "signature": "forall X0, X1, X2, X3, X4, X5 -> tuple __tact_tuple_create_6((X0, X1, X2, X3, X4, X5) v)", + }, + { + "code": { + "code": "6 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_6", + "signature": "forall X0, X1, X2, X3, X4, X5 -> (X0, X1, X2, X3, X4, X5) __tact_tuple_destroy_6(tuple v)", + }, + { + "code": { + "code": "7 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_7", + "signature": "forall X0, X1, X2, X3, X4, X5, X6 -> tuple __tact_tuple_create_7((X0, X1, X2, X3, X4, X5, X6) v)", + }, + { + "code": { + "code": "7 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_7", + "signature": "forall X0, X1, X2, X3, X4, X5, X6 -> (X0, X1, X2, X3, X4, X5, X6) __tact_tuple_destroy_7(tuple v)", + }, + { + "code": { + "code": "8 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_8", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7 -> tuple __tact_tuple_create_8((X0, X1, X2, X3, X4, X5, X6, X7) v)", + }, + { + "code": { + "code": "8 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_8", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7 -> (X0, X1, X2, X3, X4, X5, X6, X7) __tact_tuple_destroy_8(tuple v)", + }, + { + "code": { + "code": "9 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_9", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8 -> tuple __tact_tuple_create_9((X0, X1, X2, X3, X4, X5, X6, X7, X8) v)", + }, + { + "code": { + "code": "9 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_9", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8) __tact_tuple_destroy_9(tuple v)", + }, + { + "code": { + "code": "10 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_10", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9 -> tuple __tact_tuple_create_10((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) v)", + }, + { + "code": { + "code": "10 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_10", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) __tact_tuple_destroy_10(tuple v)", + }, + { + "code": { + "code": "11 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_11", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10 -> tuple __tact_tuple_create_11((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) v)", + }, + { + "code": { + "code": "11 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_11", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) __tact_tuple_destroy_11(tuple v)", + }, + { + "code": { + "code": "12 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_12", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11 -> tuple __tact_tuple_create_12((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) v)", + }, + { + "code": { + "code": "12 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_12", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) __tact_tuple_destroy_12(tuple v)", + }, + { + "code": { + "code": "13 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_13", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12 -> tuple __tact_tuple_create_13((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) v)", + }, + { + "code": { + "code": "13 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_13", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) __tact_tuple_destroy_13(tuple v)", + }, + { + "code": { + "code": "14 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_14", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13 -> tuple __tact_tuple_create_14((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) v)", + }, + { + "code": { + "code": "14 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_14", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) __tact_tuple_destroy_14(tuple v)", + }, + { + "code": { + "code": "15 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_15", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14 -> tuple __tact_tuple_create_15((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) v)", + }, + { + "code": { + "code": "15 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_15", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) __tact_tuple_destroy_15(tuple v)", + }, + { + "code": { + "code": "return tpush(tpush(empty_tuple(), b), null());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start", + "signature": "tuple __tact_string_builder_start(builder b)", + }, + { + "code": { + "code": "return __tact_string_builder_start(begin_cell().store_uint(0, 32));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_start", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start_comment", + "signature": "tuple __tact_string_builder_start_comment()", + }, + { + "code": { + "code": "return __tact_string_builder_start(begin_cell().store_uint(0, 8));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_start", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start_tail_string", + "signature": "tuple __tact_string_builder_start_tail_string()", + }, + { + "code": { + "code": "return __tact_string_builder_start(begin_cell());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_start", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start_string", + "signature": "tuple __tact_string_builder_start_string()", + }, + { + "code": { + "code": "(builder b, tuple tail) = uncons(builders); +cell c = b.end_cell(); +while(~ null?(tail)) { + (b, tail) = uncons(tail); + c = b.store_ref(c).end_cell(); +} +return c;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_end", + "signature": "cell __tact_string_builder_end(tuple builders)", + }, + { + "code": { + "code": "return __tact_string_builder_end(builders).begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_end", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_end_slice", + "signature": "slice __tact_string_builder_end_slice(tuple builders)", + }, + { + "code": { + "code": "int sliceRefs = slice_refs(sc); +int sliceBits = slice_bits(sc); + +while((sliceBits > 0) | (sliceRefs > 0)) { + + ;; Load the current builder + (builder b, tuple tail) = uncons(builders); + int remBytes = 127 - (builder_bits(b) / 8); + int exBytes = sliceBits / 8; + + ;; Append bits + int amount = min(remBytes, exBytes); + if (amount > 0) { + slice read = sc~load_bits(amount * 8); + b = b.store_slice(read); + } + + ;; Update builders + builders = cons(b, tail); + + ;; Check if we need to add a new cell and continue + if (exBytes - amount > 0) { + var bb = begin_cell(); + builders = cons(bb, builders); + sliceBits = (exBytes - amount) * 8; + } elseif (sliceRefs > 0) { + sc = sc~load_ref().begin_parse(); + sliceRefs = slice_refs(sc); + sliceBits = slice_bits(sc); + } else { + sliceBits = 0; + sliceRefs = 0; + } +} + +return ((builders), ());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_string_builder_append", + "signature": "((tuple), ()) __tact_string_builder_append(tuple builders, slice sc)", + }, + { + "code": { + "code": "builders~__tact_string_builder_append(sc); +return builders;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_append", + }, + "flags": Set {}, + "name": "__tact_string_builder_append_not_mut", + "signature": "(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc)", + }, + { + "code": { + "code": "var b = begin_cell(); +if (src < 0) { + b = b.store_uint(45, 8); + src = - src; +} + +if (src < 1000000000000000000000000000000) { + int len = 0; + int value = 0; + int mult = 1; + do { + (src, int res) = src.divmod(10); + value = value + (res + 48) * mult; + mult = mult * 256; + len = len + 1; + } until (src == 0); + + b = b.store_uint(value, len * 8); +} else { + tuple t = empty_tuple(); + int len = 0; + do { + int digit = src % 10; + t~tpush(digit); + len = len + 1; + src = src / 10; + } until (src == 0); + + int c = len - 1; + repeat(len) { + int v = t.at(c); + b = b.store_uint(v + 48, 8); + c = c - 1; + } +} +return b.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_int_to_string", + "signature": "slice __tact_int_to_string(int src)", + }, + { + "code": { + "code": "throw_if(134, (digits <= 0) | (digits > 77)); +builder b = begin_cell(); + +if (src < 0) { + b = b.store_uint(45, 8); + src = - src; +} + +;; Process rem part +int skip = true; +int len = 0; +int rem = 0; +tuple t = empty_tuple(); +repeat(digits) { + (src, rem) = src.divmod(10); + if ( ~ ( skip & ( rem == 0 ) ) ) { + skip = false; + t~tpush(rem + 48); + len = len + 1; + } +} + +;; Process dot +if (~ skip) { + t~tpush(46); + len = len + 1; +} + +;; Main +do { + (src, rem) = src.divmod(10); + t~tpush(rem + 48); + len = len + 1; +} until (src == 0); + +;; Assemble +int c = len - 1; +repeat(len) { + int v = t.at(c); + b = b.store_uint(v, 8); + c = c - 1; +} + +;; Result +return b.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_float_to_string", + "signature": "slice __tact_float_to_string(int src, int digits)", + }, + { + "code": { + "code": "throw_unless(5, num > 0); +throw_unless(5, base > 1); +if (num < base) { + return 0; +} +int result = 0; +while (num >= base) { + num /= base; + result += 1; +} +return result;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_log", + "signature": "int __tact_log(int num, int base)", + }, + { + "code": { + "code": "throw_unless(5, exp >= 0); +int result = 1; +repeat (exp) { + result *= base; +} +return result;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_pow", + "signature": "int __tact_pow(int base, int exp)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +return ok;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_exists_int", + "signature": "int __tact_dict_exists_int(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +return ok;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_exists_uint", + "signature": "int __tact_dict_exists_uint(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +return ok;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_exists_slice", + "signature": "int __tact_dict_exists_slice(cell d, int kl, slice k)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +build_0 = build_0.store_int(v'a, 257); +build_0 = build_0.store_int(v'b, 257); +build_0 = ~ null?(v'c) ? build_0.store_int(true, 1).store_int(v'c, 257) : build_0.store_int(false, 1); +build_0 = build_0.store_int(v'd, 1); +build_0 = ~ null?(v'e) ? build_0.store_int(true, 1).store_int(v'e, 1) : build_0.store_int(false, 1); +var build_1 = begin_cell(); +build_1 = build_1.store_int(v'f, 257); +build_1 = build_1.store_int(v'g, 257); +build_0 = store_ref(build_0, build_1.end_cell()); +return build_0;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set {}, + "name": "$A$_store", + "signature": "builder $A$_store(builder build_0, (int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "return $A$_store(begin_cell(), v).end_cell();", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_store", + }, + "flags": Set { + "inline", + }, + "name": "$A$_store_cell", + "signature": "cell $A$_store_cell((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'a;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_a", + "signature": "_ $A$_get_a((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'b;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_b", + "signature": "_ $A$_get_b((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'c;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_c", + "signature": "_ $A$_get_c((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'd;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_d", + "signature": "_ $A$_get_d((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'e;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_e", + "signature": "_ $A$_get_e((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'f;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_f", + "signature": "_ $A$_get_f((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'g;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_g", + "signature": "_ $A$_get_g((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set {}, + "name": "$A$_tensor_cast", + "signature": "((int, int, int, int, int, int, int)) $A$_tensor_cast((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "throw_if(128, null?(v)); +var (int vvv'a, int vvv'b, int vvv'c, int vvv'd, int vvv'e, int vvv'f, int vvv'g) = __tact_tuple_destroy_7(v); +return (vvv'a, vvv'b, vvv'c, vvv'd, vvv'e, vvv'f, vvv'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_not_null", + "signature": "((int, int, int, int, int, int, int)) $A$_not_null(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_as_optional", + "signature": "tuple $A$_as_optional((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_to_tuple", + "signature": "tuple $A$_to_tuple(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $A$_to_tuple($A$_not_null(v)); ", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_to_tuple", + "$A$_not_null", + }, + "flags": Set { + "inline", + }, + "name": "$A$_to_opt_tuple", + "signature": "tuple $A$_to_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (int v'a, int v'b, int v'c, int v'd, int v'e, int v'f, int v'g) = __tact_tuple_destroy_7(v); +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_from_tuple", + "signature": "(int, int, int, int, int, int, int) $A$_from_tuple(tuple v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $A$_as_optional($A$_from_tuple(v));", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_as_optional", + "$A$_from_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$A$_from_opt_tuple", + "signature": "tuple $A$_from_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_to_external", + "signature": "(int, int, int, int, int, int, int) $A$_to_external(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "var loaded = $A$_to_opt_tuple(v); +if (null?(loaded)) { + return null(); +} else { + return (loaded); +}", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_to_opt_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$A$_to_opt_external", + "signature": "tuple $A$_to_opt_external(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'a;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_a", + "signature": "_ $B$_get_a((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'b;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_b", + "signature": "_ $B$_get_b((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'c;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_c", + "signature": "_ $B$_get_c((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'd;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_d", + "signature": "_ $B$_get_d((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'e;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_e", + "signature": "_ $B$_get_e((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'f;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_f", + "signature": "_ $B$_get_f((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'g;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_g", + "signature": "_ $B$_get_g((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set {}, + "name": "$B$_tensor_cast", + "signature": "((int, int, int, int, int, int, int)) $B$_tensor_cast((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "throw_if(128, null?(v)); +var (int vvv'a, int vvv'b, int vvv'c, int vvv'd, int vvv'e, int vvv'f, int vvv'g) = __tact_tuple_destroy_7(v); +return (vvv'a, vvv'b, vvv'c, vvv'd, vvv'e, vvv'f, vvv'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_not_null", + "signature": "((int, int, int, int, int, int, int)) $B$_not_null(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_as_optional", + "signature": "tuple $B$_as_optional((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_to_tuple", + "signature": "tuple $B$_to_tuple(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $B$_to_tuple($B$_not_null(v)); ", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_to_tuple", + "$B$_not_null", + }, + "flags": Set { + "inline", + }, + "name": "$B$_to_opt_tuple", + "signature": "tuple $B$_to_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (int v'a, int v'b, int v'c, int v'd, int v'e, int v'f, int v'g) = __tact_tuple_destroy_7(v); +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_from_tuple", + "signature": "(int, int, int, int, int, int, int) $B$_from_tuple(tuple v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $B$_as_optional($B$_from_tuple(v));", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_as_optional", + "$B$_from_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$B$_from_opt_tuple", + "signature": "tuple $B$_from_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_to_external", + "signature": "(int, int, int, int, int, int, int) $B$_to_external(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "var loaded = $B$_to_opt_tuple(v); +if (null?(loaded)) { + return null(); +} else { + return (loaded); +}", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_to_opt_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$B$_to_opt_external", + "signature": "tuple $B$_to_opt_external(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'a;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_a", + "signature": "_ $C$_get_a((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'b;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_b", + "signature": "_ $C$_get_b((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'c;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_c", + "signature": "_ $C$_get_c((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'd;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_d", + "signature": "_ $C$_get_d((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'e;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_e", + "signature": "_ $C$_get_e((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'f;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_f", + "signature": "_ $C$_get_f((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'g;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_g", + "signature": "_ $C$_get_g((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'h;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_h", + "signature": "_ $C$_get_h((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set {}, + "name": "$C$_tensor_cast", + "signature": "((cell, cell, slice, slice, int, int, int, slice)) $C$_tensor_cast((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "throw_if(128, null?(v)); +var (cell vvv'a, cell vvv'b, slice vvv'c, slice vvv'd, int vvv'e, int vvv'f, int vvv'g, slice vvv'h) = __tact_tuple_destroy_8(v); +return (vvv'a, vvv'b, vvv'c, vvv'd, vvv'e, vvv'f, vvv'g, vvv'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_tuple_destroy_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_not_null", + "signature": "((cell, cell, slice, slice, int, int, int, slice)) $C$_not_null(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return __tact_tuple_create_8(v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_tuple_create_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_as_optional", + "signature": "tuple $C$_as_optional((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return __tact_tuple_create_8(v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_tuple_create_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_to_tuple", + "signature": "tuple $C$_to_tuple(((cell, cell, slice, slice, int, int, int, slice)) v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $C$_to_tuple($C$_not_null(v)); ", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_to_tuple", + "$C$_not_null", + }, + "flags": Set { + "inline", + }, + "name": "$C$_to_opt_tuple", + "signature": "tuple $C$_to_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (cell v'a, cell v'b, slice v'c, slice v'd, int v'e, int v'f, int v'g, slice v'h) = __tact_tuple_destroy_8(v); +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g, __tact_verify_address(v'h));", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_verify_address", + "__tact_tuple_destroy_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_from_tuple", + "signature": "(cell, cell, slice, slice, int, int, int, slice) $C$_from_tuple(tuple v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $C$_as_optional($C$_from_tuple(v));", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_as_optional", + "$C$_from_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$C$_from_opt_tuple", + "signature": "tuple $C$_from_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_to_external", + "signature": "(cell, cell, slice, slice, int, int, int, slice) $C$_to_external(((cell, cell, slice, slice, int, int, int, slice)) v)", + }, + { + "code": { + "code": "var loaded = $C$_to_opt_tuple(v); +if (null?(loaded)) { + return null(); +} else { + return (loaded); +}", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_to_opt_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$C$_to_opt_external", + "signature": "tuple $C$_to_opt_external(tuple v)", + }, + { + "code": { + "code": "var v'a = sc_0~load_int(257); +var v'b = sc_0~load_int(257); +var v'c = sc_0~load_int(1) ? sc_0~load_int(257) : null(); +var v'd = sc_0~load_int(1); +var v'e = sc_0~load_int(1) ? sc_0~load_int(1) : null(); +slice sc_1 = sc_0~load_ref().begin_parse(); +var v'f = sc_1~load_int(257); +var v'g = sc_1~load_int(257); +return (sc_0, (v'a, v'b, v'c, v'd, v'e, v'f, v'g));", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set {}, + "name": "$A$_load", + "signature": "(slice, ((int, int, int, int, int, int, int))) $A$_load(slice sc_0)", + }, + { + "code": { + "code": "var r = sc_0~$A$_load(); +sc_0.end_parse(); +return r;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_load", + }, + "flags": Set {}, + "name": "$A$_load_not_mut", + "signature": "((int, int, int, int, int, int, int)) $A$_load_not_mut(slice sc_0)", + }, +] +`; + +exports[`writeSerialization should write serializer for B 1`] = ` +[ + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_set", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_nop", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_str_to_slice", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_slice_to_str", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_address_to_slice", + "signature": "", + }, + { + "code": { + "code": "throw_unless(136, address.slice_bits() == 267); +var h = address.preload_uint(11); +throw_if(137, h == 1279); +throw_unless(136, h == 1024); +return address;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + "inline", + }, + "name": "__tact_verify_address", + "signature": "slice __tact_verify_address(slice address)", + }, + { + "code": { + "code": "slice raw = cs~load_msg_addr(); +return (cs, __tact_verify_address(raw));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_load_address", + "signature": "(slice, slice) __tact_load_address(slice cs)", + }, + { + "code": { + "code": "if (cs.preload_uint(2) != 0) { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); +} else { + cs~skip_bits(2); + return (cs, null()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_load_address_opt", + "signature": "(slice, slice) __tact_load_address_opt(slice cs)", + }, + { + "code": { + "code": "return b.store_slice(__tact_verify_address(address));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_store_address", + "signature": "builder __tact_store_address(builder b, slice address)", + }, + { + "code": { + "code": "if (null?(address)) { + b = b.store_uint(0, 2); + return b; +} else { + return __tact_store_address(b, address); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_store_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_store_address_opt", + "signature": "builder __tact_store_address_opt(builder b, slice address)", + }, + { + "code": { + "code": "var b = begin_cell(); +b = b.store_uint(2, 2); +b = b.store_uint(0, 1); +b = b.store_int(chain, 8); +b = b.store_uint(hash, 256); +var addr = b.end_cell().begin_parse(); +return __tact_verify_address(addr);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_create_address", + "signature": "slice __tact_create_address(int chain, int hash)", + }, + { + "code": { + "code": "var b = begin_cell(); +b = b.store_uint(0, 2); +b = b.store_uint(3, 2); +b = b.store_uint(0, 1); +b = b.store_ref(code); +b = b.store_ref(data); +var hash = cell_hash(b.end_cell()); +return __tact_create_address(chain, hash);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_create_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_compute_contract_address", + "signature": "slice __tact_compute_contract_address(int chain, cell code, cell data)", + }, + { + "code": { + "code": "throw_if(128, null?(x)); return x;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + "inline", + }, + "name": "__tact_not_null", + "signature": "forall X -> X __tact_not_null(X x)", + }, + { + "code": { + "code": "DICTDEL", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete", + "signature": "(cell, int) __tact_dict_delete(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTIDEL", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete_int", + "signature": "(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index)", + }, + { + "code": { + "code": "DICTUDEL", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete_uint", + "signature": "(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index)", + }, + { + "code": { + "code": "DICTSETREF", + "kind": "asm", + "shuffle": "(value index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_set_ref", + "signature": "((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value)", + }, + { + "code": { + "code": "DICTGET NULLSWAPIFNOT", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_get", + "signature": "(slice, int) __tact_dict_get(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTDELGET NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete_get", + "signature": "(cell, (slice, int)) __tact_dict_delete_get(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTGETREF NULLSWAPIFNOT", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_get_ref", + "signature": "(cell, int) __tact_dict_get_ref(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTMIN NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(dict key_len -> 1 0 2)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_min", + "signature": "(slice, slice, int) __tact_dict_min(cell dict, int key_len)", + }, + { + "code": { + "code": "DICTMINREF NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(dict key_len -> 1 0 2)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_min_ref", + "signature": "(slice, cell, int) __tact_dict_min_ref(cell dict, int key_len)", + }, + { + "code": { + "code": "DICTGETNEXT NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(pivot dict key_len -> 1 0 2)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_next", + "signature": "(slice, slice, int) __tact_dict_next(cell dict, int key_len, slice pivot)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(dict, key_len, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set {}, + "name": "__tact_dict_next_ref", + "signature": "(slice, cell, int) __tact_dict_next_ref(cell dict, int key_len, slice pivot)", + }, + { + "code": { + "code": "STRDUMP DROP STRDUMP DROP s0 DUMP DROP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + }, + "name": "__tact_debug", + "signature": "forall X -> () __tact_debug(X value, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "STRDUMP DROP STRDUMP DROP STRDUMP DROP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + }, + "name": "__tact_debug_str", + "signature": "() __tact_debug_str(slice value, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "if (value) { + __tact_debug_str("true", debug_print_1, debug_print_2); +} else { + __tact_debug_str("false", debug_print_1, debug_print_2); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_debug_str", + }, + "flags": Set { + "impure", + }, + "name": "__tact_debug_bool", + "signature": "() __tact_debug_bool(int value, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "SDSUBSTR", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_preload_offset", + "signature": "(slice) __tact_preload_offset(slice s, int offset, int bits)", + }, + { + "code": { + "code": "slice new_data = begin_cell() + .store_slice(data) + .store_slice("0000"s) +.end_cell().begin_parse(); +int reg = 0; +while (~ new_data.slice_data_empty?()) { + int byte = new_data~load_uint(8); + int mask = 0x80; + while (mask > 0) { + reg <<= 1; + if (byte & mask) { + reg += 1; + } + mask >>= 1; + if (reg > 0xffff) { + reg &= 0xffff; + reg ^= 0x1021; + } + } +} +(int q, int r) = divmod(reg, 256); +return begin_cell() + .store_uint(q, 8) + .store_uint(r, 8) +.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline_ref", + }, + "name": "__tact_crc16", + "signature": "(slice) __tact_crc16(slice data)", + }, + { + "code": { + "code": "slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; +builder res = begin_cell(); + +while (data.slice_bits() >= 24) { + (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); + + int n = (bs1 << 16) | (bs2 << 8) | bs3; + + res = res + .store_slice(__tact_preload_offset(chars, ((n >> 18) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 12) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 6) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n ) & 63) * 8, 8)); +} + +return res.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_preload_offset", + }, + "flags": Set {}, + "name": "__tact_base64_encode", + "signature": "(slice) __tact_base64_encode(slice data)", + }, + { + "code": { + "code": "(int wc, int hash) = address.parse_std_addr(); + +slice user_friendly_address = begin_cell() + .store_slice("11"s) + .store_uint((wc + 0x100) % 0x100, 8) + .store_uint(hash, 256) +.end_cell().begin_parse(); + +slice checksum = __tact_crc16(user_friendly_address); +slice user_friendly_address_with_checksum = begin_cell() + .store_slice(user_friendly_address) + .store_slice(checksum) +.end_cell().begin_parse(); + +return __tact_base64_encode(user_friendly_address_with_checksum);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_crc16", + "__tact_base64_encode", + }, + "flags": Set {}, + "name": "__tact_address_to_user_friendly", + "signature": "(slice) __tact_address_to_user_friendly(slice address)", + }, + { + "code": { + "code": "__tact_debug_str(__tact_address_to_user_friendly(address), debug_print_1, debug_print_2);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_debug_str", + "__tact_address_to_user_friendly", + }, + "flags": Set { + "impure", + }, + "name": "__tact_debug_address", + "signature": "() __tact_debug_address(slice address, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "STRDUMP DROP STRDUMP DROP DUMPSTK", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + }, + "name": "__tact_debug_stack", + "signature": "() __tact_debug_stack(slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "return __tact_context;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_context_get", + "signature": "(int, slice, int, slice) __tact_context_get()", + }, + { + "code": { + "code": "return __tact_context_sender;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_context_get_sender", + "signature": "slice __tact_context_get_sender()", + }, + { + "code": { + "code": "if (null?(__tact_randomized)) { + randomize_lt(); + __tact_randomized = true; +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + "inline", + }, + "name": "__tact_prepare_random", + "signature": "() __tact_prepare_random()", + }, + { + "code": { + "code": "return b.store_int(v, 1);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_store_bool", + "signature": "builder __tact_store_bool(builder b, int v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_to_tuple", + "signature": "forall X -> tuple __tact_to_tuple(X x)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_from_tuple", + "signature": "forall X -> X __tact_from_tuple(tuple x)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_int", + "signature": "(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +if (ok) { + return r~load_int(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_int", + "signature": "int __tact_dict_get_int_int(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min?(d, kl); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_int", + "signature": "(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_int", + "signature": "(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_uint", + "signature": "(cell, ()) __tact_dict_set_int_uint(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +if (ok) { + return r~load_uint(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_uint", + "signature": "int __tact_dict_get_int_uint(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min?(d, kl); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_uint", + "signature": "(int, int, int) __tact_dict_min_int_uint(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_uint", + "signature": "(int, int, int) __tact_dict_next_int_uint(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_int", + "signature": "(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +if (ok) { + return r~load_int(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_int", + "signature": "int __tact_dict_get_uint_int(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min?(d, kl); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_int", + "signature": "(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_int", + "signature": "(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_uint", + "signature": "(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +if (ok) { + return r~load_uint(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_uint", + "signature": "int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min?(d, kl); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_uint", + "signature": "(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_uint", + "signature": "(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set_ref(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_cell", + "signature": "(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v)", + }, + { + "code": { + "code": "var (r, ok) = idict_get_ref?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_cell", + "signature": "cell __tact_dict_get_int_cell(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min_ref?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_cell", + "signature": "(int, cell, int) __tact_dict_min_int_cell(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_cell", + "signature": "(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set_ref(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_cell", + "signature": "(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v)", + }, + { + "code": { + "code": "var (r, ok) = udict_get_ref?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_cell", + "signature": "cell __tact_dict_get_uint_cell(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min_ref?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_cell", + "signature": "(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_cell", + "signature": "(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_slice", + "signature": "(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_slice", + "signature": "slice __tact_dict_get_int_slice(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_slice", + "signature": "(int, slice, int) __tact_dict_min_int_slice(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_slice", + "signature": "(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_slice", + "signature": "(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_slice", + "signature": "slice __tact_dict_get_uint_slice(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_slice", + "signature": "(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_slice", + "signature": "(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_int", + "signature": "(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +if (ok) { + return r~load_int(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_int", + "signature": "int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min(d, kl); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_int", + "signature": "(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(d, kl, pivot); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_int", + "signature": "(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_uint", + "signature": "(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +if (ok) { + return r~load_uint(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_uint", + "signature": "int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min(d, kl); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_uint", + "signature": "(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(d, kl, pivot); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_uint", + "signature": "(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return __tact_dict_set_ref(d, kl, k, v); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + "__tact_dict_set_ref", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_cell", + "signature": "(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get_ref(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get_ref", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_cell", + "signature": "cell __tact_dict_get_slice_cell(cell d, int kl, slice k)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min_ref(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min_ref", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_cell", + "signature": "(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(d, kl, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_cell", + "signature": "(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_slice", + "signature": "(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_slice", + "signature": "slice __tact_dict_get_slice_slice(cell d, int kl, slice k)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_slice", + "signature": "(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl)", + }, + { + "code": { + "code": "return __tact_dict_next(d, kl, pivot);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_slice", + "signature": "(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot)", + }, + { + "code": { + "code": "return equal_slices_bits(a, b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_bits", + "signature": "int __tact_slice_eq_bits(slice a, slice b)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (equal_slices_bits(a, b));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_bits_nullable_one", + "signature": "int __tact_slice_eq_bits_nullable_one(slice a, slice b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( equal_slices_bits(a, b) ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_bits_nullable", + "signature": "int __tact_slice_eq_bits_nullable(slice a, slice b)", + }, + { + "code": { + "code": "(slice key, slice value, int flag) = __tact_dict_min(a, kl); +while (flag) { + (slice value_b, int flag_b) = b~__tact_dict_delete_get(kl, key); + ifnot (flag_b) { + return 0; + } + ifnot (value.slice_hash() == value_b.slice_hash()) { + return 0; + } + (key, value, flag) = __tact_dict_next(a, kl, key); +} +return null?(b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + "__tact_dict_delete_get", + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_eq", + "signature": "int __tact_dict_eq(cell a, cell b, int kl)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (a == b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_eq_nullable_one", + "signature": "int __tact_int_eq_nullable_one(int a, int b)", + }, + { + "code": { + "code": "return (null?(a)) ? (true) : (a != b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_neq_nullable_one", + "signature": "int __tact_int_neq_nullable_one(int a, int b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a == b ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_eq_nullable", + "signature": "int __tact_int_eq_nullable(int a, int b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a != b ) : ( true ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_neq_nullable", + "signature": "int __tact_int_neq_nullable(int a, int b)", + }, + { + "code": { + "code": "return (a.cell_hash() == b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_eq", + "signature": "int __tact_cell_eq(cell a, cell b)", + }, + { + "code": { + "code": "return (a.cell_hash() != b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_neq", + "signature": "int __tact_cell_neq(cell a, cell b)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_eq_nullable_one", + "signature": "int __tact_cell_eq_nullable_one(cell a, cell b)", + }, + { + "code": { + "code": "return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_neq_nullable_one", + "signature": "int __tact_cell_neq_nullable_one(cell a, cell b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() == b.cell_hash() ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_eq_nullable", + "signature": "int __tact_cell_eq_nullable(cell a, cell b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() != b.cell_hash() ) : ( true ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_neq_nullable", + "signature": "int __tact_cell_neq_nullable(cell a, cell b)", + }, + { + "code": { + "code": "return (a.slice_hash() == b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq", + "signature": "int __tact_slice_eq(slice a, slice b)", + }, + { + "code": { + "code": "return (a.slice_hash() != b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_neq", + "signature": "int __tact_slice_neq(slice a, slice b)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_nullable_one", + "signature": "int __tact_slice_eq_nullable_one(slice a, slice b)", + }, + { + "code": { + "code": "return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_neq_nullable_one", + "signature": "int __tact_slice_neq_nullable_one(slice a, slice b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() == b.slice_hash() ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_nullable", + "signature": "int __tact_slice_eq_nullable(slice a, slice b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() != b.slice_hash() ) : ( true ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_neq_nullable", + "signature": "int __tact_slice_neq_nullable(slice a, slice b)", + }, + { + "code": { + "code": "return udict_set_ref(dict, 16, id, code);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_code", + "signature": "cell __tact_dict_set_code(cell dict, int id, cell code)", + }, + { + "code": { + "code": "var (data, ok) = udict_get_ref?(dict, 16, id); +throw_unless(135, ok); +return data;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_code", + "signature": "cell __tact_dict_get_code(cell dict, int id)", + }, + { + "code": { + "code": "NIL", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_0", + "signature": "tuple __tact_tuple_create_0()", + }, + { + "code": { + "code": "return ();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_tuple_destroy_0", + "signature": "() __tact_tuple_destroy_0()", + }, + { + "code": { + "code": "1 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_1", + "signature": "forall X0 -> tuple __tact_tuple_create_1((X0) v)", + }, + { + "code": { + "code": "1 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_1", + "signature": "forall X0 -> (X0) __tact_tuple_destroy_1(tuple v)", + }, + { + "code": { + "code": "2 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_2", + "signature": "forall X0, X1 -> tuple __tact_tuple_create_2((X0, X1) v)", + }, + { + "code": { + "code": "2 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_2", + "signature": "forall X0, X1 -> (X0, X1) __tact_tuple_destroy_2(tuple v)", + }, + { + "code": { + "code": "3 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_3", + "signature": "forall X0, X1, X2 -> tuple __tact_tuple_create_3((X0, X1, X2) v)", + }, + { + "code": { + "code": "3 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_3", + "signature": "forall X0, X1, X2 -> (X0, X1, X2) __tact_tuple_destroy_3(tuple v)", + }, + { + "code": { + "code": "4 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_4", + "signature": "forall X0, X1, X2, X3 -> tuple __tact_tuple_create_4((X0, X1, X2, X3) v)", + }, + { + "code": { + "code": "4 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_4", + "signature": "forall X0, X1, X2, X3 -> (X0, X1, X2, X3) __tact_tuple_destroy_4(tuple v)", + }, + { + "code": { + "code": "5 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_5", + "signature": "forall X0, X1, X2, X3, X4 -> tuple __tact_tuple_create_5((X0, X1, X2, X3, X4) v)", + }, + { + "code": { + "code": "5 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_5", + "signature": "forall X0, X1, X2, X3, X4 -> (X0, X1, X2, X3, X4) __tact_tuple_destroy_5(tuple v)", + }, + { + "code": { + "code": "6 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_6", + "signature": "forall X0, X1, X2, X3, X4, X5 -> tuple __tact_tuple_create_6((X0, X1, X2, X3, X4, X5) v)", + }, + { + "code": { + "code": "6 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_6", + "signature": "forall X0, X1, X2, X3, X4, X5 -> (X0, X1, X2, X3, X4, X5) __tact_tuple_destroy_6(tuple v)", + }, + { + "code": { + "code": "7 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_7", + "signature": "forall X0, X1, X2, X3, X4, X5, X6 -> tuple __tact_tuple_create_7((X0, X1, X2, X3, X4, X5, X6) v)", + }, + { + "code": { + "code": "7 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_7", + "signature": "forall X0, X1, X2, X3, X4, X5, X6 -> (X0, X1, X2, X3, X4, X5, X6) __tact_tuple_destroy_7(tuple v)", + }, + { + "code": { + "code": "8 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_8", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7 -> tuple __tact_tuple_create_8((X0, X1, X2, X3, X4, X5, X6, X7) v)", + }, + { + "code": { + "code": "8 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_8", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7 -> (X0, X1, X2, X3, X4, X5, X6, X7) __tact_tuple_destroy_8(tuple v)", + }, + { + "code": { + "code": "9 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_9", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8 -> tuple __tact_tuple_create_9((X0, X1, X2, X3, X4, X5, X6, X7, X8) v)", + }, + { + "code": { + "code": "9 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_9", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8) __tact_tuple_destroy_9(tuple v)", + }, + { + "code": { + "code": "10 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_10", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9 -> tuple __tact_tuple_create_10((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) v)", + }, + { + "code": { + "code": "10 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_10", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) __tact_tuple_destroy_10(tuple v)", + }, + { + "code": { + "code": "11 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_11", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10 -> tuple __tact_tuple_create_11((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) v)", + }, + { + "code": { + "code": "11 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_11", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) __tact_tuple_destroy_11(tuple v)", + }, + { + "code": { + "code": "12 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_12", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11 -> tuple __tact_tuple_create_12((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) v)", + }, + { + "code": { + "code": "12 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_12", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) __tact_tuple_destroy_12(tuple v)", + }, + { + "code": { + "code": "13 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_13", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12 -> tuple __tact_tuple_create_13((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) v)", + }, + { + "code": { + "code": "13 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_13", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) __tact_tuple_destroy_13(tuple v)", + }, + { + "code": { + "code": "14 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_14", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13 -> tuple __tact_tuple_create_14((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) v)", + }, + { + "code": { + "code": "14 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_14", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) __tact_tuple_destroy_14(tuple v)", + }, + { + "code": { + "code": "15 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_15", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14 -> tuple __tact_tuple_create_15((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) v)", + }, + { + "code": { + "code": "15 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_15", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) __tact_tuple_destroy_15(tuple v)", + }, + { + "code": { + "code": "return tpush(tpush(empty_tuple(), b), null());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start", + "signature": "tuple __tact_string_builder_start(builder b)", + }, + { + "code": { + "code": "return __tact_string_builder_start(begin_cell().store_uint(0, 32));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_start", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start_comment", + "signature": "tuple __tact_string_builder_start_comment()", + }, + { + "code": { + "code": "return __tact_string_builder_start(begin_cell().store_uint(0, 8));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_start", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start_tail_string", + "signature": "tuple __tact_string_builder_start_tail_string()", + }, + { + "code": { + "code": "return __tact_string_builder_start(begin_cell());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_start", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start_string", + "signature": "tuple __tact_string_builder_start_string()", + }, + { + "code": { + "code": "(builder b, tuple tail) = uncons(builders); +cell c = b.end_cell(); +while(~ null?(tail)) { + (b, tail) = uncons(tail); + c = b.store_ref(c).end_cell(); +} +return c;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_end", + "signature": "cell __tact_string_builder_end(tuple builders)", + }, + { + "code": { + "code": "return __tact_string_builder_end(builders).begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_end", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_end_slice", + "signature": "slice __tact_string_builder_end_slice(tuple builders)", + }, + { + "code": { + "code": "int sliceRefs = slice_refs(sc); +int sliceBits = slice_bits(sc); + +while((sliceBits > 0) | (sliceRefs > 0)) { + + ;; Load the current builder + (builder b, tuple tail) = uncons(builders); + int remBytes = 127 - (builder_bits(b) / 8); + int exBytes = sliceBits / 8; + + ;; Append bits + int amount = min(remBytes, exBytes); + if (amount > 0) { + slice read = sc~load_bits(amount * 8); + b = b.store_slice(read); + } + + ;; Update builders + builders = cons(b, tail); + + ;; Check if we need to add a new cell and continue + if (exBytes - amount > 0) { + var bb = begin_cell(); + builders = cons(bb, builders); + sliceBits = (exBytes - amount) * 8; + } elseif (sliceRefs > 0) { + sc = sc~load_ref().begin_parse(); + sliceRefs = slice_refs(sc); + sliceBits = slice_bits(sc); + } else { + sliceBits = 0; + sliceRefs = 0; + } +} + +return ((builders), ());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_string_builder_append", + "signature": "((tuple), ()) __tact_string_builder_append(tuple builders, slice sc)", + }, + { + "code": { + "code": "builders~__tact_string_builder_append(sc); +return builders;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_append", + }, + "flags": Set {}, + "name": "__tact_string_builder_append_not_mut", + "signature": "(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc)", + }, + { + "code": { + "code": "var b = begin_cell(); +if (src < 0) { + b = b.store_uint(45, 8); + src = - src; +} + +if (src < 1000000000000000000000000000000) { + int len = 0; + int value = 0; + int mult = 1; + do { + (src, int res) = src.divmod(10); + value = value + (res + 48) * mult; + mult = mult * 256; + len = len + 1; + } until (src == 0); + + b = b.store_uint(value, len * 8); +} else { + tuple t = empty_tuple(); + int len = 0; + do { + int digit = src % 10; + t~tpush(digit); + len = len + 1; + src = src / 10; + } until (src == 0); + + int c = len - 1; + repeat(len) { + int v = t.at(c); + b = b.store_uint(v + 48, 8); + c = c - 1; + } +} +return b.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_int_to_string", + "signature": "slice __tact_int_to_string(int src)", + }, + { + "code": { + "code": "throw_if(134, (digits <= 0) | (digits > 77)); +builder b = begin_cell(); + +if (src < 0) { + b = b.store_uint(45, 8); + src = - src; +} + +;; Process rem part +int skip = true; +int len = 0; +int rem = 0; +tuple t = empty_tuple(); +repeat(digits) { + (src, rem) = src.divmod(10); + if ( ~ ( skip & ( rem == 0 ) ) ) { + skip = false; + t~tpush(rem + 48); + len = len + 1; + } +} + +;; Process dot +if (~ skip) { + t~tpush(46); + len = len + 1; +} + +;; Main +do { + (src, rem) = src.divmod(10); + t~tpush(rem + 48); + len = len + 1; +} until (src == 0); + +;; Assemble +int c = len - 1; +repeat(len) { + int v = t.at(c); + b = b.store_uint(v, 8); + c = c - 1; +} + +;; Result +return b.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_float_to_string", + "signature": "slice __tact_float_to_string(int src, int digits)", + }, + { + "code": { + "code": "throw_unless(5, num > 0); +throw_unless(5, base > 1); +if (num < base) { + return 0; +} +int result = 0; +while (num >= base) { + num /= base; + result += 1; +} +return result;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_log", + "signature": "int __tact_log(int num, int base)", + }, + { + "code": { + "code": "throw_unless(5, exp >= 0); +int result = 1; +repeat (exp) { + result *= base; +} +return result;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_pow", + "signature": "int __tact_pow(int base, int exp)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +return ok;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_exists_int", + "signature": "int __tact_dict_exists_int(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +return ok;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_exists_uint", + "signature": "int __tact_dict_exists_uint(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +return ok;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_exists_slice", + "signature": "int __tact_dict_exists_slice(cell d, int kl, slice k)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +build_0 = build_0.store_int(v'a, 257); +build_0 = build_0.store_int(v'b, 257); +build_0 = ~ null?(v'c) ? build_0.store_int(true, 1).store_int(v'c, 257) : build_0.store_int(false, 1); +build_0 = build_0.store_int(v'd, 1); +build_0 = ~ null?(v'e) ? build_0.store_int(true, 1).store_int(v'e, 1) : build_0.store_int(false, 1); +var build_1 = begin_cell(); +build_1 = build_1.store_int(v'f, 257); +build_1 = build_1.store_int(v'g, 257); +build_0 = store_ref(build_0, build_1.end_cell()); +return build_0;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set {}, + "name": "$B$_store", + "signature": "builder $B$_store(builder build_0, (int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "return $B$_store(begin_cell(), v).end_cell();", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_store", + }, + "flags": Set { + "inline", + }, + "name": "$B$_store_cell", + "signature": "cell $B$_store_cell((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'a;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_a", + "signature": "_ $A$_get_a((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'b;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_b", + "signature": "_ $A$_get_b((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'c;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_c", + "signature": "_ $A$_get_c((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'd;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_d", + "signature": "_ $A$_get_d((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'e;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_e", + "signature": "_ $A$_get_e((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'f;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_f", + "signature": "_ $A$_get_f((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'g;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_g", + "signature": "_ $A$_get_g((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set {}, + "name": "$A$_tensor_cast", + "signature": "((int, int, int, int, int, int, int)) $A$_tensor_cast((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "throw_if(128, null?(v)); +var (int vvv'a, int vvv'b, int vvv'c, int vvv'd, int vvv'e, int vvv'f, int vvv'g) = __tact_tuple_destroy_7(v); +return (vvv'a, vvv'b, vvv'c, vvv'd, vvv'e, vvv'f, vvv'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_not_null", + "signature": "((int, int, int, int, int, int, int)) $A$_not_null(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_as_optional", + "signature": "tuple $A$_as_optional((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_to_tuple", + "signature": "tuple $A$_to_tuple(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $A$_to_tuple($A$_not_null(v)); ", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_to_tuple", + "$A$_not_null", + }, + "flags": Set { + "inline", + }, + "name": "$A$_to_opt_tuple", + "signature": "tuple $A$_to_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (int v'a, int v'b, int v'c, int v'd, int v'e, int v'f, int v'g) = __tact_tuple_destroy_7(v); +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_from_tuple", + "signature": "(int, int, int, int, int, int, int) $A$_from_tuple(tuple v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $A$_as_optional($A$_from_tuple(v));", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_as_optional", + "$A$_from_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$A$_from_opt_tuple", + "signature": "tuple $A$_from_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_to_external", + "signature": "(int, int, int, int, int, int, int) $A$_to_external(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "var loaded = $A$_to_opt_tuple(v); +if (null?(loaded)) { + return null(); +} else { + return (loaded); +}", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_to_opt_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$A$_to_opt_external", + "signature": "tuple $A$_to_opt_external(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'a;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_a", + "signature": "_ $B$_get_a((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'b;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_b", + "signature": "_ $B$_get_b((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'c;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_c", + "signature": "_ $B$_get_c((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'd;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_d", + "signature": "_ $B$_get_d((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'e;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_e", + "signature": "_ $B$_get_e((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'f;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_f", + "signature": "_ $B$_get_f((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'g;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_g", + "signature": "_ $B$_get_g((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set {}, + "name": "$B$_tensor_cast", + "signature": "((int, int, int, int, int, int, int)) $B$_tensor_cast((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "throw_if(128, null?(v)); +var (int vvv'a, int vvv'b, int vvv'c, int vvv'd, int vvv'e, int vvv'f, int vvv'g) = __tact_tuple_destroy_7(v); +return (vvv'a, vvv'b, vvv'c, vvv'd, vvv'e, vvv'f, vvv'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_not_null", + "signature": "((int, int, int, int, int, int, int)) $B$_not_null(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_as_optional", + "signature": "tuple $B$_as_optional((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_to_tuple", + "signature": "tuple $B$_to_tuple(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $B$_to_tuple($B$_not_null(v)); ", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_to_tuple", + "$B$_not_null", + }, + "flags": Set { + "inline", + }, + "name": "$B$_to_opt_tuple", + "signature": "tuple $B$_to_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (int v'a, int v'b, int v'c, int v'd, int v'e, int v'f, int v'g) = __tact_tuple_destroy_7(v); +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_from_tuple", + "signature": "(int, int, int, int, int, int, int) $B$_from_tuple(tuple v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $B$_as_optional($B$_from_tuple(v));", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_as_optional", + "$B$_from_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$B$_from_opt_tuple", + "signature": "tuple $B$_from_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_to_external", + "signature": "(int, int, int, int, int, int, int) $B$_to_external(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "var loaded = $B$_to_opt_tuple(v); +if (null?(loaded)) { + return null(); +} else { + return (loaded); +}", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_to_opt_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$B$_to_opt_external", + "signature": "tuple $B$_to_opt_external(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'a;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_a", + "signature": "_ $C$_get_a((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'b;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_b", + "signature": "_ $C$_get_b((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'c;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_c", + "signature": "_ $C$_get_c((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'd;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_d", + "signature": "_ $C$_get_d((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'e;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_e", + "signature": "_ $C$_get_e((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'f;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_f", + "signature": "_ $C$_get_f((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'g;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_g", + "signature": "_ $C$_get_g((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'h;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_h", + "signature": "_ $C$_get_h((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set {}, + "name": "$C$_tensor_cast", + "signature": "((cell, cell, slice, slice, int, int, int, slice)) $C$_tensor_cast((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "throw_if(128, null?(v)); +var (cell vvv'a, cell vvv'b, slice vvv'c, slice vvv'd, int vvv'e, int vvv'f, int vvv'g, slice vvv'h) = __tact_tuple_destroy_8(v); +return (vvv'a, vvv'b, vvv'c, vvv'd, vvv'e, vvv'f, vvv'g, vvv'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_tuple_destroy_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_not_null", + "signature": "((cell, cell, slice, slice, int, int, int, slice)) $C$_not_null(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return __tact_tuple_create_8(v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_tuple_create_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_as_optional", + "signature": "tuple $C$_as_optional((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return __tact_tuple_create_8(v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_tuple_create_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_to_tuple", + "signature": "tuple $C$_to_tuple(((cell, cell, slice, slice, int, int, int, slice)) v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $C$_to_tuple($C$_not_null(v)); ", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_to_tuple", + "$C$_not_null", + }, + "flags": Set { + "inline", + }, + "name": "$C$_to_opt_tuple", + "signature": "tuple $C$_to_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (cell v'a, cell v'b, slice v'c, slice v'd, int v'e, int v'f, int v'g, slice v'h) = __tact_tuple_destroy_8(v); +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g, __tact_verify_address(v'h));", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_verify_address", + "__tact_tuple_destroy_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_from_tuple", + "signature": "(cell, cell, slice, slice, int, int, int, slice) $C$_from_tuple(tuple v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $C$_as_optional($C$_from_tuple(v));", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_as_optional", + "$C$_from_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$C$_from_opt_tuple", + "signature": "tuple $C$_from_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_to_external", + "signature": "(cell, cell, slice, slice, int, int, int, slice) $C$_to_external(((cell, cell, slice, slice, int, int, int, slice)) v)", + }, + { + "code": { + "code": "var loaded = $C$_to_opt_tuple(v); +if (null?(loaded)) { + return null(); +} else { + return (loaded); +}", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_to_opt_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$C$_to_opt_external", + "signature": "tuple $C$_to_opt_external(tuple v)", + }, + { + "code": { + "code": "var v'a = sc_0~load_int(257); +var v'b = sc_0~load_int(257); +var v'c = sc_0~load_int(1) ? sc_0~load_int(257) : null(); +var v'd = sc_0~load_int(1); +var v'e = sc_0~load_int(1) ? sc_0~load_int(1) : null(); +slice sc_1 = sc_0~load_ref().begin_parse(); +var v'f = sc_1~load_int(257); +var v'g = sc_1~load_int(257); +return (sc_0, (v'a, v'b, v'c, v'd, v'e, v'f, v'g));", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set {}, + "name": "$B$_load", + "signature": "(slice, ((int, int, int, int, int, int, int))) $B$_load(slice sc_0)", + }, + { + "code": { + "code": "var r = sc_0~$B$_load(); +sc_0.end_parse(); +return r;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_load", + }, + "flags": Set {}, + "name": "$B$_load_not_mut", + "signature": "((int, int, int, int, int, int, int)) $B$_load_not_mut(slice sc_0)", + }, +] +`; + +exports[`writeSerialization should write serializer for C 1`] = ` +[ + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_set", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_nop", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_str_to_slice", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_slice_to_str", + "signature": "", + }, + { + "code": { + "kind": "skip", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_address_to_slice", + "signature": "", + }, + { + "code": { + "code": "throw_unless(136, address.slice_bits() == 267); +var h = address.preload_uint(11); +throw_if(137, h == 1279); +throw_unless(136, h == 1024); +return address;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + "inline", + }, + "name": "__tact_verify_address", + "signature": "slice __tact_verify_address(slice address)", + }, + { + "code": { + "code": "slice raw = cs~load_msg_addr(); +return (cs, __tact_verify_address(raw));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_load_address", + "signature": "(slice, slice) __tact_load_address(slice cs)", + }, + { + "code": { + "code": "if (cs.preload_uint(2) != 0) { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); +} else { + cs~skip_bits(2); + return (cs, null()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_load_address_opt", + "signature": "(slice, slice) __tact_load_address_opt(slice cs)", + }, + { + "code": { + "code": "return b.store_slice(__tact_verify_address(address));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_store_address", + "signature": "builder __tact_store_address(builder b, slice address)", + }, + { + "code": { + "code": "if (null?(address)) { + b = b.store_uint(0, 2); + return b; +} else { + return __tact_store_address(b, address); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_store_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_store_address_opt", + "signature": "builder __tact_store_address_opt(builder b, slice address)", + }, + { + "code": { + "code": "var b = begin_cell(); +b = b.store_uint(2, 2); +b = b.store_uint(0, 1); +b = b.store_int(chain, 8); +b = b.store_uint(hash, 256); +var addr = b.end_cell().begin_parse(); +return __tact_verify_address(addr);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_verify_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_create_address", + "signature": "slice __tact_create_address(int chain, int hash)", + }, + { + "code": { + "code": "var b = begin_cell(); +b = b.store_uint(0, 2); +b = b.store_uint(3, 2); +b = b.store_uint(0, 1); +b = b.store_ref(code); +b = b.store_ref(data); +var hash = cell_hash(b.end_cell()); +return __tact_create_address(chain, hash);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_create_address", + }, + "flags": Set { + "inline", + }, + "name": "__tact_compute_contract_address", + "signature": "slice __tact_compute_contract_address(int chain, cell code, cell data)", + }, + { + "code": { + "code": "throw_if(128, null?(x)); return x;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + "inline", + }, + "name": "__tact_not_null", + "signature": "forall X -> X __tact_not_null(X x)", + }, + { + "code": { + "code": "DICTDEL", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete", + "signature": "(cell, int) __tact_dict_delete(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTIDEL", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete_int", + "signature": "(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index)", + }, + { + "code": { + "code": "DICTUDEL", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete_uint", + "signature": "(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index)", + }, + { + "code": { + "code": "DICTSETREF", + "kind": "asm", + "shuffle": "(value index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_set_ref", + "signature": "((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value)", + }, + { + "code": { + "code": "DICTGET NULLSWAPIFNOT", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_get", + "signature": "(slice, int) __tact_dict_get(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTDELGET NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_delete_get", + "signature": "(cell, (slice, int)) __tact_dict_delete_get(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTGETREF NULLSWAPIFNOT", + "kind": "asm", + "shuffle": "(index dict key_len)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_get_ref", + "signature": "(cell, int) __tact_dict_get_ref(cell dict, int key_len, slice index)", + }, + { + "code": { + "code": "DICTMIN NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(dict key_len -> 1 0 2)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_min", + "signature": "(slice, slice, int) __tact_dict_min(cell dict, int key_len)", + }, + { + "code": { + "code": "DICTMINREF NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(dict key_len -> 1 0 2)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_min_ref", + "signature": "(slice, cell, int) __tact_dict_min_ref(cell dict, int key_len)", + }, + { + "code": { + "code": "DICTGETNEXT NULLSWAPIFNOT2", + "kind": "asm", + "shuffle": "(pivot dict key_len -> 1 0 2)", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_dict_next", + "signature": "(slice, slice, int) __tact_dict_next(cell dict, int key_len, slice pivot)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(dict, key_len, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set {}, + "name": "__tact_dict_next_ref", + "signature": "(slice, cell, int) __tact_dict_next_ref(cell dict, int key_len, slice pivot)", + }, + { + "code": { + "code": "STRDUMP DROP STRDUMP DROP s0 DUMP DROP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + }, + "name": "__tact_debug", + "signature": "forall X -> () __tact_debug(X value, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "STRDUMP DROP STRDUMP DROP STRDUMP DROP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + }, + "name": "__tact_debug_str", + "signature": "() __tact_debug_str(slice value, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "if (value) { + __tact_debug_str("true", debug_print_1, debug_print_2); +} else { + __tact_debug_str("false", debug_print_1, debug_print_2); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_debug_str", + }, + "flags": Set { + "impure", + }, + "name": "__tact_debug_bool", + "signature": "() __tact_debug_bool(int value, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "SDSUBSTR", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_preload_offset", + "signature": "(slice) __tact_preload_offset(slice s, int offset, int bits)", + }, + { + "code": { + "code": "slice new_data = begin_cell() + .store_slice(data) + .store_slice("0000"s) +.end_cell().begin_parse(); +int reg = 0; +while (~ new_data.slice_data_empty?()) { + int byte = new_data~load_uint(8); + int mask = 0x80; + while (mask > 0) { + reg <<= 1; + if (byte & mask) { + reg += 1; + } + mask >>= 1; + if (reg > 0xffff) { + reg &= 0xffff; + reg ^= 0x1021; + } + } +} +(int q, int r) = divmod(reg, 256); +return begin_cell() + .store_uint(q, 8) + .store_uint(r, 8) +.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline_ref", + }, + "name": "__tact_crc16", + "signature": "(slice) __tact_crc16(slice data)", + }, + { + "code": { + "code": "slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; +builder res = begin_cell(); + +while (data.slice_bits() >= 24) { + (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); + + int n = (bs1 << 16) | (bs2 << 8) | bs3; + + res = res + .store_slice(__tact_preload_offset(chars, ((n >> 18) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 12) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 6) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n ) & 63) * 8, 8)); +} + +return res.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_preload_offset", + }, + "flags": Set {}, + "name": "__tact_base64_encode", + "signature": "(slice) __tact_base64_encode(slice data)", + }, + { + "code": { + "code": "(int wc, int hash) = address.parse_std_addr(); + +slice user_friendly_address = begin_cell() + .store_slice("11"s) + .store_uint((wc + 0x100) % 0x100, 8) + .store_uint(hash, 256) +.end_cell().begin_parse(); + +slice checksum = __tact_crc16(user_friendly_address); +slice user_friendly_address_with_checksum = begin_cell() + .store_slice(user_friendly_address) + .store_slice(checksum) +.end_cell().begin_parse(); + +return __tact_base64_encode(user_friendly_address_with_checksum);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_crc16", + "__tact_base64_encode", + }, + "flags": Set {}, + "name": "__tact_address_to_user_friendly", + "signature": "(slice) __tact_address_to_user_friendly(slice address)", + }, + { + "code": { + "code": "__tact_debug_str(__tact_address_to_user_friendly(address), debug_print_1, debug_print_2);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_debug_str", + "__tact_address_to_user_friendly", + }, + "flags": Set { + "impure", + }, + "name": "__tact_debug_address", + "signature": "() __tact_debug_address(slice address, slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "STRDUMP DROP STRDUMP DROP DUMPSTK", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + }, + "name": "__tact_debug_stack", + "signature": "() __tact_debug_stack(slice debug_print_1, slice debug_print_2)", + }, + { + "code": { + "code": "return __tact_context;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_context_get", + "signature": "(int, slice, int, slice) __tact_context_get()", + }, + { + "code": { + "code": "return __tact_context_sender;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_context_get_sender", + "signature": "slice __tact_context_get_sender()", + }, + { + "code": { + "code": "if (null?(__tact_randomized)) { + randomize_lt(); + __tact_randomized = true; +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "impure", + "inline", + }, + "name": "__tact_prepare_random", + "signature": "() __tact_prepare_random()", + }, + { + "code": { + "code": "return b.store_int(v, 1);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_store_bool", + "signature": "builder __tact_store_bool(builder b, int v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_to_tuple", + "signature": "forall X -> tuple __tact_to_tuple(X x)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_from_tuple", + "signature": "forall X -> X __tact_from_tuple(tuple x)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_int", + "signature": "(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +if (ok) { + return r~load_int(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_int", + "signature": "int __tact_dict_get_int_int(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min?(d, kl); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_int", + "signature": "(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_int", + "signature": "(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_uint", + "signature": "(cell, ()) __tact_dict_set_int_uint(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +if (ok) { + return r~load_uint(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_uint", + "signature": "int __tact_dict_get_int_uint(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min?(d, kl); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_uint", + "signature": "(int, int, int) __tact_dict_min_int_uint(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_uint", + "signature": "(int, int, int) __tact_dict_next_int_uint(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_int", + "signature": "(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +if (ok) { + return r~load_int(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_int", + "signature": "int __tact_dict_get_uint_int(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min?(d, kl); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_int", + "signature": "(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_int", + "signature": "(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_uint", + "signature": "(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +if (ok) { + return r~load_uint(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_uint", + "signature": "int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min?(d, kl); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_uint", + "signature": "(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_uint", + "signature": "(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set_ref(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_cell", + "signature": "(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v)", + }, + { + "code": { + "code": "var (r, ok) = idict_get_ref?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_cell", + "signature": "cell __tact_dict_get_int_cell(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min_ref?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_cell", + "signature": "(int, cell, int) __tact_dict_min_int_cell(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_cell", + "signature": "(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set_ref(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_cell", + "signature": "(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v)", + }, + { + "code": { + "code": "var (r, ok) = udict_get_ref?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_cell", + "signature": "cell __tact_dict_get_uint_cell(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min_ref?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_cell", + "signature": "(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_cell", + "signature": "(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); +} else { + return (idict_set(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_int_slice", + "signature": "(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_int_slice", + "signature": "slice __tact_dict_get_int_slice(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_min?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_int_slice", + "signature": "(int, slice, int) __tact_dict_min_int_slice(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = idict_get_next?(d, kl, pivot); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_int_slice", + "signature": "(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); +} else { + return (udict_set(d, kl, k, v), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_uint_slice", + "signature": "(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_uint_slice", + "signature": "slice __tact_dict_get_uint_slice(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_min?(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_uint_slice", + "signature": "(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = udict_get_next?(d, kl, pivot); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_uint_slice", + "signature": "(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_int", + "signature": "(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +if (ok) { + return r~load_int(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_int", + "signature": "int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min(d, kl); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_int", + "signature": "(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(d, kl, pivot); +if (flag) { + return (key, value~load_int(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_int", + "signature": "(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_uint", + "signature": "(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +if (ok) { + return r~load_uint(vl); +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_uint", + "signature": "int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min(d, kl); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_uint", + "signature": "(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(d, kl, pivot); +if (flag) { + return (key, value~load_uint(vl), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_uint", + "signature": "(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return __tact_dict_set_ref(d, kl, k, v); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + "__tact_dict_set_ref", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_cell", + "signature": "(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get_ref(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get_ref", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_cell", + "signature": "cell __tact_dict_get_slice_cell(cell d, int kl, slice k)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min_ref(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min_ref", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_cell", + "signature": "(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_next(d, kl, pivot); +if (flag) { + return (key, value~load_ref(), flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_cell", + "signature": "(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot)", + }, + { + "code": { + "code": "if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); +} else { + return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_delete", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_slice_slice", + "signature": "(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +if (ok) { + return r; +} else { + return null(); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_slice_slice", + "signature": "slice __tact_dict_get_slice_slice(cell d, int kl, slice k)", + }, + { + "code": { + "code": "var (key, value, flag) = __tact_dict_min(d, kl); +if (flag) { + return (key, value, flag); +} else { + return (null(), null(), flag); +}", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_min_slice_slice", + "signature": "(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl)", + }, + { + "code": { + "code": "return __tact_dict_next(d, kl, pivot);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_next_slice_slice", + "signature": "(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot)", + }, + { + "code": { + "code": "return equal_slices_bits(a, b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_bits", + "signature": "int __tact_slice_eq_bits(slice a, slice b)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (equal_slices_bits(a, b));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_bits_nullable_one", + "signature": "int __tact_slice_eq_bits_nullable_one(slice a, slice b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( equal_slices_bits(a, b) ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_bits_nullable", + "signature": "int __tact_slice_eq_bits_nullable(slice a, slice b)", + }, + { + "code": { + "code": "(slice key, slice value, int flag) = __tact_dict_min(a, kl); +while (flag) { + (slice value_b, int flag_b) = b~__tact_dict_delete_get(kl, key); + ifnot (flag_b) { + return 0; + } + ifnot (value.slice_hash() == value_b.slice_hash()) { + return 0; + } + (key, value, flag) = __tact_dict_next(a, kl, key); +} +return null?(b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_min", + "__tact_dict_delete_get", + "__tact_dict_next", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_eq", + "signature": "int __tact_dict_eq(cell a, cell b, int kl)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (a == b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_eq_nullable_one", + "signature": "int __tact_int_eq_nullable_one(int a, int b)", + }, + { + "code": { + "code": "return (null?(a)) ? (true) : (a != b);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_neq_nullable_one", + "signature": "int __tact_int_neq_nullable_one(int a, int b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a == b ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_eq_nullable", + "signature": "int __tact_int_eq_nullable(int a, int b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a != b ) : ( true ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_int_neq_nullable", + "signature": "int __tact_int_neq_nullable(int a, int b)", + }, + { + "code": { + "code": "return (a.cell_hash() == b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_eq", + "signature": "int __tact_cell_eq(cell a, cell b)", + }, + { + "code": { + "code": "return (a.cell_hash() != b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_neq", + "signature": "int __tact_cell_neq(cell a, cell b)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_eq_nullable_one", + "signature": "int __tact_cell_eq_nullable_one(cell a, cell b)", + }, + { + "code": { + "code": "return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_neq_nullable_one", + "signature": "int __tact_cell_neq_nullable_one(cell a, cell b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() == b.cell_hash() ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_eq_nullable", + "signature": "int __tact_cell_eq_nullable(cell a, cell b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() != b.cell_hash() ) : ( true ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_cell_neq_nullable", + "signature": "int __tact_cell_neq_nullable(cell a, cell b)", + }, + { + "code": { + "code": "return (a.slice_hash() == b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq", + "signature": "int __tact_slice_eq(slice a, slice b)", + }, + { + "code": { + "code": "return (a.slice_hash() != b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_neq", + "signature": "int __tact_slice_neq(slice a, slice b)", + }, + { + "code": { + "code": "return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_nullable_one", + "signature": "int __tact_slice_eq_nullable_one(slice a, slice b)", + }, + { + "code": { + "code": "return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_neq_nullable_one", + "signature": "int __tact_slice_neq_nullable_one(slice a, slice b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() == b.slice_hash() ) : ( false ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_eq_nullable", + "signature": "int __tact_slice_eq_nullable(slice a, slice b)", + }, + { + "code": { + "code": "var a_is_null = null?(a); +var b_is_null = null?(b); +return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() != b.slice_hash() ) : ( true ) );", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_slice_neq_nullable", + "signature": "int __tact_slice_neq_nullable(slice a, slice b)", + }, + { + "code": { + "code": "return udict_set_ref(dict, 16, id, code);", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_set_code", + "signature": "cell __tact_dict_set_code(cell dict, int id, cell code)", + }, + { + "code": { + "code": "var (data, ok) = udict_get_ref?(dict, 16, id); +throw_unless(135, ok); +return data;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_get_code", + "signature": "cell __tact_dict_get_code(cell dict, int id)", + }, + { + "code": { + "code": "NIL", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_0", + "signature": "tuple __tact_tuple_create_0()", + }, + { + "code": { + "code": "return ();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_tuple_destroy_0", + "signature": "() __tact_tuple_destroy_0()", + }, + { + "code": { + "code": "1 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_1", + "signature": "forall X0 -> tuple __tact_tuple_create_1((X0) v)", + }, + { + "code": { + "code": "1 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_1", + "signature": "forall X0 -> (X0) __tact_tuple_destroy_1(tuple v)", + }, + { + "code": { + "code": "2 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_2", + "signature": "forall X0, X1 -> tuple __tact_tuple_create_2((X0, X1) v)", + }, + { + "code": { + "code": "2 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_2", + "signature": "forall X0, X1 -> (X0, X1) __tact_tuple_destroy_2(tuple v)", + }, + { + "code": { + "code": "3 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_3", + "signature": "forall X0, X1, X2 -> tuple __tact_tuple_create_3((X0, X1, X2) v)", + }, + { + "code": { + "code": "3 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_3", + "signature": "forall X0, X1, X2 -> (X0, X1, X2) __tact_tuple_destroy_3(tuple v)", + }, + { + "code": { + "code": "4 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_4", + "signature": "forall X0, X1, X2, X3 -> tuple __tact_tuple_create_4((X0, X1, X2, X3) v)", + }, + { + "code": { + "code": "4 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_4", + "signature": "forall X0, X1, X2, X3 -> (X0, X1, X2, X3) __tact_tuple_destroy_4(tuple v)", + }, + { + "code": { + "code": "5 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_5", + "signature": "forall X0, X1, X2, X3, X4 -> tuple __tact_tuple_create_5((X0, X1, X2, X3, X4) v)", + }, + { + "code": { + "code": "5 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_5", + "signature": "forall X0, X1, X2, X3, X4 -> (X0, X1, X2, X3, X4) __tact_tuple_destroy_5(tuple v)", + }, + { + "code": { + "code": "6 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_6", + "signature": "forall X0, X1, X2, X3, X4, X5 -> tuple __tact_tuple_create_6((X0, X1, X2, X3, X4, X5) v)", + }, + { + "code": { + "code": "6 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_6", + "signature": "forall X0, X1, X2, X3, X4, X5 -> (X0, X1, X2, X3, X4, X5) __tact_tuple_destroy_6(tuple v)", + }, + { + "code": { + "code": "7 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_7", + "signature": "forall X0, X1, X2, X3, X4, X5, X6 -> tuple __tact_tuple_create_7((X0, X1, X2, X3, X4, X5, X6) v)", + }, + { + "code": { + "code": "7 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_7", + "signature": "forall X0, X1, X2, X3, X4, X5, X6 -> (X0, X1, X2, X3, X4, X5, X6) __tact_tuple_destroy_7(tuple v)", + }, + { + "code": { + "code": "8 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_8", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7 -> tuple __tact_tuple_create_8((X0, X1, X2, X3, X4, X5, X6, X7) v)", + }, + { + "code": { + "code": "8 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_8", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7 -> (X0, X1, X2, X3, X4, X5, X6, X7) __tact_tuple_destroy_8(tuple v)", + }, + { + "code": { + "code": "9 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_9", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8 -> tuple __tact_tuple_create_9((X0, X1, X2, X3, X4, X5, X6, X7, X8) v)", + }, + { + "code": { + "code": "9 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_9", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8) __tact_tuple_destroy_9(tuple v)", + }, + { + "code": { + "code": "10 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_10", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9 -> tuple __tact_tuple_create_10((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) v)", + }, + { + "code": { + "code": "10 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_10", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9) __tact_tuple_destroy_10(tuple v)", + }, + { + "code": { + "code": "11 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_11", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10 -> tuple __tact_tuple_create_11((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) v)", + }, + { + "code": { + "code": "11 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_11", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10) __tact_tuple_destroy_11(tuple v)", + }, + { + "code": { + "code": "12 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_12", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11 -> tuple __tact_tuple_create_12((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) v)", + }, + { + "code": { + "code": "12 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_12", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11) __tact_tuple_destroy_12(tuple v)", + }, + { + "code": { + "code": "13 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_13", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12 -> tuple __tact_tuple_create_13((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) v)", + }, + { + "code": { + "code": "13 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_13", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12) __tact_tuple_destroy_13(tuple v)", + }, + { + "code": { + "code": "14 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_14", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13 -> tuple __tact_tuple_create_14((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) v)", + }, + { + "code": { + "code": "14 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_14", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13) __tact_tuple_destroy_14(tuple v)", + }, + { + "code": { + "code": "15 TUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_create_15", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14 -> tuple __tact_tuple_create_15((X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) v)", + }, + { + "code": { + "code": "15 UNTUPLE", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_tuple_destroy_15", + "signature": "forall X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14 -> (X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14) __tact_tuple_destroy_15(tuple v)", + }, + { + "code": { + "code": "return tpush(tpush(empty_tuple(), b), null());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start", + "signature": "tuple __tact_string_builder_start(builder b)", + }, + { + "code": { + "code": "return __tact_string_builder_start(begin_cell().store_uint(0, 32));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_start", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start_comment", + "signature": "tuple __tact_string_builder_start_comment()", + }, + { + "code": { + "code": "return __tact_string_builder_start(begin_cell().store_uint(0, 8));", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_start", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start_tail_string", + "signature": "tuple __tact_string_builder_start_tail_string()", + }, + { + "code": { + "code": "return __tact_string_builder_start(begin_cell());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_start", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_start_string", + "signature": "tuple __tact_string_builder_start_string()", + }, + { + "code": { + "code": "(builder b, tuple tail) = uncons(builders); +cell c = b.end_cell(); +while(~ null?(tail)) { + (b, tail) = uncons(tail); + c = b.store_ref(c).end_cell(); +} +return c;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_end", + "signature": "cell __tact_string_builder_end(tuple builders)", + }, + { + "code": { + "code": "return __tact_string_builder_end(builders).begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_end", + }, + "flags": Set { + "inline", + }, + "name": "__tact_string_builder_end_slice", + "signature": "slice __tact_string_builder_end_slice(tuple builders)", + }, + { + "code": { + "code": "int sliceRefs = slice_refs(sc); +int sliceBits = slice_bits(sc); + +while((sliceBits > 0) | (sliceRefs > 0)) { + + ;; Load the current builder + (builder b, tuple tail) = uncons(builders); + int remBytes = 127 - (builder_bits(b) / 8); + int exBytes = sliceBits / 8; + + ;; Append bits + int amount = min(remBytes, exBytes); + if (amount > 0) { + slice read = sc~load_bits(amount * 8); + b = b.store_slice(read); + } + + ;; Update builders + builders = cons(b, tail); + + ;; Check if we need to add a new cell and continue + if (exBytes - amount > 0) { + var bb = begin_cell(); + builders = cons(bb, builders); + sliceBits = (exBytes - amount) * 8; + } elseif (sliceRefs > 0) { + sc = sc~load_ref().begin_parse(); + sliceRefs = slice_refs(sc); + sliceBits = slice_bits(sc); + } else { + sliceBits = 0; + sliceRefs = 0; + } +} + +return ((builders), ());", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_string_builder_append", + "signature": "((tuple), ()) __tact_string_builder_append(tuple builders, slice sc)", + }, + { + "code": { + "code": "builders~__tact_string_builder_append(sc); +return builders;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_string_builder_append", + }, + "flags": Set {}, + "name": "__tact_string_builder_append_not_mut", + "signature": "(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc)", + }, + { + "code": { + "code": "var b = begin_cell(); +if (src < 0) { + b = b.store_uint(45, 8); + src = - src; +} + +if (src < 1000000000000000000000000000000) { + int len = 0; + int value = 0; + int mult = 1; + do { + (src, int res) = src.divmod(10); + value = value + (res + 48) * mult; + mult = mult * 256; + len = len + 1; + } until (src == 0); + + b = b.store_uint(value, len * 8); +} else { + tuple t = empty_tuple(); + int len = 0; + do { + int digit = src % 10; + t~tpush(digit); + len = len + 1; + src = src / 10; + } until (src == 0); + + int c = len - 1; + repeat(len) { + int v = t.at(c); + b = b.store_uint(v + 48, 8); + c = c - 1; + } +} +return b.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_int_to_string", + "signature": "slice __tact_int_to_string(int src)", + }, + { + "code": { + "code": "throw_if(134, (digits <= 0) | (digits > 77)); +builder b = begin_cell(); + +if (src < 0) { + b = b.store_uint(45, 8); + src = - src; +} + +;; Process rem part +int skip = true; +int len = 0; +int rem = 0; +tuple t = empty_tuple(); +repeat(digits) { + (src, rem) = src.divmod(10); + if ( ~ ( skip & ( rem == 0 ) ) ) { + skip = false; + t~tpush(rem + 48); + len = len + 1; + } +} + +;; Process dot +if (~ skip) { + t~tpush(46); + len = len + 1; +} + +;; Main +do { + (src, rem) = src.divmod(10); + t~tpush(rem + 48); + len = len + 1; +} until (src == 0); + +;; Assemble +int c = len - 1; +repeat(len) { + int v = t.at(c); + b = b.store_uint(v, 8); + c = c - 1; +} + +;; Result +return b.end_cell().begin_parse();", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set {}, + "name": "__tact_float_to_string", + "signature": "slice __tact_float_to_string(int src, int digits)", + }, + { + "code": { + "code": "throw_unless(5, num > 0); +throw_unless(5, base > 1); +if (num < base) { + return 0; +} +int result = 0; +while (num >= base) { + num /= base; + result += 1; +} +return result;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_log", + "signature": "int __tact_log(int num, int base)", + }, + { + "code": { + "code": "throw_unless(5, exp >= 0); +int result = 1; +repeat (exp) { + result *= base; +} +return result;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_pow", + "signature": "int __tact_pow(int base, int exp)", + }, + { + "code": { + "code": "var (r, ok) = idict_get?(d, kl, k); +return ok;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_exists_int", + "signature": "int __tact_dict_exists_int(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (r, ok) = udict_get?(d, kl, k); +return ok;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "__tact_dict_exists_uint", + "signature": "int __tact_dict_exists_uint(cell d, int kl, int k)", + }, + { + "code": { + "code": "var (r, ok) = __tact_dict_get(d, kl, k); +return ok;", + "kind": "generic", + }, + "comment": null, + "context": "stdlib", + "depends": Set { + "__tact_dict_get", + }, + "flags": Set { + "inline", + }, + "name": "__tact_dict_exists_slice", + "signature": "int __tact_dict_exists_slice(cell d, int kl, slice k)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +build_0 = build_0.store_ref(v'a); +build_0 = ~ null?(v'b) ? build_0.store_int(true, 1).store_ref(v'b) : build_0.store_int(false, 1); +var build_1 = begin_cell(); +build_1 = ~ null?(v'c) ? build_1.store_int(true, 1).store_ref(begin_cell().store_slice(v'c).end_cell()) : build_1.store_int(false, 1); +build_1 = ~ null?(v'd) ? build_1.store_int(true, 1).store_ref(begin_cell().store_slice(v'd).end_cell()) : build_1.store_int(false, 1); +build_1 = build_1.store_int(v'e, 1); +build_1 = build_1.store_int(v'f, 257); +build_1 = build_1.store_int(v'g, 257); +build_1 = __tact_store_address(build_1, v'h); +build_0 = store_ref(build_0, build_1.end_cell()); +return build_0;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_store_address", + }, + "flags": Set {}, + "name": "$C$_store", + "signature": "builder $C$_store(builder build_0, (cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "return $C$_store(begin_cell(), v).end_cell();", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_store", + }, + "flags": Set { + "inline", + }, + "name": "$C$_store_cell", + "signature": "cell $C$_store_cell((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'a;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_a", + "signature": "_ $A$_get_a((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'b;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_b", + "signature": "_ $A$_get_b((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'c;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_c", + "signature": "_ $A$_get_c((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'd;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_d", + "signature": "_ $A$_get_d((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'e;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_e", + "signature": "_ $A$_get_e((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'f;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_f", + "signature": "_ $A$_get_f((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'g;", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_get_g", + "signature": "_ $A$_get_g((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set {}, + "name": "$A$_tensor_cast", + "signature": "((int, int, int, int, int, int, int)) $A$_tensor_cast((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "throw_if(128, null?(v)); +var (int vvv'a, int vvv'b, int vvv'c, int vvv'd, int vvv'e, int vvv'f, int vvv'g) = __tact_tuple_destroy_7(v); +return (vvv'a, vvv'b, vvv'c, vvv'd, vvv'e, vvv'f, vvv'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_not_null", + "signature": "((int, int, int, int, int, int, int)) $A$_not_null(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_as_optional", + "signature": "tuple $A$_as_optional((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_to_tuple", + "signature": "tuple $A$_to_tuple(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $A$_to_tuple($A$_not_null(v)); ", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_to_tuple", + "$A$_not_null", + }, + "flags": Set { + "inline", + }, + "name": "$A$_to_opt_tuple", + "signature": "tuple $A$_to_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (int v'a, int v'b, int v'c, int v'd, int v'e, int v'f, int v'g) = __tact_tuple_destroy_7(v); +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$A$_from_tuple", + "signature": "(int, int, int, int, int, int, int) $A$_from_tuple(tuple v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $A$_as_optional($A$_from_tuple(v));", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_as_optional", + "$A$_from_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$A$_from_opt_tuple", + "signature": "tuple $A$_from_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$A$_to_external", + "signature": "(int, int, int, int, int, int, int) $A$_to_external(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "var loaded = $A$_to_opt_tuple(v); +if (null?(loaded)) { + return null(); +} else { + return (loaded); +}", + "kind": "generic", + }, + "comment": null, + "context": "type:A", + "depends": Set { + "$A$_to_opt_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$A$_to_opt_external", + "signature": "tuple $A$_to_opt_external(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'a;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_a", + "signature": "_ $B$_get_a((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'b;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_b", + "signature": "_ $B$_get_b((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'c;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_c", + "signature": "_ $B$_get_c((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'd;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_d", + "signature": "_ $B$_get_d((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'e;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_e", + "signature": "_ $B$_get_e((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'f;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_f", + "signature": "_ $B$_get_f((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return v'g;", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_get_g", + "signature": "_ $B$_get_g((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set {}, + "name": "$B$_tensor_cast", + "signature": "((int, int, int, int, int, int, int)) $B$_tensor_cast((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "throw_if(128, null?(v)); +var (int vvv'a, int vvv'b, int vvv'c, int vvv'd, int vvv'e, int vvv'f, int vvv'g) = __tact_tuple_destroy_7(v); +return (vvv'a, vvv'b, vvv'c, vvv'd, vvv'e, vvv'f, vvv'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_not_null", + "signature": "((int, int, int, int, int, int, int)) $B$_not_null(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_as_optional", + "signature": "tuple $B$_as_optional((int, int, int, int, int, int, int) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return __tact_tuple_create_7(v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_create_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_to_tuple", + "signature": "tuple $B$_to_tuple(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $B$_to_tuple($B$_not_null(v)); ", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_to_tuple", + "$B$_not_null", + }, + "flags": Set { + "inline", + }, + "name": "$B$_to_opt_tuple", + "signature": "tuple $B$_to_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (int v'a, int v'b, int v'c, int v'd, int v'e, int v'f, int v'g) = __tact_tuple_destroy_7(v); +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "__tact_tuple_destroy_7", + }, + "flags": Set { + "inline", + }, + "name": "$B$_from_tuple", + "signature": "(int, int, int, int, int, int, int) $B$_from_tuple(tuple v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $B$_as_optional($B$_from_tuple(v));", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_as_optional", + "$B$_from_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$B$_from_opt_tuple", + "signature": "tuple $B$_from_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g) = v; +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g);", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$B$_to_external", + "signature": "(int, int, int, int, int, int, int) $B$_to_external(((int, int, int, int, int, int, int)) v)", + }, + { + "code": { + "code": "var loaded = $B$_to_opt_tuple(v); +if (null?(loaded)) { + return null(); +} else { + return (loaded); +}", + "kind": "generic", + }, + "comment": null, + "context": "type:B", + "depends": Set { + "$B$_to_opt_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$B$_to_opt_external", + "signature": "tuple $B$_to_opt_external(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'a;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_a", + "signature": "_ $C$_get_a((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'b;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_b", + "signature": "_ $C$_get_b((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'c;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_c", + "signature": "_ $C$_get_c((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'd;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_d", + "signature": "_ $C$_get_d((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'e;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_e", + "signature": "_ $C$_get_e((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'f;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_f", + "signature": "_ $C$_get_f((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'g;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_g", + "signature": "_ $C$_get_g((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return v'h;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_get_h", + "signature": "_ $C$_get_h((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "NOP", + "kind": "asm", + "shuffle": "", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set {}, + "name": "$C$_tensor_cast", + "signature": "((cell, cell, slice, slice, int, int, int, slice)) $C$_tensor_cast((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "throw_if(128, null?(v)); +var (cell vvv'a, cell vvv'b, slice vvv'c, slice vvv'd, int vvv'e, int vvv'f, int vvv'g, slice vvv'h) = __tact_tuple_destroy_8(v); +return (vvv'a, vvv'b, vvv'c, vvv'd, vvv'e, vvv'f, vvv'g, vvv'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_tuple_destroy_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_not_null", + "signature": "((cell, cell, slice, slice, int, int, int, slice)) $C$_not_null(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return __tact_tuple_create_8(v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_tuple_create_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_as_optional", + "signature": "tuple $C$_as_optional((cell, cell, slice, slice, int, int, int, slice) v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return __tact_tuple_create_8(v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_tuple_create_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_to_tuple", + "signature": "tuple $C$_to_tuple(((cell, cell, slice, slice, int, int, int, slice)) v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $C$_to_tuple($C$_not_null(v)); ", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_to_tuple", + "$C$_not_null", + }, + "flags": Set { + "inline", + }, + "name": "$C$_to_opt_tuple", + "signature": "tuple $C$_to_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (cell v'a, cell v'b, slice v'c, slice v'd, int v'e, int v'f, int v'g, slice v'h) = __tact_tuple_destroy_8(v); +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g, __tact_verify_address(v'h));", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_verify_address", + "__tact_tuple_destroy_8", + }, + "flags": Set { + "inline", + }, + "name": "$C$_from_tuple", + "signature": "(cell, cell, slice, slice, int, int, int, slice) $C$_from_tuple(tuple v)", + }, + { + "code": { + "code": "if (null?(v)) { return null(); } +return $C$_as_optional($C$_from_tuple(v));", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_as_optional", + "$C$_from_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$C$_from_opt_tuple", + "signature": "tuple $C$_from_opt_tuple(tuple v)", + }, + { + "code": { + "code": "var (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h) = v; +return (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h);", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set {}, + "flags": Set { + "inline", + }, + "name": "$C$_to_external", + "signature": "(cell, cell, slice, slice, int, int, int, slice) $C$_to_external(((cell, cell, slice, slice, int, int, int, slice)) v)", + }, + { + "code": { + "code": "var loaded = $C$_to_opt_tuple(v); +if (null?(loaded)) { + return null(); +} else { + return (loaded); +}", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_to_opt_tuple", + }, + "flags": Set { + "inline", + }, + "name": "$C$_to_opt_external", + "signature": "tuple $C$_to_opt_external(tuple v)", + }, + { + "code": { + "code": "var v'a = sc_0~load_ref(); +var v'b = sc_0~load_int(1) ? sc_0~load_ref() : null(); +slice sc_1 = sc_0~load_ref().begin_parse(); +var v'c = sc_1~load_int(1) ? sc_1~load_ref().begin_parse() : null(); +var v'd = sc_1~load_int(1) ? sc_1~load_ref().begin_parse() : null(); +var v'e = sc_1~load_int(1); +var v'f = sc_1~load_int(257); +var v'g = sc_1~load_int(257); +var v'h = sc_1~__tact_load_address(); +return (sc_0, (v'a, v'b, v'c, v'd, v'e, v'f, v'g, v'h));", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "__tact_load_address", + }, + "flags": Set {}, + "name": "$C$_load", + "signature": "(slice, ((cell, cell, slice, slice, int, int, int, slice))) $C$_load(slice sc_0)", + }, + { + "code": { + "code": "var r = sc_0~$C$_load(); +sc_0.end_parse(); +return r;", + "kind": "generic", + }, + "comment": null, + "context": "type:C", + "depends": Set { + "$C$_load", + }, + "flags": Set {}, + "name": "$C$_load_not_mut", + "signature": "((cell, cell, slice, slice, int, int, int, slice)) $C$_load_not_mut(slice sc_0)", + }, +] +`; diff --git a/src/generatorNew/writers/cast.ts b/src/generatorNew/writers/cast.ts new file mode 100644 index 000000000..4c098e455 --- /dev/null +++ b/src/generatorNew/writers/cast.ts @@ -0,0 +1,24 @@ +import { getType } from "../../types/resolveDescriptors"; +import { TypeRef } from "../../types/types"; +import { WriterContext } from "../Writer"; +import { ops } from "./ops"; + +export function cast( + from: TypeRef, + to: TypeRef, + expression: string, + ctx: WriterContext, +) { + if (from.kind === "ref" && to.kind === "ref") { + if (from.name !== to.name) { + throw Error("Impossible"); + } + if (!from.optional && to.optional) { + const type = getType(ctx.ctx, from.name); + if (type.kind === "struct") { + return `${ops.typeAsOptional(type.name, ctx)}(${expression})`; + } + } + } + return expression; +} diff --git a/src/generatorNew/writers/freshIdentifier.ts b/src/generatorNew/writers/freshIdentifier.ts new file mode 100644 index 000000000..dcbdafdd7 --- /dev/null +++ b/src/generatorNew/writers/freshIdentifier.ts @@ -0,0 +1,9 @@ +import { funcIdOf } from "./id"; + +let counter = 0; + +export function freshIdentifier(prefix: string): string { + const fresh = `fresh$${prefix}_${counter}`; + counter += 1; + return funcIdOf(fresh); +} diff --git a/src/generatorNew/writers/id.ts b/src/generatorNew/writers/id.ts new file mode 100644 index 000000000..50c55372d --- /dev/null +++ b/src/generatorNew/writers/id.ts @@ -0,0 +1,15 @@ +import { AstId, idText } from "../../grammar/ast"; + +export function funcIdOf(ident: AstId | string): string { + if (typeof ident === "string") { + return "$" + ident; + } + return "$" + idText(ident); +} + +export function funcInitIdOf(ident: AstId | string): string { + if (typeof ident === "string") { + return ident + "$init"; + } + return idText(ident) + "$init"; +} diff --git a/src/generatorNew/writers/ops.ts b/src/generatorNew/writers/ops.ts new file mode 100644 index 000000000..6f4f28865 --- /dev/null +++ b/src/generatorNew/writers/ops.ts @@ -0,0 +1,82 @@ +import { WriterContext } from "../Writer"; + +function used(name: string, ctx: WriterContext) { + const c = ctx.currentContext(); + if (c) { + ctx.used(name); + } + return name; +} + +export const ops = { + // Type operations + writer: (type: string, ctx: WriterContext) => used(`$${type}$_store`, ctx), + writerCell: (type: string, ctx: WriterContext) => + used(`$${type}$_store_cell`, ctx), + writerCellOpt: (type: string, ctx: WriterContext) => + used(`$${type}$_store_opt`, ctx), + reader: (type: string, ctx: WriterContext) => used(`$${type}$_load`, ctx), + readerNonModifying: (type: string, ctx: WriterContext) => + used(`$${type}$_load_not_mut`, ctx), + readerBounced: (type: string, ctx: WriterContext) => + used(`$${type}$_load_bounced`, ctx), + readerOpt: (type: string, ctx: WriterContext) => + used(`$${type}$_load_opt`, ctx), + typeField: (type: string, name: string, ctx: WriterContext) => + used(`$${type}$_get_${name}`, ctx), + typeTensorCast: (type: string, ctx: WriterContext) => + used(`$${type}$_tensor_cast`, ctx), + typeNotNull: (type: string, ctx: WriterContext) => + used(`$${type}$_not_null`, ctx), + typeAsOptional: (type: string, ctx: WriterContext) => + used(`$${type}$_as_optional`, ctx), + typeToTuple: (type: string, ctx: WriterContext) => + used(`$${type}$_to_tuple`, ctx), + typeToOptTuple: (type: string, ctx: WriterContext) => + used(`$${type}$_to_opt_tuple`, ctx), + typeFromTuple: (type: string, ctx: WriterContext) => + used(`$${type}$_from_tuple`, ctx), + typeFromOptTuple: (type: string, ctx: WriterContext) => + used(`$${type}$_from_opt_tuple`, ctx), + typeToExternal: (type: string, ctx: WriterContext) => + used(`$${type}$_to_external`, ctx), + typeToOptExternal: (type: string, ctx: WriterContext) => + used(`$${type}$_to_opt_external`, ctx), + typeConstructor: (type: string, fields: string[], ctx: WriterContext) => + used(`$${type}$_constructor_${fields.join("_")}`, ctx), + + // Contract operations + contractInit: (type: string, ctx: WriterContext) => + used(`$${type}$_contract_init`, ctx), + contractInitChild: (type: string, ctx: WriterContext) => + used(`$${type}$_init_child`, ctx), + contractLoad: (type: string, ctx: WriterContext) => + used(`$${type}$_contract_load`, ctx), + contractStore: (type: string, ctx: WriterContext) => + used(`$${type}$_contract_store`, ctx), + contractRouter: (type: string, kind: "internal" | "external") => + `$${type}$_contract_router_${kind}`, // Not rendered as dependency + + // Router operations + receiveEmpty: (type: string, kind: "internal" | "external") => + `%$${type}$_${kind}_empty`, + receiveType: (type: string, kind: "internal" | "external", msg: string) => + `$${type}$_${kind}_binary_${msg}`, + receiveAnyText: (type: string, kind: "internal" | "external") => + `$${type}$_${kind}_any_text`, + receiveText: (type: string, kind: "internal" | "external", hash: string) => + `$${type}$_${kind}_text_${hash}`, + receiveAny: (type: string, kind: "internal" | "external") => + `$${type}$_${kind}_any`, + receiveTypeBounce: (type: string, msg: string) => + `$${type}$_receive_binary_bounce_${msg}`, + receiveBounceAny: (type: string) => `$${type}$_receive_bounce`, + + // Functions + extension: (type: string, name: string) => `$${type}$_fun_${name}`, + global: (name: string) => `$global_${name}`, + nonModifying: (name: string) => `${name}$not_mut`, + + // Constants + str: (id: string, ctx: WriterContext) => used(`__gen_str_${id}`, ctx), +}; diff --git a/src/generatorNew/writers/resolveFuncFlatPack.ts b/src/generatorNew/writers/resolveFuncFlatPack.ts new file mode 100644 index 000000000..f0480bc5a --- /dev/null +++ b/src/generatorNew/writers/resolveFuncFlatPack.ts @@ -0,0 +1,58 @@ +import { getType } from "../../types/resolveDescriptors"; +import { TypeDescription, TypeRef } from "../../types/types"; +import { WriterContext } from "../Writer"; + +export function resolveFuncFlatPack( + descriptor: TypeRef | TypeDescription | string, + name: string, + ctx: WriterContext, + optional: boolean = false, +): string[] { + // String + if (typeof descriptor === "string") { + return resolveFuncFlatPack(getType(ctx.ctx, descriptor), name, ctx); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncFlatPack( + getType(ctx.ctx, descriptor.name), + name, + ctx, + descriptor.optional, + ); + } + if (descriptor.kind === "map") { + return [name]; + } + if (descriptor.kind === "ref_bounced") { + throw Error("Unimplemented"); + } + if (descriptor.kind === "void") { + throw Error("Void type is not allowed in function arguments: " + name); + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + return [name]; + } else if (descriptor.kind === "struct") { + if (optional || descriptor.fields.length === 0) { + return [name]; + } else { + return descriptor.fields.flatMap((v) => + resolveFuncFlatPack(v.type, name + `'` + v.name, ctx), + ); + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return [name]; + } else { + return descriptor.fields.flatMap((v) => + resolveFuncFlatPack(v.type, name + `'` + v.name, ctx), + ); + } + } + + // Unreachable + throw Error("Unknown type: " + descriptor.kind); +} diff --git a/src/generatorNew/writers/resolveFuncFlatTypes.ts b/src/generatorNew/writers/resolveFuncFlatTypes.ts new file mode 100644 index 000000000..2f829a2ba --- /dev/null +++ b/src/generatorNew/writers/resolveFuncFlatTypes.ts @@ -0,0 +1,57 @@ +import { getType } from "../../types/resolveDescriptors"; +import { TypeDescription, TypeRef } from "../../types/types"; +import { WriterContext } from "../Writer"; +import { resolveFuncType } from "./resolveFuncType"; + +export function resolveFuncFlatTypes( + descriptor: TypeRef | TypeDescription | string, + ctx: WriterContext, + optional: boolean = false, +): string[] { + // String + if (typeof descriptor === "string") { + return resolveFuncFlatTypes(getType(ctx.ctx, descriptor), ctx); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncFlatTypes( + getType(ctx.ctx, descriptor.name), + ctx, + descriptor.optional, + ); + } + if (descriptor.kind === "map") { + return ["cell"]; + } + if (descriptor.kind === "ref_bounced") { + throw Error("Unimplemented"); + } + if (descriptor.kind === "void") { + throw Error("Void type is not allowed in function arguments"); + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + return [resolveFuncType(descriptor, ctx)]; + } else if (descriptor.kind === "struct") { + if (optional || descriptor.fields.length === 0) { + return ["tuple"]; + } else { + return descriptor.fields.flatMap((v) => + resolveFuncFlatTypes(v.type, ctx), + ); + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return ["tuple"]; + } else { + return descriptor.fields.flatMap((v) => + resolveFuncFlatTypes(v.type, ctx), + ); + } + } + + // Unreachable + throw Error("Unknown type: " + descriptor.kind); +} diff --git a/src/codegen/primitive.ts b/src/generatorNew/writers/resolveFuncPrimitive.ts similarity index 74% rename from src/codegen/primitive.ts rename to src/generatorNew/writers/resolveFuncPrimitive.ts index 4e7c1181d..0d815f358 100644 --- a/src/codegen/primitive.ts +++ b/src/generatorNew/writers/resolveFuncPrimitive.ts @@ -1,19 +1,19 @@ -import { CompilerContext } from "../context"; -import { getType } from "../types/resolveDescriptors"; -import { TypeDescription, TypeRef } from "../types/types"; +import { getType } from "../../types/resolveDescriptors"; +import { TypeDescription, TypeRef } from "../../types/types"; +import { WriterContext } from "../Writer"; export function resolveFuncPrimitive( - ctx: CompilerContext, descriptor: TypeRef | TypeDescription | string, + ctx: WriterContext, ): boolean { // String if (typeof descriptor === "string") { - return resolveFuncPrimitive(ctx, getType(ctx, descriptor)); + return resolveFuncPrimitive(getType(ctx.ctx, descriptor), ctx); } // TypeRef if (descriptor.kind === "ref") { - return resolveFuncPrimitive(ctx, getType(ctx, descriptor.name)); + return resolveFuncPrimitive(getType(ctx.ctx, descriptor.name), ctx); } if (descriptor.kind === "map") { return true; @@ -44,7 +44,7 @@ export function resolveFuncPrimitive( } else if (descriptor.name === "StringBuilder") { return true; } else { - throw Error(`Unknown primitive type: ${descriptor.name}`); + throw Error("Unknown primitive type: " + descriptor.name); } } else if (descriptor.kind === "struct") { return false; @@ -53,5 +53,5 @@ export function resolveFuncPrimitive( } // Unreachable - throw Error(`Unknown type: ${descriptor.kind}`); + throw Error("Unknown type: " + descriptor.kind); } diff --git a/src/generatorNew/writers/resolveFuncTupleType.ts b/src/generatorNew/writers/resolveFuncTupleType.ts new file mode 100644 index 000000000..70483cebc --- /dev/null +++ b/src/generatorNew/writers/resolveFuncTupleType.ts @@ -0,0 +1,55 @@ +import { getType } from "../../types/resolveDescriptors"; +import { TypeDescription, TypeRef } from "../../types/types"; +import { WriterContext } from "../Writer"; + +export function resolveFuncTupleType( + descriptor: TypeRef | TypeDescription | string, + ctx: WriterContext, +): string { + // String + if (typeof descriptor === "string") { + return resolveFuncTupleType(getType(ctx.ctx, descriptor), ctx); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncTupleType(getType(ctx.ctx, descriptor.name), ctx); + } + if (descriptor.kind === "map") { + return "cell"; + } + if (descriptor.kind === "ref_bounced") { + throw Error("Unimplemented"); + } + if (descriptor.kind === "void") { + return "()"; + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + if (descriptor.name === "Int") { + return "int"; + } else if (descriptor.name === "Bool") { + return "int"; + } else if (descriptor.name === "Slice") { + return "slice"; + } else if (descriptor.name === "Cell") { + return "cell"; + } else if (descriptor.name === "Builder") { + return "builder"; + } else if (descriptor.name === "Address") { + return "slice"; + } else if (descriptor.name === "String") { + return "slice"; + } else if (descriptor.name === "StringBuilder") { + return "tuple"; + } else { + throw Error("Unknown primitive type: " + descriptor.name); + } + } else if (descriptor.kind === "struct" || descriptor.kind === "contract") { + return "tuple"; + } + + // Unreachable + throw Error("Unknown type: " + descriptor.kind); +} diff --git a/src/generatorNew/writers/resolveFuncType.spec.ts b/src/generatorNew/writers/resolveFuncType.spec.ts new file mode 100644 index 000000000..362f00667 --- /dev/null +++ b/src/generatorNew/writers/resolveFuncType.spec.ts @@ -0,0 +1,176 @@ +import { __DANGER_resetNodeId } from "../../grammar/ast"; +import { resolveDescriptors } from "../../types/resolveDescriptors"; +import { WriterContext } from "../Writer"; +import { resolveFuncType } from "./resolveFuncType"; +import { openContext } from "../../grammar/store"; +import { CompilerContext } from "../../context"; + +const primitiveCode = ` +primitive Int; +primitive Bool; +primitive Builder; +primitive Cell; +primitive Slice; + +trait BaseTrait { + +} + +struct Struct1 { + a1: Int; + a2: Int; +} + +struct Struct2 { + b1: Int; +} + +contract Contract1 { + c: Int; + c2: Int; + + init() { + + } +} + +contract Contract2 { + d: Int; + e: Struct1; + + init() { + + } +} +`; + +describe("resolveFuncType", () => { + beforeEach(() => { + __DANGER_resetNodeId(); + }); + + it("should process primitive types", () => { + let ctx = openContext( + new CompilerContext(), + [{ code: primitiveCode, path: "", origin: "user" }], + [], + ); + ctx = resolveDescriptors(ctx); + const wCtx = new WriterContext(ctx, "Contract1"); + expect( + resolveFuncType( + { kind: "ref", name: "Int", optional: false }, + wCtx, + ), + ).toBe("int"); + expect( + resolveFuncType( + { kind: "ref", name: "Bool", optional: false }, + wCtx, + ), + ).toBe("int"); + expect( + resolveFuncType( + { kind: "ref", name: "Cell", optional: false }, + wCtx, + ), + ).toBe("cell"); + expect( + resolveFuncType( + { kind: "ref", name: "Slice", optional: false }, + wCtx, + ), + ).toBe("slice"); + expect( + resolveFuncType( + { kind: "ref", name: "Builder", optional: false }, + wCtx, + ), + ).toBe("builder"); + expect( + resolveFuncType({ kind: "ref", name: "Int", optional: true }, wCtx), + ).toBe("int"); + expect( + resolveFuncType( + { kind: "ref", name: "Bool", optional: true }, + wCtx, + ), + ).toBe("int"); + expect( + resolveFuncType( + { kind: "ref", name: "Cell", optional: true }, + wCtx, + ), + ).toBe("cell"); + expect( + resolveFuncType( + { kind: "ref", name: "Slice", optional: true }, + wCtx, + ), + ).toBe("slice"); + expect( + resolveFuncType( + { kind: "ref", name: "Builder", optional: true }, + wCtx, + ), + ).toBe("builder"); + }); + + it("should process contract and struct types", () => { + let ctx = openContext( + new CompilerContext(), + [{ code: primitiveCode, path: "", origin: "user" }], + [], + ); + ctx = resolveDescriptors(ctx); + const wCtx = new WriterContext(ctx, "Contract1"); + expect( + resolveFuncType( + { kind: "ref", name: "Struct1", optional: false }, + wCtx, + ), + ).toBe("(int, int)"); + expect( + resolveFuncType( + { kind: "ref", name: "Struct2", optional: false }, + wCtx, + ), + ).toBe("(int)"); + expect( + resolveFuncType( + { kind: "ref", name: "Contract1", optional: false }, + wCtx, + ), + ).toBe("(int, int)"); + expect( + resolveFuncType( + { kind: "ref", name: "Contract2", optional: false }, + wCtx, + ), + ).toBe("(int, (int, int))"); + expect( + resolveFuncType( + { kind: "ref", name: "Struct1", optional: true }, + wCtx, + ), + ).toBe("tuple"); + expect( + resolveFuncType( + { kind: "ref", name: "Struct2", optional: true }, + wCtx, + ), + ).toBe("tuple"); + expect( + resolveFuncType( + { kind: "ref", name: "Contract1", optional: true }, + wCtx, + ), + ).toBe("tuple"); + expect( + resolveFuncType( + { kind: "ref", name: "Contract2", optional: true }, + wCtx, + ), + ).toBe("tuple"); + }); +}); diff --git a/src/generatorNew/writers/resolveFuncType.ts b/src/generatorNew/writers/resolveFuncType.ts new file mode 100644 index 000000000..a5b920636 --- /dev/null +++ b/src/generatorNew/writers/resolveFuncType.ts @@ -0,0 +1,101 @@ +import { getType } from "../../types/resolveDescriptors"; +import { TypeDescription, TypeRef } from "../../types/types"; +import { WriterContext } from "../Writer"; + +export function resolveFuncType( + descriptor: TypeRef | TypeDescription | string, + ctx: WriterContext, + optional: boolean = false, + usePartialFields: boolean = false, +): string { + // String + if (typeof descriptor === "string") { + return resolveFuncType( + getType(ctx.ctx, descriptor), + ctx, + false, + usePartialFields, + ); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncType( + getType(ctx.ctx, descriptor.name), + ctx, + descriptor.optional, + usePartialFields, + ); + } + if (descriptor.kind === "map") { + return "cell"; + } + if (descriptor.kind === "ref_bounced") { + return resolveFuncType( + getType(ctx.ctx, descriptor.name), + ctx, + false, + true, + ); + } + if (descriptor.kind === "void") { + return "()"; + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + if (descriptor.name === "Int") { + return "int"; + } else if (descriptor.name === "Bool") { + return "int"; + } else if (descriptor.name === "Slice") { + return "slice"; + } else if (descriptor.name === "Cell") { + return "cell"; + } else if (descriptor.name === "Builder") { + return "builder"; + } else if (descriptor.name === "Address") { + return "slice"; + } else if (descriptor.name === "String") { + return "slice"; + } else if (descriptor.name === "StringBuilder") { + return "tuple"; + } else { + throw Error("Unknown primitive type: " + descriptor.name); + } + } else if (descriptor.kind === "struct") { + const fieldsToUse = usePartialFields + ? descriptor.fields.slice(0, descriptor.partialFieldCount) + : descriptor.fields; + if (optional || fieldsToUse.length === 0) { + return "tuple"; + } else { + return ( + "(" + + fieldsToUse + .map((v) => + resolveFuncType(v.type, ctx, false, usePartialFields), + ) + .join(", ") + + ")" + ); + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return "tuple"; + } else { + return ( + "(" + + descriptor.fields + .map((v) => + resolveFuncType(v.type, ctx, false, usePartialFields), + ) + .join(", ") + + ")" + ); + } + } + + // Unreachable + throw Error("Unknown type: " + descriptor.kind); +} diff --git a/src/generatorNew/writers/resolveFuncTypeFromAbi.ts b/src/generatorNew/writers/resolveFuncTypeFromAbi.ts new file mode 100644 index 000000000..c45b7b5da --- /dev/null +++ b/src/generatorNew/writers/resolveFuncTypeFromAbi.ts @@ -0,0 +1,55 @@ +import { ABITypeRef } from "@ton/core"; +import { getType } from "../../types/resolveDescriptors"; +import { WriterContext } from "../Writer"; + +export function resolveFuncTypeFromAbi( + fields: ABITypeRef[], + ctx: WriterContext, +): string { + if (fields.length === 0) { + return "tuple"; + } + const res: string[] = []; + for (const f of fields) { + switch (f.kind) { + case "dict": + { + res.push("cell"); + } + break; + case "simple": { + if ( + f.type === "int" || + f.type === "uint" || + f.type === "bool" + ) { + res.push("int"); + } else if (f.type === "cell") { + res.push("cell"); + } else if (f.type === "slice") { + res.push("slice"); + } else if (f.type === "builder") { + res.push("builder"); + } else if (f.type === "address") { + res.push("slice"); + } else if (f.type === "fixed-bytes") { + res.push("slice"); + } else if (f.type === "string") { + res.push("slice"); + } else { + const t = getType(ctx.ctx, f.type); + if (t.kind !== "struct") { + throw Error("Unsupported type: " + t.kind); + } + if (f.optional ?? t.fields.length === 0) { + res.push("tuple"); + } else { + const loaded = t.fields.map((v) => v.abi.type); + res.push(resolveFuncTypeFromAbi(loaded, ctx)); + } + } + } + } + } + return `(${res.join(", ")})`; +} diff --git a/src/generatorNew/writers/resolveFuncTypeFromAbiUnpack.ts b/src/generatorNew/writers/resolveFuncTypeFromAbiUnpack.ts new file mode 100644 index 000000000..4652570d7 --- /dev/null +++ b/src/generatorNew/writers/resolveFuncTypeFromAbiUnpack.ts @@ -0,0 +1,61 @@ +import { ABITypeRef } from "@ton/core"; +import { getType } from "../../types/resolveDescriptors"; +import { WriterContext } from "../Writer"; + +export function resolveFuncTypeFromAbiUnpack( + name: string, + fields: { name: string; type: ABITypeRef }[], + ctx: WriterContext, +): string { + if (fields.length === 0) { + return name; + } + const res: string[] = []; + for (const f of fields) { + switch (f.type.kind) { + case "dict": + { + res.push(`${name}'${f.name}`); + } + break; + case "simple": + { + if ( + f.type.type === "int" || + f.type.type === "uint" || + f.type.type === "bool" + ) { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "cell") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "slice") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "builder") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "address") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "fixed-bytes") { + res.push(`${name}'${f.name}`); + } else if (f.type.type === "string") { + res.push(`${name}'${f.name}`); + } else { + const t = getType(ctx.ctx, f.type.type); + if (f.type.optional ?? t.fields.length === 0) { + res.push(`${name}'${f.name}`); + } else { + const loaded = t.fields.map((v) => v.abi); + res.push( + resolveFuncTypeFromAbiUnpack( + `${name}'${f.name}`, + loaded, + ctx, + ), + ); + } + } + } + break; + } + } + return `(${res.join(", ")})`; +} diff --git a/src/generatorNew/writers/resolveFuncTypeUnpack.ts b/src/generatorNew/writers/resolveFuncTypeUnpack.ts new file mode 100644 index 000000000..dd088d8b0 --- /dev/null +++ b/src/generatorNew/writers/resolveFuncTypeUnpack.ts @@ -0,0 +1,99 @@ +import { getType } from "../../types/resolveDescriptors"; +import { TypeDescription, TypeRef } from "../../types/types"; +import { WriterContext } from "../Writer"; + +export function resolveFuncTypeUnpack( + descriptor: TypeRef | TypeDescription | string, + name: string, + ctx: WriterContext, + optional: boolean = false, + usePartialFields: boolean = false, +): string { + // String + if (typeof descriptor === "string") { + return resolveFuncTypeUnpack( + getType(ctx.ctx, descriptor), + name, + ctx, + false, + usePartialFields, + ); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncTypeUnpack( + getType(ctx.ctx, descriptor.name), + name, + ctx, + descriptor.optional, + usePartialFields, + ); + } + if (descriptor.kind === "map") { + return name; + } + if (descriptor.kind === "ref_bounced") { + return resolveFuncTypeUnpack( + getType(ctx.ctx, descriptor.name), + name, + ctx, + false, + true, + ); + } + if (descriptor.kind === "void") { + throw Error("Void type is not allowed in function arguments: " + name); + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + return name; + } else if (descriptor.kind === "struct") { + const fieldsToUse = usePartialFields + ? descriptor.fields.slice(0, descriptor.partialFieldCount) + : descriptor.fields; + if (optional || fieldsToUse.length === 0) { + return name; + } else { + return ( + "(" + + fieldsToUse + .map((v) => + resolveFuncTypeUnpack( + v.type, + name + `'` + v.name, + ctx, + false, + usePartialFields, + ), + ) + .join(", ") + + ")" + ); + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return name; + } else { + return ( + "(" + + descriptor.fields + .map((v) => + resolveFuncTypeUnpack( + v.type, + name + `'` + v.name, + ctx, + false, + usePartialFields, + ), + ) + .join(", ") + + ")" + ); + } + } + + // Unreachable + throw Error("Unknown type: " + descriptor.kind); +} diff --git a/src/generatorNew/writers/writeAccessors.ts b/src/generatorNew/writers/writeAccessors.ts new file mode 100644 index 000000000..df210313c --- /dev/null +++ b/src/generatorNew/writers/writeAccessors.ts @@ -0,0 +1,318 @@ +import { contractErrors } from "../../abi/errors"; +import { maxTupleSize } from "../../bindings/typescript/writeStruct"; +import { ItemOrigin } from "../../grammar/grammar"; +import { getType } from "../../types/resolveDescriptors"; +import { TypeDescription } from "../../types/types"; +import { WriterContext } from "../Writer"; +import { ops } from "./ops"; +import { resolveFuncFlatPack } from "./resolveFuncFlatPack"; +import { resolveFuncFlatTypes } from "./resolveFuncFlatTypes"; +import { resolveFuncType } from "./resolveFuncType"; +import { resolveFuncTypeUnpack } from "./resolveFuncTypeUnpack"; + +function chainVars(vars: string[]): string[] { + // let's say we have vars = ['v1', 'v2, ..., 'v32'] + // we need to split it into chunks of size maxTupleSize - 1 + const chunks: string[][] = []; + while (vars.length > 0) { + chunks.push(vars.splice(0, maxTupleSize - 1)); + } + // and now chain them into a string like this: [v1, v2, ..., v14, [v15, v16, ..., v28, [v29, v30, ..., v32]] + while (chunks.length > 1) { + const a = chunks.pop()!; + chunks[chunks.length - 1]!.push(`[${a.join(", ")}]`); + } + return chunks[0]!; +} + +export function writeAccessors( + type: TypeDescription, + origin: ItemOrigin, + ctx: WriterContext, +) { + // Getters + for (const f of type.fields) { + ctx.fun(ops.typeField(type.name, f.name, ctx), () => { + ctx.signature( + `_ ${ops.typeField(type.name, f.name, ctx)}(${resolveFuncType(type, ctx)} v)`, + ); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + ctx.append( + `var (${type.fields.map((v) => `v'${v.name}`).join(", ")}) = v;`, + ); + ctx.append(`return v'${f.name};`); + }); + }); + } + + // Tensor cast + ctx.fun(ops.typeTensorCast(type.name, ctx), () => { + ctx.signature( + `(${resolveFuncType(type, ctx)}) ${ops.typeTensorCast(type.name, ctx)}(${resolveFuncType(type, ctx)} v)`, + ); + ctx.context("type:" + type.name); + ctx.asm("", "NOP"); + }); + + // Not null + ctx.fun(ops.typeNotNull(type.name, ctx), () => { + ctx.signature( + `(${resolveFuncType(type, ctx)}) ${ops.typeNotNull(type.name, ctx)}(tuple v)`, + ); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + ctx.append(`throw_if(${contractErrors.null.id}, null?(v));`); + const flatPack = resolveFuncFlatPack(type, "vvv", ctx); + const flatTypes = resolveFuncFlatTypes(type, ctx); + if (flatPack.length !== flatTypes.length) + throw Error("Flat pack and flat types length mismatch"); + const pairs = flatPack.map((v, i) => `${flatTypes[i]} ${v}`); + if (flatPack.length <= maxTupleSize) { + ctx.used(`__tact_tuple_destroy_${flatPack.length}`); + ctx.append( + `var (${pairs.join(", ")}) = __tact_tuple_destroy_${flatPack.length}(v);`, + ); + } else { + flatPack.splice(0, maxTupleSize - 1); + const pairsBatch = pairs.splice(0, maxTupleSize - 1); + ctx.used(`__tact_tuple_destroy_${maxTupleSize}`); + ctx.append( + `var (${pairsBatch.join(", ")}, next) = __tact_tuple_destroy_${maxTupleSize}(v);`, + ); + while (flatPack.length >= maxTupleSize) { + flatPack.splice(0, maxTupleSize - 1); + const pairsBatch = pairs.splice(0, maxTupleSize - 1); + ctx.append( + `var (${pairsBatch.join(", ")}, next) = __tact_tuple_destroy_${maxTupleSize}(next);`, + ); + } + ctx.used(`__tact_tuple_destroy_${flatPack.length}`); + ctx.append( + `var (${pairs.join(", ")}) = __tact_tuple_destroy_${flatPack.length}(next);`, + ); + } + ctx.append(`return ${resolveFuncTypeUnpack(type, "vvv", ctx)};`); + }); + }); + + // As optional + ctx.fun(ops.typeAsOptional(type.name, ctx), () => { + ctx.signature( + `tuple ${ops.typeAsOptional(type.name, ctx)}(${resolveFuncType(type, ctx)} v)`, + ); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + ctx.append(`var ${resolveFuncTypeUnpack(type, "v", ctx)} = v;`); + const flatPack = resolveFuncFlatPack(type, "v", ctx); + if (flatPack.length <= maxTupleSize) { + ctx.used(`__tact_tuple_create_${flatPack.length}`); + ctx.append( + `return __tact_tuple_create_${flatPack.length}(${flatPack.join(", ")});`, + ); + } else { + const longTupleFlatPack = chainVars(flatPack); + ctx.used(`__tact_tuple_create_${longTupleFlatPack.length}`); + ctx.append( + `return __tact_tuple_create_${longTupleFlatPack.length}(${longTupleFlatPack.join(", ")});`, + ); + } + }); + }); + + // + // Convert to and from tuple representation + // + + ctx.fun(ops.typeToTuple(type.name, ctx), () => { + ctx.signature( + `tuple ${ops.typeToTuple(type.name, ctx)}((${resolveFuncType(type, ctx)}) v)`, + ); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + ctx.append( + `var (${type.fields.map((v) => `v'${v.name}`).join(", ")}) = v;`, + ); + const vars: string[] = []; + for (const f of type.fields) { + if (f.type.kind === "ref") { + const t = getType(ctx.ctx, f.type.name); + if (t.kind === "struct") { + if (f.type.optional) { + vars.push( + `${ops.typeToOptTuple(f.type.name, ctx)}(v'${f.name})`, + ); + } else { + vars.push( + `${ops.typeToTuple(f.type.name, ctx)}(v'${f.name})`, + ); + } + continue; + } + } + vars.push(`v'${f.name}`); + } + if (vars.length <= maxTupleSize) { + ctx.used(`__tact_tuple_create_${vars.length}`); + ctx.append( + `return __tact_tuple_create_${vars.length}(${vars.join(", ")});`, + ); + } else { + const longTupleVars = chainVars(vars); + ctx.used(`__tact_tuple_create_${longTupleVars.length}`); + ctx.append( + `return __tact_tuple_create_${longTupleVars.length}(${longTupleVars.join(", ")});`, + ); + } + }); + }); + + ctx.fun(ops.typeToOptTuple(type.name, ctx), () => { + ctx.signature(`tuple ${ops.typeToOptTuple(type.name, ctx)}(tuple v)`); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + ctx.append(`if (null?(v)) { return null(); } `); + ctx.append( + `return ${ops.typeToTuple(type.name, ctx)}(${ops.typeNotNull(type.name, ctx)}(v)); `, + ); + }); + }); + + ctx.fun(ops.typeFromTuple(type.name, ctx), () => { + ctx.signature( + `(${type.fields.map((v) => resolveFuncType(v.type, ctx)).join(", ")}) ${ops.typeFromTuple(type.name, ctx)}(tuple v)`, + ); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + // Resolve vars + const vars: string[] = []; + const out: string[] = []; + for (const f of type.fields) { + if (f.type.kind === "ref") { + const t = getType(ctx.ctx, f.type.name); + if (t.kind === "struct") { + vars.push(`tuple v'${f.name}`); + if (f.type.optional) { + out.push( + `${ops.typeFromOptTuple(f.type.name, ctx)}(v'${f.name})`, + ); + } else { + out.push( + `${ops.typeFromTuple(f.type.name, ctx)}(v'${f.name})`, + ); + } + continue; + } else if ( + t.kind === "primitive_type_decl" && + t.name === "Address" + ) { + if (f.type.optional) { + vars.push( + `${resolveFuncType(f.type, ctx)} v'${f.name}`, + ); + out.push( + `null?(v'${f.name}) ? null() : ${ctx.used(`__tact_verify_address`)}(v'${f.name})`, + ); + } else { + vars.push( + `${resolveFuncType(f.type, ctx)} v'${f.name}`, + ); + out.push( + `${ctx.used(`__tact_verify_address`)}(v'${f.name})`, + ); + } + continue; + } + } + vars.push(`${resolveFuncType(f.type, ctx)} v'${f.name}`); + out.push(`v'${f.name}`); + } + if (vars.length <= maxTupleSize) { + ctx.used(`__tact_tuple_destroy_${vars.length}`); + ctx.append( + `var (${vars.join(", ")}) = __tact_tuple_destroy_${vars.length}(v);`, + ); + } else { + const batch = vars.splice(0, maxTupleSize - 1); + ctx.used(`__tact_tuple_destroy_${maxTupleSize}`); + ctx.append( + `var (${batch.join(", ")}, next) = __tact_tuple_destroy_${maxTupleSize}(v);`, + ); + while (vars.length >= maxTupleSize) { + const batch = vars.splice(0, maxTupleSize - 1); + ctx.used(`__tact_tuple_destroy_${maxTupleSize}`); + ctx.append( + `var (${batch.join(", ")}, next) = __tact_tuple_destroy_${maxTupleSize}(next);`, + ); + } + ctx.used(`__tact_tuple_destroy_${vars.length}`); + ctx.append( + `var (${batch.join(", ")}) = __tact_tuple_destroy_${vars.length}(next);`, + ); + } + ctx.append(`return (${out.join(", ")});`); + }); + }); + + ctx.fun(ops.typeFromOptTuple(type.name, ctx), () => { + ctx.signature(`tuple ${ops.typeFromOptTuple(type.name, ctx)}(tuple v)`); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + ctx.append(`if (null?(v)) { return null(); } `); + ctx.append( + `return ${ops.typeAsOptional(type.name, ctx)}(${ops.typeFromTuple(type.name, ctx)}(v));`, + ); + }); + }); + + // + // Convert to and from external representation + // + + ctx.fun(ops.typeToExternal(type.name, ctx), () => { + ctx.signature( + `(${type.fields.map((f) => resolveFuncType(f.type, ctx)).join(", ")}) ${ops.typeToExternal(type.name, ctx)}((${resolveFuncType(type, ctx)}) v)`, + ); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + ctx.append( + `var (${type.fields.map((v) => `v'${v.name}`).join(", ")}) = v; `, + ); + const vars: string[] = []; + for (const f of type.fields) { + vars.push(`v'${f.name}`); + } + ctx.append(`return (${vars.join(", ")});`); + }); + }); + + ctx.fun(ops.typeToOptExternal(type.name, ctx), () => { + ctx.signature( + `tuple ${ops.typeToOptExternal(type.name, ctx)}(tuple v)`, + ); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + ctx.append( + `var loaded = ${ops.typeToOptTuple(type.name, ctx)}(v);`, + ); + ctx.append(`if (null?(loaded)) {`); + ctx.inIndent(() => { + ctx.append(`return null();`); + }); + ctx.append(`} else {`); + ctx.inIndent(() => { + ctx.append(`return (loaded);`); + }); + ctx.append(`}`); + }); + }); +} diff --git a/src/generatorNew/writers/writeConstant.ts b/src/generatorNew/writers/writeConstant.ts new file mode 100644 index 000000000..7b45bdee6 --- /dev/null +++ b/src/generatorNew/writers/writeConstant.ts @@ -0,0 +1,84 @@ +import { Address, beginCell, Cell, Slice } from "@ton/core"; +import { WriterContext } from "../Writer"; + +export function writeString(str: string, ctx: WriterContext) { + const cell = beginCell().storeStringTail(str).endCell(); + return writeRawSlice("string", `String "${str}"`, cell, ctx); +} + +export function writeComment(str: string, ctx: WriterContext) { + const cell = beginCell().storeUint(0, 32).storeStringTail(str).endCell(); + return writeRawCell("comment", `Comment "${str}"`, cell, ctx); +} + +export function writeAddress(address: Address, ctx: WriterContext) { + return writeRawSlice( + "address", + address.toString(), + beginCell().storeAddress(address).endCell(), + ctx, + ); +} + +export function writeCell(cell: Cell, ctx: WriterContext) { + return writeRawCell( + "cell", + "Cell " + cell.hash().toString("base64"), + cell, + ctx, + ); +} + +export function writeSlice(slice: Slice, ctx: WriterContext) { + const cell = slice.asCell(); + return writeRawSlice( + "slice", + "Slice " + cell.hash().toString("base64"), + cell, + ctx, + ); +} + +function writeRawSlice( + prefix: string, + comment: string, + cell: Cell, + ctx: WriterContext, +) { + const h = cell.hash().toString("hex"); + const t = cell.toBoc({ idx: false }).toString("hex"); + const k = "slice:" + prefix + ":" + h; + if (ctx.isRendered(k)) { + return `__gen_slice_${prefix}_${h}`; + } + ctx.markRendered(k); + ctx.fun(`__gen_slice_${prefix}_${h}`, () => { + ctx.signature(`slice __gen_slice_${prefix}_${h}()`); + ctx.comment(comment); + ctx.context("constants"); + ctx.asm("", `B{${t}} B>boc { + ctx.signature(`cell __gen_cell_${prefix}_${h}()`); + ctx.comment(comment); + ctx.context("constants"); + ctx.asm("", `B{${t}} B>boc PUSHREF`); + }); + return `__gen_cell_${prefix}_${h}`; +} diff --git a/src/generatorNew/writers/writeContract.ts b/src/generatorNew/writers/writeContract.ts new file mode 100644 index 000000000..642682052 --- /dev/null +++ b/src/generatorNew/writers/writeContract.ts @@ -0,0 +1,374 @@ +import { contractErrors } from "../../abi/errors"; +import { + enabledInline, + enabledInterfacesGetter, + enabledIpfsAbiGetter, + enabledMasterchain, +} from "../../config/features"; +import { ItemOrigin } from "../../grammar/grammar"; +import { InitDescription, TypeDescription } from "../../types/types"; +import { WriterContext } from "../Writer"; +import { funcIdOf, funcInitIdOf } from "./id"; +import { ops } from "./ops"; +import { resolveFuncPrimitive } from "./resolveFuncPrimitive"; +import { resolveFuncType } from "./resolveFuncType"; +import { resolveFuncTypeUnpack } from "./resolveFuncTypeUnpack"; +import { writeValue } from "./writeExpression"; +import { writeGetter, writeStatement } from "./writeFunction"; +import { writeInterfaces } from "./writeInterfaces"; +import { writeReceiver, writeRouter } from "./writeRouter"; + +export function writeStorageOps( + type: TypeDescription, + origin: ItemOrigin, + ctx: WriterContext, +) { + // Load function + ctx.fun(ops.contractLoad(type.name, ctx), () => { + ctx.signature( + `${resolveFuncType(type, ctx)} ${ops.contractLoad(type.name, ctx)}()`, + ); + ctx.flag("impure"); + // ctx.flag('inline'); + ctx.context("type:" + type.name + "$init"); + ctx.body(() => { + // Load data slice + ctx.append(`slice $sc = get_data().begin_parse();`); + + // Load context + ctx.append(`__tact_context_sys = $sc~load_ref();`); + ctx.append(`int $loaded = $sc~load_int(1);`); + + // Load data + ctx.append(`if ($loaded) {`); + ctx.inIndent(() => { + if (type.fields.length > 0) { + ctx.append(`return $sc~${ops.reader(type.name, ctx)}();`); + } else { + ctx.append(`return null();`); + } + }); + ctx.append(`} else {`); + ctx.inIndent(() => { + // Allow only workchain deployments + if (!enabledMasterchain(ctx.ctx)) { + ctx.write(`;; Allow only workchain deployments`); + ctx.write( + `throw_unless(${contractErrors.masterchainNotEnabled.id}, my_address().preload_uint(11) == 1024);`, + ); + } + + // Load arguments + if (type.init!.params.length > 0) { + ctx.append( + `(${type.init!.params.map((v) => resolveFuncType(v.type, ctx) + " " + funcIdOf(v.name)).join(", ")}) = $sc~${ops.reader(funcInitIdOf(type.name), ctx)}();`, + ); + ctx.append(`$sc.end_parse();`); + } + + // Execute init function + ctx.append( + `return ${ops.contractInit(type.name, ctx)}(${[...type.init!.params.map((v) => funcIdOf(v.name))].join(", ")});`, + ); + }); + + ctx.append(`}`); + }); + }); + + // Store function + ctx.fun(ops.contractStore(type.name, ctx), () => { + const sig = `() ${ops.contractStore(type.name, ctx)}(${resolveFuncType(type, ctx)} v)`; + ctx.signature(sig); + ctx.flag("impure"); + ctx.flag("inline"); + ctx.context("type:" + type.name + "$init"); + ctx.body(() => { + ctx.append(`builder b = begin_cell();`); + + // Persist system cell + ctx.append(`b = b.store_ref(__tact_context_sys);`); + + // Persist deployment flag + ctx.append(`b = b.store_int(true, 1);`); + + // Build data + if (type.fields.length > 0) { + ctx.append(`b = ${ops.writer(type.name, ctx)}(b, v);`); + } + + // Persist data + ctx.append(`set_data(b.end_cell());`); + }); + }); +} + +export function writeInit( + t: TypeDescription, + init: InitDescription, + ctx: WriterContext, +) { + ctx.fun(ops.contractInit(t.name, ctx), () => { + const args = init.params.map( + (v) => resolveFuncType(v.type, ctx) + " " + funcIdOf(v.name), + ); + const sig = `${resolveFuncType(t, ctx)} ${ops.contractInit(t.name, ctx)}(${args.join(", ")})`; + ctx.signature(sig); + ctx.flag("impure"); + ctx.body(() => { + // Unpack parameters + for (const a of init.params) { + if (!resolveFuncPrimitive(a.type, ctx)) { + ctx.append( + `var (${resolveFuncTypeUnpack(a.type, funcIdOf(a.name), ctx)}) = ${funcIdOf(a.name)};`, + ); + } + } + + // Generate self initial tensor + const initValues: string[] = []; + t.fields.forEach((tField) => { + let init = "null()"; + if (tField.default !== undefined) { + init = writeValue(tField.default!, ctx); + } + initValues.push(init); + }); + if (initValues.length > 0) { + // Special case for empty contracts + ctx.append( + `var (${resolveFuncTypeUnpack(t, funcIdOf("self"), ctx)}) = (${initValues.join(", ")});`, + ); + } else { + ctx.append(`tuple ${funcIdOf("self")} = null();`); + } + + // Generate statements + const returns = resolveFuncTypeUnpack(t, funcIdOf("self"), ctx); + for (const s of init.ast.statements) { + if (s.kind === "statement_return") { + ctx.append(`return ${returns};`); + } else { + writeStatement(s, returns, null, ctx); + } + } + + // Return result + if ( + init.ast.statements.length === 0 || + init.ast.statements[init.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + ctx.append(`return ${returns};`); + } + }); + }); + + ctx.fun(ops.contractInitChild(t.name, ctx), () => { + const args = [ + `cell sys'`, + ...init.params.map( + (v) => resolveFuncType(v.type, ctx) + " " + funcIdOf(v.name), + ), + ]; + const sig = `(cell, cell) ${ops.contractInitChild(t.name, ctx)}(${args.join(", ")})`; + ctx.signature(sig); + if (enabledInline(ctx.ctx)) { + ctx.flag("inline"); + } + ctx.context("type:" + t.name + "$init"); + ctx.body(() => { + ctx.write(` + slice sc' = sys'.begin_parse(); + cell source = sc'~load_dict(); + cell contracts = new_dict(); + + ;; Contract Code: ${t.name} + cell mine = ${ctx.used(`__tact_dict_get_code`)}(source, ${t.uid}); + contracts = ${ctx.used(`__tact_dict_set_code`)}(contracts, ${t.uid}, mine); + `); + + // Copy contracts code + for (const c of t.dependsOn) { + ctx.append(); + ctx.write(` + ;; Contract Code: ${c.name} + cell code_${c.uid} = __tact_dict_get_code(source, ${c.uid}); + contracts = ${ctx.used(`__tact_dict_set_code`)}(contracts, ${c.uid}, code_${c.uid}); + `); + } + + // Build cell + ctx.append(); + ctx.append(`;; Build cell`); + ctx.append(`builder b = begin_cell();`); + ctx.append( + `b = b.store_ref(begin_cell().store_dict(contracts).end_cell());`, + ); + ctx.append(`b = b.store_int(false, 1);`); + const args = + t.init!.params.length > 0 + ? [ + "b", + "(" + + t + .init!.params.map((a) => funcIdOf(a.name)) + .join(", ") + + ")", + ].join(", ") + : "b, null()"; + ctx.append( + `b = ${ops.writer(funcInitIdOf(t.name), ctx)}(${args});`, + ); + ctx.append(`return (mine, b.end_cell());`); + }); + }); +} + +export function writeMainContract( + type: TypeDescription, + abiLink: string, + ctx: WriterContext, +) { + // Main field + ctx.main(() => { + // Comments + ctx.append(`;;`); + ctx.append(`;; Receivers of a Contract ${type.name}`); + ctx.append(`;;`); + ctx.append(``); + + // Write receivers + for (const r of type.receivers) { + writeReceiver(type, r, ctx); + } + + // Comments + ctx.append(`;;`); + ctx.append(`;; Get methods of a Contract ${type.name}`); + ctx.append(`;;`); + ctx.append(``); + + // Getters + for (const f of type.functions.values()) { + if (f.isGetter) { + writeGetter(f, ctx); + } + } + + // Interfaces + if (enabledInterfacesGetter(ctx.ctx)) { + writeInterfaces(type, ctx); + } + + // ABI + if (enabledIpfsAbiGetter(ctx.ctx)) { + ctx.append(`_ get_abi_ipfs() method_id {`); + ctx.inIndent(() => { + ctx.append(`return "${abiLink}";`); + }); + ctx.append(`}`); + ctx.append(); + } + + // Deployed + ctx.append(`_ lazy_deployment_completed() method_id {`); + ctx.inIndent(() => { + ctx.append(`return get_data().begin_parse().load_int(1);`); + }); + ctx.append(`}`); + ctx.append(); + + // Comments + ctx.append(`;;`); + ctx.append(`;; Routing of a Contract ${type.name}`); + ctx.append(`;;`); + ctx.append(``); + + // Render body + const hasExternal = type.receivers.find((v) => + v.selector.kind.startsWith("external-"), + ); + writeRouter(type, "internal", ctx); + if (hasExternal) { + writeRouter(type, "external", ctx); + } + + // Render internal receiver + ctx.append( + `() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure {`, + ); + ctx.inIndent(() => { + // Load context + ctx.append(); + ctx.append(`;; Context`); + ctx.append(`var cs = in_msg_cell.begin_parse();`); + ctx.append(`var msg_flags = cs~load_uint(4);`); // int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool + ctx.append(`var msg_bounced = -(msg_flags & 1);`); + ctx.append( + `slice msg_sender_addr = ${ctx.used("__tact_verify_address")}(cs~load_msg_addr());`, + ); + ctx.append( + `__tact_context = (msg_bounced, msg_sender_addr, msg_value, cs);`, + ); + ctx.append(`__tact_context_sender = msg_sender_addr;`); + ctx.append(); + + // Load self + ctx.append(`;; Load contract data`); + ctx.append(`var self = ${ops.contractLoad(type.name, ctx)}();`); + ctx.append(); + + // Process operation + ctx.append(`;; Handle operation`); + ctx.append( + `int handled = self~${ops.contractRouter(type.name, "internal")}(msg_bounced, in_msg);`, + ); + ctx.append(); + + // Throw if not handled + ctx.append(`;; Throw if not handled`); + ctx.append( + `throw_unless(${contractErrors.invalidMessage.id}, handled);`, + ); + ctx.append(); + + // Persist state + ctx.append(`;; Persist state`); + ctx.append(`${ops.contractStore(type.name, ctx)}(self);`); + }); + ctx.append("}"); + ctx.append(); + + // Render external receiver + if (hasExternal) { + ctx.append(`() recv_external(slice in_msg) impure {`); + ctx.inIndent(() => { + // Load self + ctx.append(`;; Load contract data`); + ctx.append(`var self = ${ops.contractLoad(type.name, ctx)}();`); + ctx.append(); + + // Process operation + ctx.append(`;; Handle operation`); + ctx.append( + `int handled = self~${ops.contractRouter(type.name, "external")}(in_msg);`, + ); + ctx.append(); + + // Throw if not handled + ctx.append(`;; Throw if not handled`); + ctx.append( + `throw_unless(${contractErrors.invalidMessage.id}, handled);`, + ); + ctx.append(); + + // Persist state + ctx.append(`;; Persist state`); + ctx.append(`${ops.contractStore(type.name, ctx)}(self);`); + }); + ctx.append("}"); + ctx.append(); + } + }); +} diff --git a/src/generatorNew/writers/writeExpression.spec.ts b/src/generatorNew/writers/writeExpression.spec.ts new file mode 100644 index 000000000..19b9bd17f --- /dev/null +++ b/src/generatorNew/writers/writeExpression.spec.ts @@ -0,0 +1,102 @@ +import { __DANGER_resetNodeId } from "../../grammar/ast"; +import { + getStaticFunction, + resolveDescriptors, +} from "../../types/resolveDescriptors"; +import { WriterContext } from "../Writer"; +import { writeExpression } from "./writeExpression"; +import { openContext } from "../../grammar/store"; +import { resolveStatements } from "../../types/resolveStatements"; +import { CompilerContext } from "../../context"; + +const code = ` + +primitive Int; +primitive Bool; +primitive Builder; +primitive Cell; +primitive Slice; + +fun f1(a: Int): Int { + return a; +} + +struct A { + a: Int; + b: Int; +} + +fun main() { + let a: Int = 1; + let b: Int = 2; + let c: Int = a + b; + let d: Int = a + b * c; + let e: Int = a + b / c; + let f: Bool = true; + let g: Bool = false; + let h: Bool = a > 1 || b < 2 && c == 3 || !(d != 4 && true && !false); + let i: Int = f1(a); + let j: A = A{a: 1, b: 2}; + let k: Int = j.a; + let l: Int = A{a: 1, b}.b; + let m: Int = -j.b + a; + let n: Int = -j.b + a + (+b); + let o: Int? = null; + let p: Int? = o!! + 1; + let q: Cell = j.toCell(); +} +`; + +const golden: string[] = [ + "1", + "2", + "($a + $b)", + "($a + ($b * $c))", + "($a + ($b / $c))", + "true", + "false", + "( (( (($a > 1)) ? (true) : (( (($b < 2)) ? (($c == 3)) : (false) )) )) ? (true) : ((~ ( (( (($d != 4)) ? (true) : (false) )) ? (true) : (false) ))) )", + "$global_f1($a)", + "$A$_constructor_a_b(1, 2)", + `$j'a`, + "$A$_get_b($A$_constructor_a_b(1, $b))", + `((- $j'b) + $a)`, + `(((- $j'b) + $a) + (+ $b))`, + "null()", + "(__tact_not_null($o) + 1)", + `$A$_store_cell(($j'a, $j'b))`, +]; + +describe("writeExpression", () => { + beforeEach(() => { + __DANGER_resetNodeId(); + }); + it("should write expression", () => { + let ctx = openContext( + new CompilerContext(), + [{ code: code, path: "", origin: "user" }], + [], + ); + ctx = resolveDescriptors(ctx); + ctx = resolveStatements(ctx); + const main = getStaticFunction(ctx, "main"); + if (main.ast.kind !== "function_def") { + throw Error("Unexpected function kind"); + } + let i = 0; + for (const s of main.ast.statements) { + if (s.kind !== "statement_let") { + throw Error("Unexpected statement kind"); + } + const wCtx = new WriterContext(ctx, "Contract1"); + wCtx.fun("$main", () => { + wCtx.body(() => { + expect(writeExpression(s.expression, wCtx)).toBe( + golden[i]!, + ); + }); + }); + i++; + } + }); +}); diff --git a/src/generatorNew/writers/writeExpression.ts b/src/generatorNew/writers/writeExpression.ts new file mode 100644 index 000000000..937d3144c --- /dev/null +++ b/src/generatorNew/writers/writeExpression.ts @@ -0,0 +1,692 @@ +import { + AstExpression, + AstId, + eqNames, + idText, + tryExtractPath, +} from "../../grammar/ast"; +import { + idTextErr, + TactConstEvalError, + throwCompilationError, +} from "../../errors"; +import { getExpType } from "../../types/resolveExpression"; +import { + getStaticConstant, + getStaticFunction, + getType, + hasStaticConstant, +} from "../../types/resolveDescriptors"; +import { + FieldDescription, + printTypeRef, + TypeDescription, + CommentValue, + Value, +} from "../../types/types"; +import { WriterContext } from "../Writer"; +import { resolveFuncTypeUnpack } from "./resolveFuncTypeUnpack"; +import { MapFunctions } from "../../abi/map"; +import { GlobalFunctions } from "../../abi/global"; +import { funcIdOf } from "./id"; +import { StructFunctions } from "../../abi/struct"; +import { resolveFuncType } from "./resolveFuncType"; +import { Address, Cell, Slice } from "@ton/core"; +import { + writeAddress, + writeCell, + writeComment, + writeSlice, + writeString, +} from "./writeConstant"; +import { ops } from "./ops"; +import { writeCastedExpression } from "./writeFunction"; +import { evalConstantExpression } from "../../constEval"; +import { isLvalue } from "../../types/resolveStatements"; + +function isNull(f: AstExpression): boolean { + return f.kind === "null"; +} + +function writeStructConstructor( + type: TypeDescription, + args: string[], + ctx: WriterContext, +) { + // Check for duplicates + const name = ops.typeConstructor(type.name, args, ctx); + const renderKey = "$constructor$" + type.name + "$" + args.join(","); + if (ctx.isRendered(renderKey)) { + return name; + } + ctx.markRendered(renderKey); + + // Generate constructor + ctx.fun(name, () => { + const funcType = resolveFuncType(type, ctx); + // rename a struct constructor formal parameter to avoid + // name clashes with FunC keywords, e.g. `struct Foo {type: Int}` + // is a perfectly fine Tact structure, but its constructor would + // have the wrong parameter name: `$Foo$_constructor_type(int type)` + const avoidFunCKeywordNameClash = (p: string) => `$${p}`; + const sig = `(${funcType}) ${name}(${args.map((v) => resolveFuncType(type.fields.find((v2) => v2.name === v)!.type, ctx) + " " + avoidFunCKeywordNameClash(v)).join(", ")})`; + ctx.signature(sig); + ctx.flag("inline"); + ctx.context("type:" + type.name); + ctx.body(() => { + // Create expressions + const expressions = type.fields.map((v) => { + const arg = args.find((v2) => v2 === v.name); + if (arg) { + return avoidFunCKeywordNameClash(arg); + } else if (v.default !== undefined) { + return writeValue(v.default, ctx); + } else { + throw Error( + `Missing argument for field "${v.name}" in struct "${type.name}"`, + ); // Must not happen + } + }, ctx); + + if (expressions.length === 0 && funcType === "tuple") { + ctx.append(`return empty_tuple();`); + } else { + ctx.append(`return (${expressions.join(", ")});`); + } + }); + }); + return name; +} + +export function writeValue(val: Value, wCtx: WriterContext): string { + if (typeof val === "bigint") { + return val.toString(10); + } + if (typeof val === "string") { + const id = writeString(val, wCtx); + wCtx.used(id); + return `${id}()`; + } + if (typeof val === "boolean") { + return val ? "true" : "false"; + } + if (Address.isAddress(val)) { + const res = writeAddress(val, wCtx); + wCtx.used(res); + return res + "()"; + } + if (val instanceof Cell) { + const res = writeCell(val, wCtx); + wCtx.used(res); + return `${res}()`; + } + if (val instanceof Slice) { + const res = writeSlice(val, wCtx); + wCtx.used(res); + return `${res}()`; + } + if (val === null) { + return "null()"; + } + if (val instanceof CommentValue) { + const id = writeComment(val.comment, wCtx); + wCtx.used(id); + return `${id}()`; + } + if (typeof val === "object" && "$tactStruct" in val) { + // this is a struct value + const structDescription = getType( + wCtx.ctx, + val["$tactStruct"] as string, + ); + const fields = structDescription.fields.map((field) => field.name); + const id = writeStructConstructor(structDescription, fields, wCtx); + wCtx.used(id); + const fieldValues = structDescription.fields.map((field) => { + if (field.name in val) { + if (field.type.kind === "ref" && field.type.optional) { + const ft = getType(wCtx.ctx, field.type.name); + if (ft.kind === "struct" && val[field.name] !== null) { + return `${ops.typeAsOptional(ft.name, wCtx)}(${writeValue(val[field.name]!, wCtx)})`; + } + } + return writeValue(val[field.name]!, wCtx); + } else { + throw Error( + `Struct value is missing a field: ${field.name}`, + val, + ); + } + }); + return `${id}(${fieldValues.join(", ")})`; + } + throw Error("Invalid value", val); +} + +export function writePathExpression(path: AstId[]): string { + return [funcIdOf(idText(path[0]!)), ...path.slice(1).map(idText)].join(`'`); +} + +export function writeExpression(f: AstExpression, wCtx: WriterContext): string { + // literals and constant expressions are covered here + try { + const value = evalConstantExpression(f, wCtx.ctx); + return writeValue(value, wCtx); + } catch (error) { + if (!(error instanceof TactConstEvalError) || error.fatal) throw error; + } + + // + // ID Reference + // + + if (f.kind === "id") { + const t = getExpType(wCtx.ctx, f); + + // Handle packed type + if (t.kind === "ref") { + const tt = getType(wCtx.ctx, t.name); + if (tt.kind === "contract" || tt.kind === "struct") { + return resolveFuncTypeUnpack(t, funcIdOf(f.text), wCtx); + } + } + + if (t.kind === "ref_bounced") { + const tt = getType(wCtx.ctx, t.name); + if (tt.kind === "struct") { + return resolveFuncTypeUnpack( + t, + funcIdOf(f.text), + wCtx, + false, + true, + ); + } + } + + // Handle constant + if (hasStaticConstant(wCtx.ctx, f.text)) { + const c = getStaticConstant(wCtx.ctx, f.text); + return writeValue(c.value!, wCtx); + } + + return funcIdOf(f.text); + } + + // NOTE: We always wrap in parentheses to avoid operator precedence issues + if (f.kind === "op_binary") { + // Special case for non-integer types and nullable + if (f.op === "==" || f.op === "!=") { + if (isNull(f.left) && isNull(f.right)) { + if (f.op === "==") { + return "true"; + } else { + return "false"; + } + } else if (isNull(f.left) && !isNull(f.right)) { + if (f.op === "==") { + return `null?(${writeExpression(f.right, wCtx)})`; + } else { + return `(~ null?(${writeExpression(f.right, wCtx)}))`; + } + } else if (!isNull(f.left) && isNull(f.right)) { + if (f.op === "==") { + return `null?(${writeExpression(f.left, wCtx)})`; + } else { + return `(~ null?(${writeExpression(f.left, wCtx)}))`; + } + } + } + + // Special case for address + const lt = getExpType(wCtx.ctx, f.left); + const rt = getExpType(wCtx.ctx, f.right); + + // Case for addresses equality + if ( + lt.kind === "ref" && + rt.kind === "ref" && + lt.name === "Address" && + rt.name === "Address" + ) { + let prefix = ""; + if (f.op == "!=") { + prefix = "~ "; + } + if (lt.optional && rt.optional) { + wCtx.used(`__tact_slice_eq_bits_nullable`); + return `( ${prefix}__tact_slice_eq_bits_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)}) )`; + } + if (lt.optional && !rt.optional) { + wCtx.used(`__tact_slice_eq_bits_nullable_one`); + return `( ${prefix}__tact_slice_eq_bits_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)}) )`; + } + if (!lt.optional && rt.optional) { + wCtx.used(`__tact_slice_eq_bits_nullable_one`); + return `( ${prefix}__tact_slice_eq_bits_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)}) )`; + } + wCtx.used(`__tact_slice_eq_bits`); + return `( ${prefix}__tact_slice_eq_bits(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)}) )`; + } + + // Case for cells equality + if ( + lt.kind === "ref" && + rt.kind === "ref" && + lt.name === "Cell" && + rt.name === "Cell" + ) { + const op = f.op === "==" ? "eq" : "neq"; + if (lt.optional && rt.optional) { + wCtx.used(`__tact_cell_${op}_nullable`); + return `__tact_cell_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + } + if (lt.optional && !rt.optional) { + wCtx.used(`__tact_cell_${op}_nullable_one`); + return `__tact_cell_${op}_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + } + if (!lt.optional && rt.optional) { + wCtx.used(`__tact_cell_${op}_nullable_one`); + return `__tact_cell_${op}_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + } + wCtx.used(`__tact_cell_${op}`); + return `__tact_cell_${op}(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + } + + // Case for slices and strings equality + if ( + lt.kind === "ref" && + rt.kind === "ref" && + lt.name === rt.name && + (lt.name === "Slice" || lt.name === "String") + ) { + const op = f.op === "==" ? "eq" : "neq"; + if (lt.optional && rt.optional) { + wCtx.used(`__tact_slice_${op}_nullable`); + return `__tact_slice_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + } + if (lt.optional && !rt.optional) { + wCtx.used(`__tact_slice_${op}_nullable_one`); + return `__tact_slice_${op}_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + } + if (!lt.optional && rt.optional) { + wCtx.used(`__tact_slice_${op}_nullable_one`); + return `__tact_slice_${op}_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + } + wCtx.used(`__tact_slice_${op}`); + return `__tact_slice_${op}(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + } + + // Case for maps equality + if (lt.kind === "map" && rt.kind === "map") { + const op = f.op === "==" ? "eq" : "neq"; + wCtx.used(`__tact_cell_${op}_nullable`); + return `__tact_cell_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + } + + // Check for int or boolean types + if ( + lt.kind !== "ref" || + rt.kind !== "ref" || + (lt.name !== "Int" && lt.name !== "Bool") || + (rt.name !== "Int" && rt.name !== "Bool") + ) { + const file = f.loc.file; + const loc_info = f.loc.interval.getLineAndColumn(); + throw Error( + `(Internal Compiler Error) Invalid types for binary operation: ${file}:${loc_info.lineNum}:${loc_info.colNum}`, + ); // Should be unreachable + } + + // Case for ints equality + if (f.op === "==" || f.op === "!=") { + const op = f.op === "==" ? "eq" : "neq"; + if (lt.optional && rt.optional) { + wCtx.used(`__tact_int_${op}_nullable`); + return `__tact_int_${op}_nullable(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + } + if (lt.optional && !rt.optional) { + wCtx.used(`__tact_int_${op}_nullable_one`); + return `__tact_int_${op}_nullable_one(${writeExpression(f.left, wCtx)}, ${writeExpression(f.right, wCtx)})`; + } + if (!lt.optional && rt.optional) { + wCtx.used(`__tact_int_${op}_nullable_one`); + return `__tact_int_${op}_nullable_one(${writeExpression(f.right, wCtx)}, ${writeExpression(f.left, wCtx)})`; + } + if (f.op === "==") { + return `(${writeExpression(f.left, wCtx)} == ${writeExpression(f.right, wCtx)})`; + } else { + return `(${writeExpression(f.left, wCtx)} != ${writeExpression(f.right, wCtx)})`; + } + } + + // Case for "&&" operator + if (f.op === "&&") { + return `( (${writeExpression(f.left, wCtx)}) ? (${writeExpression(f.right, wCtx)}) : (false) )`; + } + + // Case for "||" operator + if (f.op === "||") { + return `( (${writeExpression(f.left, wCtx)}) ? (true) : (${writeExpression(f.right, wCtx)}) )`; + } + + // Other ops + return ( + "(" + + writeExpression(f.left, wCtx) + + " " + + f.op + + " " + + writeExpression(f.right, wCtx) + + ")" + ); + } + + // + // Unary operations: !, -, +, !! + // NOTE: We always wrap in parenthesis to avoid operator precedence issues + // + + if (f.kind === "op_unary") { + // NOTE: Logical not is written as a bitwise not + switch (f.op) { + case "!": { + return "(~ " + writeExpression(f.operand, wCtx) + ")"; + } + + case "~": { + return "(~ " + writeExpression(f.operand, wCtx) + ")"; + } + + case "-": { + return "(- " + writeExpression(f.operand, wCtx) + ")"; + } + + case "+": { + return "(+ " + writeExpression(f.operand, wCtx) + ")"; + } + + // NOTE: Assert function that ensures that the value is not null + case "!!": { + const t = getExpType(wCtx.ctx, f.operand); + if (t.kind === "ref") { + const tt = getType(wCtx.ctx, t.name); + if (tt.kind === "struct") { + return `${ops.typeNotNull(tt.name, wCtx)}(${writeExpression(f.operand, wCtx)})`; + } + } + + wCtx.used("__tact_not_null"); + return `${wCtx.used("__tact_not_null")}(${writeExpression(f.operand, wCtx)})`; + } + } + } + + // + // Field Access + // NOTE: this branch resolves "a.b", where "a" is an expression and "b" is a field name + // + + if (f.kind === "field_access") { + // Resolve the type of the expression + const src = getExpType(wCtx.ctx, f.aggregate); + if ( + (src.kind !== "ref" || src.optional) && + src.kind !== "ref_bounced" + ) { + throwCompilationError( + `Cannot access field of non-struct type: "${printTypeRef(src)}"`, + f.loc, + ); + } + const srcT = getType(wCtx.ctx, src.name); + + // Resolve field + let fields: FieldDescription[]; + + fields = srcT.fields; + if (src.kind === "ref_bounced") { + fields = fields.slice(0, srcT.partialFieldCount); + } + + const field = fields.find((v) => eqNames(v.name, f.field)); + const cst = srcT.constants.find((v) => eqNames(v.name, f.field)); + if (!field && !cst) { + throwCompilationError( + `Cannot find field ${idTextErr(f.field)} in struct ${idTextErr(srcT.name)}`, + f.field.loc, + ); + } + + if (field) { + // Trying to resolve field as a path + const path = tryExtractPath(f); + if (path) { + // Prepare path + const idd = writePathExpression(path); + + // Special case for structs + if (field.type.kind === "ref") { + const ft = getType(wCtx.ctx, field.type.name); + if (ft.kind === "struct" || ft.kind === "contract") { + return resolveFuncTypeUnpack(field.type, idd, wCtx); + } + } + + return idd; + } + + // Getter instead of direct field access + return `${ops.typeField(srcT.name, field.name, wCtx)}(${writeExpression(f.aggregate, wCtx)})`; + } else { + return writeValue(cst!.value!, wCtx); + } + } + + // + // Static Function Call + // + + if (f.kind === "static_call") { + // Check global functions + if (GlobalFunctions.has(idText(f.function))) { + return GlobalFunctions.get(idText(f.function))!.generate( + wCtx, + f.args.map((v) => getExpType(wCtx.ctx, v)), + f.args, + f.loc, + ); + } + + const sf = getStaticFunction(wCtx.ctx, idText(f.function)); + let n = ops.global(idText(f.function)); + if (sf.ast.kind === "native_function_decl") { + n = idText(sf.ast.nativeName); + if (n.startsWith("__tact")) { + wCtx.used(n); + } + } else { + wCtx.used(n); + } + return ( + n + + "(" + + f.args + .map((a, i) => + writeCastedExpression(a, sf.params[i]!.type, wCtx), + ) + .join(", ") + + ")" + ); + } + + // + // Struct Constructor + // + + if (f.kind === "struct_instance") { + const src = getType(wCtx.ctx, f.type); + + // Write a constructor + const id = writeStructConstructor( + src, + f.args.map((v) => idText(v.field)), + wCtx, + ); + wCtx.used(id); + + // Write an expression + const expressions = f.args.map( + (v) => + writeCastedExpression( + v.initializer, + src.fields.find((v2) => eqNames(v2.name, v.field))!.type, + wCtx, + ), + wCtx, + ); + return `${id}(${expressions.join(", ")})`; + } + + // + // Object-based function call + // + + if (f.kind === "method_call") { + // Resolve source type + const selfTyRef = getExpType(wCtx.ctx, f.self); + + // Reference type + if (selfTyRef.kind === "ref") { + if (selfTyRef.optional) { + throwCompilationError( + `Cannot call function of non - direct type: "${printTypeRef(selfTyRef)}"`, + f.loc, + ); + } + + // Render function call + const selfTy = getType(wCtx.ctx, selfTyRef.name); + + // Check struct ABI + if (selfTy.kind === "struct") { + if (StructFunctions.has(idText(f.method))) { + const abi = StructFunctions.get(idText(f.method))!; + return abi.generate( + wCtx, + [ + selfTyRef, + ...f.args.map((v) => getExpType(wCtx.ctx, v)), + ], + [f.self, ...f.args], + f.loc, + ); + } + } + + // Resolve function + const methodDescr = selfTy.functions.get(idText(f.method))!; + let name = ops.extension(selfTyRef.name, idText(f.method)); + if ( + methodDescr.ast.kind === "function_def" || + methodDescr.ast.kind === "function_decl" || + methodDescr.ast.kind === "asm_function_def" + ) { + wCtx.used(name); + } else { + name = idText(methodDescr.ast.nativeName); + if (name.startsWith("__tact")) { + wCtx.used(name); + } + } + + // Render arguments + let renderedArguments = f.args.map((a, i) => + writeCastedExpression(a, methodDescr.params[i]!.type, wCtx), + ); + + // Hack to replace a single struct argument to a tensor wrapper since otherwise + // func would convert (int) type to just int and break mutating functions + if (methodDescr.isMutating) { + if (f.args.length === 1) { + const t = getExpType(wCtx.ctx, f.args[0]!); + if (t.kind === "ref") { + const tt = getType(wCtx.ctx, t.name); + if ( + (tt.kind === "contract" || tt.kind === "struct") && + methodDescr.params[0]!.type.kind === "ref" && + !methodDescr.params[0]!.type.optional + ) { + renderedArguments = [ + `${ops.typeTensorCast(tt.name, wCtx)}(${renderedArguments[0]})`, + ]; + } + } + } + } + + // Render + const s = writeExpression(f.self, wCtx); + if (methodDescr.isMutating) { + // check if it's an l-value + const path = tryExtractPath(f.self); + if (path !== null && isLvalue(path, wCtx.ctx)) { + return `${s}~${name}(${renderedArguments.join(", ")})`; + } else { + return `${wCtx.used(ops.nonModifying(name))}(${[s, ...renderedArguments].join(", ")})`; + } + } else { + return `${name}(${[s, ...renderedArguments].join(", ")})`; + } + } + + // Map types + if (selfTyRef.kind === "map") { + if (!MapFunctions.has(idText(f.method))) { + throwCompilationError( + `Map function "${idText(f.method)}" not found`, + f.loc, + ); + } + const abf = MapFunctions.get(idText(f.method))!; + return abf.generate( + wCtx, + [selfTyRef, ...f.args.map((v) => getExpType(wCtx.ctx, v))], + [f.self, ...f.args], + f.loc, + ); + } + + if (selfTyRef.kind === "ref_bounced") { + throw Error("Unimplemented"); + } + + throwCompilationError( + `Cannot call function of non - direct type: "${printTypeRef(selfTyRef)}"`, + f.loc, + ); + } + + // + // Init of + // + + if (f.kind === "init_of") { + const type = getType(wCtx.ctx, f.contract); + return `${ops.contractInitChild(idText(f.contract), wCtx)}(${["__tact_context_sys", ...f.args.map((a, i) => writeCastedExpression(a, type.init!.params[i]!.type, wCtx))].join(", ")})`; + } + + // + // Ternary operator + // + + if (f.kind === "conditional") { + return `(${writeExpression(f.condition, wCtx)} ? ${writeExpression(f.thenBranch, wCtx)} : ${writeExpression(f.elseBranch, wCtx)})`; + } + + // + // Unreachable + // + + throw Error("Unknown expression"); +} diff --git a/src/generatorNew/writers/writeFunction.ts b/src/generatorNew/writers/writeFunction.ts new file mode 100644 index 000000000..cb2727018 --- /dev/null +++ b/src/generatorNew/writers/writeFunction.ts @@ -0,0 +1,726 @@ +import { enabledInline } from "../../config/features"; +import { + AstAsmShuffle, + AstCondition, + AstExpression, + AstStatement, + idOfText, + idText, + isWildcard, + tryExtractPath, +} from "../../grammar/ast"; +import { getType, resolveTypeRef } from "../../types/resolveDescriptors"; +import { getExpType } from "../../types/resolveExpression"; +import { FunctionDescription, TypeRef } from "../../types/types"; +import { getMethodId } from "../../utils/utils"; +import { WriterContext } from "../Writer"; +import { resolveFuncPrimitive } from "./resolveFuncPrimitive"; +import { resolveFuncType } from "./resolveFuncType"; +import { resolveFuncTypeUnpack } from "./resolveFuncTypeUnpack"; +import { funcIdOf } from "./id"; +import { writeExpression, writePathExpression } from "./writeExpression"; +import { cast } from "./cast"; +import { resolveFuncTupleType } from "./resolveFuncTupleType"; +import { ops } from "./ops"; +import { freshIdentifier } from "./freshIdentifier"; +import { idTextErr, throwInternalCompilerError } from "../../errors"; +import { prettyPrintAsmShuffle } from "../../prettyPrinter"; + +export function writeCastedExpression( + expression: AstExpression, + to: TypeRef, + ctx: WriterContext, +) { + const expr = getExpType(ctx.ctx, expression); + return cast(expr, to, writeExpression(expression, ctx), ctx); // Cast for nullable +} + +function unwrapExternal( + targetName: string, + sourceName: string, + type: TypeRef, + ctx: WriterContext, +) { + if (type.kind === "ref") { + const t = getType(ctx.ctx, type.name); + if (t.kind === "struct" || t.kind === "contract") { + if (type.optional) { + ctx.append( + `${resolveFuncType(type, ctx)} ${targetName} = ${ops.typeFromOptTuple(t.name, ctx)}(${sourceName});`, + ); + } else { + ctx.append( + `${resolveFuncType(type, ctx)} ${targetName} = ${ops.typeFromTuple(t.name, ctx)}(${sourceName});`, + ); + } + return; + } else if (t.kind === "primitive_type_decl" && t.name === "Address") { + if (type.optional) { + ctx.append( + `${resolveFuncType(type, ctx)} ${targetName} = null?(${sourceName}) ? null() : ${ctx.used(`__tact_verify_address`)}(${sourceName});`, + ); + } else { + ctx.append( + `${resolveFuncType(type, ctx)} ${targetName} = ${ctx.used(`__tact_verify_address`)}(${sourceName});`, + ); + } + return; + } + } + ctx.append(`${resolveFuncType(type, ctx)} ${targetName} = ${sourceName};`); +} + +export function writeStatement( + f: AstStatement, + self: string | null, + returns: TypeRef | null, + ctx: WriterContext, +) { + switch (f.kind) { + case "statement_return": { + if (f.expression) { + // Format expression + const result = writeCastedExpression( + f.expression, + returns!, + ctx, + ); + + // Return + if (self) { + ctx.append(`return (${self}, ${result});`); + } else { + ctx.append(`return ${result};`); + } + } else { + if (self) { + ctx.append(`return (${self}, ());`); + } else { + ctx.append(`return ();`); + } + } + return; + } + case "statement_let": { + // Underscore name case + if (isWildcard(f.name)) { + ctx.append(`${writeExpression(f.expression, ctx)};`); + return; + } + + // Contract/struct case + const t = + f.type === null + ? getExpType(ctx.ctx, f.expression) + : resolveTypeRef(ctx.ctx, f.type); + + if (t.kind === "ref") { + const tt = getType(ctx.ctx, t.name); + if (tt.kind === "contract" || tt.kind === "struct") { + if (t.optional) { + ctx.append( + `tuple ${funcIdOf(f.name)} = ${writeCastedExpression(f.expression, t, ctx)};`, + ); + } else { + ctx.append( + `var ${resolveFuncTypeUnpack(t, funcIdOf(f.name), ctx)} = ${writeCastedExpression(f.expression, t, ctx)};`, + ); + } + return; + } + } + + ctx.append( + `${resolveFuncType(t, ctx)} ${funcIdOf(f.name)} = ${writeCastedExpression(f.expression, t, ctx)};`, + ); + return; + } + case "statement_assign": { + // Prepare lvalue + const lvaluePath = tryExtractPath(f.path); + if (lvaluePath === null) { + // typechecker is supposed to catch this + throwInternalCompilerError( + `Assignments are allowed only into path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + f.path.loc, + ); + } + const path = writePathExpression(lvaluePath); + + // Contract/struct case + const t = getExpType(ctx.ctx, f.path); + if (t.kind === "ref") { + const tt = getType(ctx.ctx, t.name); + if (tt.kind === "contract" || tt.kind === "struct") { + ctx.append( + `${resolveFuncTypeUnpack(t, path, ctx)} = ${writeCastedExpression(f.expression, t, ctx)};`, + ); + return; + } + } + + ctx.append( + `${path} = ${writeCastedExpression(f.expression, t, ctx)};`, + ); + return; + } + case "statement_augmentedassign": { + const lvaluePath = tryExtractPath(f.path); + if (lvaluePath === null) { + // typechecker is supposed to catch this + throwInternalCompilerError( + `Assignments are allowed only into path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + f.path.loc, + ); + } + const path = writePathExpression(lvaluePath); + const t = getExpType(ctx.ctx, f.path); + ctx.append( + `${path} = ${cast(t, t, `${path} ${f.op} ${writeExpression(f.expression, ctx)}`, ctx)};`, + ); + return; + } + case "statement_condition": { + writeCondition(f, self, false, returns, ctx); + return; + } + case "statement_expression": { + const exp = writeExpression(f.expression, ctx); + ctx.append(`${exp};`); + return; + } + case "statement_while": { + ctx.append(`while (${writeExpression(f.condition, ctx)}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + }); + ctx.append(`}`); + return; + } + case "statement_until": { + ctx.append(`do {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + }); + ctx.append(`} until (${writeExpression(f.condition, ctx)});`); + return; + } + case "statement_repeat": { + ctx.append(`repeat (${writeExpression(f.iterations, ctx)}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + }); + ctx.append(`}`); + return; + } + case "statement_try": { + ctx.append(`try {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + }); + ctx.append("} catch (_) { }"); + return; + } + case "statement_try_catch": { + ctx.append(`try {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + }); + if (isWildcard(f.catchName)) { + ctx.append(`} catch (_) {`); + } else { + ctx.append(`} catch (_, ${funcIdOf(f.catchName)}) {`); + } + ctx.inIndent(() => { + for (const s of f.catchStatements) { + writeStatement(s, self, returns, ctx); + } + }); + ctx.append(`}`); + return; + } + case "statement_foreach": { + const mapPath = tryExtractPath(f.map); + if (mapPath === null) { + // typechecker is supposed to catch this + throwInternalCompilerError( + `foreach is only allowed over maps that are path expressions, i.e. identifiers, or sequences of direct contract/struct/message accesses, like "self.foo" or "self.structure.field"`, + f.map.loc, + ); + } + const path = writePathExpression(mapPath); + + const t = getExpType(ctx.ctx, f.map); + if (t.kind !== "map") { + throw Error("Unknown map type"); + } + + const flag = freshIdentifier("flag"); + const key = isWildcard(f.keyName) + ? freshIdentifier("underscore") + : funcIdOf(f.keyName); + const value = isWildcard(f.valueName) + ? freshIdentifier("underscore") + : funcIdOf(f.valueName); + + // Handle Int key + if (t.key === "Int") { + let bits = 257; + let kind = "int"; + if (t.keyAs?.startsWith("int")) { + bits = parseInt(t.keyAs.slice(3), 10); + } else if (t.keyAs?.startsWith("uint")) { + bits = parseInt(t.keyAs.slice(4), 10); + kind = "uint"; + } + if (t.value === "Int") { + let vBits = 257; + let vKind = "int"; + if (t.valueAs?.startsWith("int")) { + vBits = parseInt(t.valueAs.slice(3), 10); + } else if (t.valueAs?.startsWith("uint")) { + vBits = parseInt(t.valueAs.slice(4), 10); + vKind = "uint"; + } + + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_${vKind}`)}(${path}, ${bits}, ${vBits});`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_${vKind}`)}(${path}, ${bits}, ${key}, ${vBits});`, + ); + }); + ctx.append(`}`); + } else if (t.value === "Bool") { + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_int`)}(${path}, ${bits}, 1);`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_int`)}(${path}, ${bits}, ${key}, 1);`, + ); + }); + ctx.append(`}`); + } else if (t.value === "Cell") { + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_cell`)}(${path}, ${bits});`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_cell`)}(${path}, ${bits}, ${key});`, + ); + }); + ctx.append(`}`); + } else if (t.value === "Address") { + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_slice`)}(${path}, ${bits});`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_slice`)}(${path}, ${bits}, ${key});`, + ); + }); + ctx.append(`}`); + } else { + // value is struct + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_${kind}_cell`)}(${path}, ${bits});`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + ctx.append( + `var ${resolveFuncTypeUnpack(t.value, funcIdOf(f.valueName), ctx)} = ${ops.typeNotNull(t.value, ctx)}(${ops.readerOpt(t.value, ctx)}(${value}));`, + ); + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_${kind}_cell`)}(${path}, ${bits}, ${key});`, + ); + }); + ctx.append(`}`); + } + } + + // Handle address key + if (t.key === "Address") { + if (t.value === "Int") { + let vBits = 257; + let vKind = "int"; + if (t.valueAs?.startsWith("int")) { + vBits = parseInt(t.valueAs.slice(3), 10); + } else if (t.valueAs?.startsWith("uint")) { + vBits = parseInt(t.valueAs.slice(4), 10); + vKind = "uint"; + } + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_${vKind}`)}(${path}, 267, ${vBits});`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_${vKind}`)}(${path}, 267, ${key}, ${vBits});`, + ); + }); + ctx.append(`}`); + } else if (t.value === "Bool") { + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_int`)}(${path}, 267, 1);`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_int`)}(${path}, 267, ${key}, 1);`, + ); + }); + ctx.append(`}`); + } else if (t.value === "Cell") { + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_cell`)}(${path}, 267);`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_cell`)}(${path}, 267, ${key});`, + ); + }); + ctx.append(`}`); + } else if (t.value === "Address") { + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_slice`)}(${path}, 267);`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_slice`)}(${path}, 267, ${key});`, + ); + }); + ctx.append(`}`); + } else { + // value is struct + ctx.append( + `var (${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_min_slice_cell`)}(${path}, 267);`, + ); + ctx.append(`while (${flag}) {`); + ctx.inIndent(() => { + ctx.append( + `var ${resolveFuncTypeUnpack(t.value, funcIdOf(f.valueName), ctx)} = ${ops.typeNotNull(t.value, ctx)}(${ops.readerOpt(t.value, ctx)}(${value}));`, + ); + for (const s of f.statements) { + writeStatement(s, self, returns, ctx); + } + ctx.append( + `(${key}, ${value}, ${flag}) = ${ctx.used(`__tact_dict_next_slice_cell`)}(${path}, 267, ${key});`, + ); + }); + ctx.append(`}`); + } + } + + return; + } + } + + throw Error("Unknown statement kind"); +} + +function writeCondition( + f: AstCondition, + self: string | null, + elseif: boolean, + returns: TypeRef | null, + ctx: WriterContext, +) { + ctx.append( + `${elseif ? "} else" : ""}if (${writeExpression(f.condition, ctx)}) {`, + ); + ctx.inIndent(() => { + for (const s of f.trueStatements) { + writeStatement(s, self, returns, ctx); + } + }); + if (f.falseStatements && f.falseStatements.length > 0) { + ctx.append(`} else {`); + ctx.inIndent(() => { + for (const s of f.falseStatements!) { + writeStatement(s, self, returns, ctx); + } + }); + ctx.append(`}`); + } else if (f.elseif) { + writeCondition(f.elseif, self, true, returns, ctx); + } else { + ctx.append(`}`); + } +} + +export function writeFunction(f: FunctionDescription, ctx: WriterContext) { + // Resolve self + const self = f.self ? getType(ctx.ctx, f.self) : null; + + // Write function header + let returns: string = resolveFuncType(f.returns, ctx); + const returnsOriginal = returns; + let returnsStr: string | null; + if (self && f.isMutating) { + if (f.returns.kind !== "void") { + returns = `(${resolveFuncType(self, ctx)}, ${returns})`; + } else { + returns = `(${resolveFuncType(self, ctx)}, ())`; + } + returnsStr = resolveFuncTypeUnpack(self, funcIdOf("self"), ctx); + } + + // Resolve function descriptor + const params: string[] = []; + if (self) { + params.push(resolveFuncType(self, ctx) + " " + funcIdOf("self")); + } + for (const a of f.params) { + params.push(resolveFuncType(a.type, ctx) + " " + funcIdOf(a.name)); + } + + const fAst = f.ast; + switch (fAst.kind) { + case "native_function_decl": { + const name = idText(fAst.nativeName); + if (f.isMutating && !ctx.isRendered(name)) { + writeNonMutatingFunction( + f, + name, + params, + returnsOriginal, + false, + ctx, + ); + ctx.markRendered(name); + } + return; + } + + case "asm_function_def": { + const name = self + ? ops.extension(self.name, f.name) + : ops.global(f.name); + ctx.fun(name, () => { + ctx.signature(`${returns} ${name}(${params.join(", ")})`); + ctx.flag("impure"); + if (f.origin === "stdlib") { + ctx.context("stdlib"); + } + // we need to do some renames (prepending $ to identifiers) + const asmShuffleEscaped: AstAsmShuffle = { + ...fAst.shuffle, + args: fAst.shuffle.args.map((id) => idOfText(funcIdOf(id))), + }; + ctx.asm( + prettyPrintAsmShuffle(asmShuffleEscaped), + fAst.instructions.join(" "), + ); + }); + if (f.isMutating) { + writeNonMutatingFunction( + f, + name, + params, + returnsOriginal, + true, + ctx, + ); + } + return; + } + + case "function_def": { + const name = self + ? ops.extension(self.name, f.name) + : ops.global(f.name); + + ctx.fun(name, () => { + ctx.signature(`${returns} ${name}(${params.join(", ")})`); + ctx.flag("impure"); + if (enabledInline(ctx.ctx) || f.isInline) { + ctx.flag("inline"); + } + if (f.origin === "stdlib") { + ctx.context("stdlib"); + } + ctx.body(() => { + // Unpack self + if (self) { + ctx.append( + `var (${resolveFuncTypeUnpack(self, funcIdOf("self"), ctx)}) = ${funcIdOf("self")};`, + ); + } + for (const a of f.ast.params) { + if ( + !resolveFuncPrimitive( + resolveTypeRef(ctx.ctx, a.type), + ctx, + ) + ) { + ctx.append( + `var (${resolveFuncTypeUnpack(resolveTypeRef(ctx.ctx, a.type), funcIdOf(a.name), ctx)}) = ${funcIdOf(a.name)};`, + ); + } + } + + // Process statements + for (const s of fAst.statements) { + writeStatement(s, returnsStr, f.returns, ctx); + } + + // Auto append return + if (f.self && f.returns.kind === "void" && f.isMutating) { + if ( + fAst.statements.length === 0 || + fAst.statements[fAst.statements.length - 1]! + .kind !== "statement_return" + ) { + ctx.append(`return (${returnsStr}, ());`); + } + } + }); + }); + + if (f.isMutating) { + writeNonMutatingFunction( + f, + name, + params, + returnsOriginal, + true, + ctx, + ); + } + return; + } + default: { + throwInternalCompilerError( + `Unknown function kind: ${idTextErr(fAst.name)}`, + fAst.loc, + ); + } + } +} + +// Write a function in non-mutating form +function writeNonMutatingFunction( + f: FunctionDescription, + name: string, + params: string[], + returnsOriginal: string, + markUsedName: boolean, + ctx: WriterContext, +) { + const nonMutName = ops.nonModifying(name); + ctx.fun(nonMutName, () => { + ctx.signature(`${returnsOriginal} ${nonMutName}(${params.join(", ")})`); + ctx.flag("impure"); + if (enabledInline(ctx.ctx) || f.isInline) { + ctx.flag("inline"); + } + if (f.origin === "stdlib") { + ctx.context("stdlib"); + } + ctx.body(() => { + ctx.append( + `return ${funcIdOf("self")}~${markUsedName ? ctx.used(name) : name}(${f.ast.params + .slice(1) + .map((arg) => funcIdOf(arg.name)) + .join(", ")});`, + ); + }); + }); +} + +export function writeGetter(f: FunctionDescription, ctx: WriterContext) { + // Render tensors + const self = f.self !== null ? getType(ctx.ctx, f.self) : null; + if (!self) { + throw new Error(`No self type for getter ${idTextErr(f.name)}`); // Impossible + } + ctx.append( + `_ %${f.name}(${f.params.map((v) => resolveFuncTupleType(v.type, ctx) + " " + funcIdOf(v.name)).join(", ")}) method_id(${getMethodId(f.name)}) {`, + ); + ctx.inIndent(() => { + // Unpack parameters + for (const param of f.params) { + unwrapExternal( + funcIdOf(param.name), + funcIdOf(param.name), + param.type, + ctx, + ); + } + + // Load contract state + ctx.append(`var self = ${ops.contractLoad(self.name, ctx)}();`); + + // Execute get method + ctx.append( + `var res = self~${ctx.used(ops.extension(self.name, f.name))}(${f.params.map((v) => funcIdOf(v.name)).join(", ")});`, + ); + + // Pack if needed + if (f.returns.kind === "ref") { + const t = getType(ctx.ctx, f.returns.name); + if (t.kind === "struct" || t.kind === "contract") { + if (f.returns.optional) { + ctx.append( + `return ${ops.typeToOptExternal(t.name, ctx)}(res);`, + ); + } else { + ctx.append( + `return ${ops.typeToExternal(t.name, ctx)}(res);`, + ); + } + return; + } + } + + // Return result + ctx.append(`return res;`); + }); + ctx.append(`}`); + ctx.append(); +} diff --git a/src/generatorNew/writers/writeInterfaces.ts b/src/generatorNew/writers/writeInterfaces.ts new file mode 100644 index 000000000..5173461ae --- /dev/null +++ b/src/generatorNew/writers/writeInterfaces.ts @@ -0,0 +1,26 @@ +import { getSupportedInterfaces } from "../../types/getSupportedInterfaces"; +import { TypeDescription } from "../../types/types"; +import { WriterContext } from "../Writer"; + +export function writeInterfaces(type: TypeDescription, ctx: WriterContext) { + ctx.append(`_ supported_interfaces() method_id {`); + ctx.inIndent(() => { + ctx.append(`return (`); + ctx.inIndent(() => { + // Build interfaces list + const interfaces: string[] = []; + interfaces.push("org.ton.introspection.v0"); + interfaces.push(...getSupportedInterfaces(type, ctx.ctx)); + + // Render interfaces + for (let i = 0; i < interfaces.length; i++) { + ctx.append( + `"${interfaces[i]}"H >> 128${i < interfaces.length - 1 ? "," : ""}`, + ); + } + }); + ctx.append(`);`); + }); + ctx.append(`}`); + ctx.append(); +} diff --git a/src/generatorNew/writers/writeRouter.ts b/src/generatorNew/writers/writeRouter.ts new file mode 100644 index 000000000..82f2e3861 --- /dev/null +++ b/src/generatorNew/writers/writeRouter.ts @@ -0,0 +1,502 @@ +import { beginCell } from "@ton/core"; +import { getType } from "../../types/resolveDescriptors"; +import { ReceiverDescription, TypeDescription } from "../../types/types"; +import { WriterContext } from "../Writer"; +import { funcIdOf } from "./id"; +import { ops } from "./ops"; +import { resolveFuncType } from "./resolveFuncType"; +import { resolveFuncTypeUnpack } from "./resolveFuncTypeUnpack"; +import { writeStatement } from "./writeFunction"; +import { AstNumber } from "../../grammar/ast"; + +export function commentPseudoOpcode(comment: string): string { + return beginCell() + .storeUint(0, 32) + .storeBuffer(Buffer.from(comment, "utf8")) + .endCell() + .hash() + .toString("hex", 0, 64); +} + +export function writeRouter( + type: TypeDescription, + kind: "internal" | "external", + ctx: WriterContext, +) { + const internal = kind === "internal"; + if (internal) { + ctx.append( + `(${resolveFuncType(type, ctx)}, int) ${ops.contractRouter(type.name, kind)}(${resolveFuncType(type, ctx)} self, int msg_bounced, slice in_msg) impure inline_ref {`, + ); + } else { + ctx.append( + `(${resolveFuncType(type, ctx)}, int) ${ops.contractRouter(type.name, kind)}(${resolveFuncType(type, ctx)} self, slice in_msg) impure inline_ref {`, + ); + } + ctx.inIndent(() => { + // Handle bounced + if (internal) { + ctx.append(`;; Handle bounced messages`); + ctx.append(`if (msg_bounced) {`); + ctx.inIndent(() => { + const bounceReceivers = type.receivers.filter((r) => { + return r.selector.kind === "bounce-binary"; + }); + + const fallbackReceiver = type.receivers.find((r) => { + return r.selector.kind === "bounce-fallback"; + }); + + if (fallbackReceiver ?? bounceReceivers.length > 0) { + ctx.append(); + ctx.append(`;; Skip 0xFFFFFFFF`); + ctx.append(`in_msg~skip_bits(32);`); + ctx.append(); + } + + if (bounceReceivers.length > 0) { + ctx.append(`;; Parse op`); + ctx.append(`int op = 0;`); + ctx.append(`if (slice_bits(in_msg) >= 32) {`); + ctx.inIndent(() => { + ctx.append(`op = in_msg.preload_uint(32);`); + }); + ctx.append(`}`); + ctx.append(); + } + + for (const r of bounceReceivers) { + const selector = r.selector; + if (selector.kind !== "bounce-binary") + throw Error("Invalid selector type: " + selector.kind); // Should not happen + const allocation = getType(ctx.ctx, selector.type); + ctx.append( + `;; Bounced handler for ${selector.type} message`, + ); + ctx.append( + `if (op == ${messageOpcode(allocation.header!)}) {`, + ); + ctx.inIndent(() => { + // Read message + ctx.append( + `var msg = in_msg~${selector.bounced ? ops.readerBounced(selector.type, ctx) : ops.reader(selector.type, ctx)}();`, + ); + + // Execute function + ctx.append( + `self~${ops.receiveTypeBounce(type.name, selector.type)}(msg);`, + ); + + // Exit + ctx.append("return (self, true);"); + }); + ctx.append(`}`); + ctx.append(); + } + + if (fallbackReceiver) { + const selector = fallbackReceiver.selector; + if (selector.kind !== "bounce-fallback") + throw Error("Invalid selector type: " + selector.kind); + + // Execute function + ctx.append(`;; Fallback bounce receiver`); + ctx.append( + `self~${ops.receiveBounceAny(type.name)}(in_msg);`, + ); + ctx.append(); + + // Exit + ctx.append("return (self, true);"); + } else { + ctx.append(`return (self, true);`); + } + }); + ctx.append(`}`); + } + + // Parse incoming message + ctx.append(); + ctx.append(`;; Parse incoming message`); + ctx.append(`int op = 0;`); + ctx.append(`if (slice_bits(in_msg) >= 32) {`); + ctx.inIndent(() => { + ctx.append(`op = in_msg.preload_uint(32);`); + }); + ctx.append(`}`); + ctx.append(); + + // Non-empty receivers + for (const f of type.receivers) { + const selector = f.selector; + + // Generic receiver + if ( + selector.kind === + (internal ? "internal-binary" : "external-binary") + ) { + const allocation = getType(ctx.ctx, selector.type); + if (!allocation.header) { + throw Error("Invalid allocation: " + selector.type); + } + ctx.append(); + ctx.append(`;; Receive ${selector.type} message`); + ctx.append(`if (op == ${messageOpcode(allocation.header)}) {`); + ctx.inIndent(() => { + // Read message + ctx.append( + `var msg = in_msg~${ops.reader(selector.type, ctx)}();`, + ); + + // Execute function + ctx.append( + `self~${ops.receiveType(type.name, kind, selector.type)}(msg);`, + ); + + // Exit + ctx.append("return (self, true);"); + }); + ctx.append(`}`); + } + + if ( + selector.kind === + (internal ? "internal-empty" : "external-empty") + ) { + ctx.append(); + ctx.append(`;; Receive empty message`); + ctx.append(`if ((op == 0) & (slice_bits(in_msg) <= 32)) {`); + ctx.inIndent(() => { + // Execute function + ctx.append(`self~${ops.receiveEmpty(type.name, kind)}();`); + + // Exit + ctx.append("return (self, true);"); + }); + ctx.append(`}`); + } + } + + // Text resolvers + const hasComments = !!type.receivers.find((v) => + internal + ? v.selector.kind === "internal-comment" || + v.selector.kind === "internal-comment-fallback" + : v.selector.kind === "external-comment" || + v.selector.kind === "external-comment-fallback", + ); + if (hasComments) { + ctx.append(); + ctx.append(`;; Text Receivers`); + ctx.append(`if (op == 0) {`); + ctx.inIndent(() => { + if ( + type.receivers.find( + (v) => + v.selector.kind === + (internal + ? "internal-comment" + : "external-comment"), + ) + ) { + ctx.append(`var text_op = slice_hash(in_msg);`); + for (const r of type.receivers) { + const selector = r.selector; + if ( + selector.kind === + (internal ? "internal-comment" : "external-comment") + ) { + const hash = commentPseudoOpcode(selector.comment); + ctx.append(); + ctx.append( + `;; Receive "${selector.comment}" message`, + ); + ctx.append(`if (text_op == 0x${hash}) {`); + ctx.inIndent(() => { + // Execute function + ctx.append( + `self~${ops.receiveText(type.name, kind, hash)}();`, + ); + + // Exit + ctx.append("return (self, true);"); + }); + ctx.append(`}`); + } + } + } + + // Comment fallback resolver + const fallback = type.receivers.find( + (v) => + v.selector.kind === + (internal + ? "internal-comment-fallback" + : "external-comment-fallback"), + ); + if (fallback) { + ctx.append(`if (slice_bits(in_msg) >= 32) {`); + ctx.inIndent(() => { + // Execute function + ctx.append( + `self~${ops.receiveAnyText(type.name, kind)}(in_msg.skip_bits(32));`, + ); + + // Exit + ctx.append("return (self, true);"); + }); + + ctx.append(`}`); + } + }); + ctx.append(`}`); + } + + // Fallback + const fallbackReceiver = type.receivers.find( + (v) => + v.selector.kind === + (internal ? "internal-fallback" : "external-fallback"), + ); + if (fallbackReceiver) { + ctx.append(); + ctx.append(`;; Receiver fallback`); + + // Execute function + ctx.append(`self~${ops.receiveAny(type.name, kind)}(in_msg);`); + + ctx.append("return (self, true);"); + } else { + ctx.append(); + ctx.append("return (self, false);"); + } + }); + ctx.append(`}`); + ctx.append(); +} + +function messageOpcode(n: AstNumber): string { + // FunC does not support binary and octal numerals + switch (n.base) { + case 10: + return n.value.toString(n.base); + case 2: + case 8: + case 16: + return `0x${n.value.toString(n.base)}`; + } +} + +export function writeReceiver( + self: TypeDescription, + f: ReceiverDescription, + ctx: WriterContext, +) { + const selector = f.selector; + const selfRes = resolveFuncTypeUnpack(self, funcIdOf("self"), ctx); + const selfType = resolveFuncType(self, ctx); + const selfUnpack = `var ${resolveFuncTypeUnpack(self, funcIdOf("self"), ctx)} = ${funcIdOf("self")};`; + + // Binary receiver + if ( + selector.kind === "internal-binary" || + selector.kind === "external-binary" + ) { + const args = [ + selfType + " " + funcIdOf("self"), + resolveFuncType(selector.type, ctx) + " " + funcIdOf(selector.name), + ]; + ctx.append( + `((${selfType}), ()) ${ops.receiveType(self.name, selector.kind === "internal-binary" ? "internal" : "external", selector.type)}(${args.join(", ")}) impure inline {`, + ); + ctx.inIndent(() => { + ctx.append(selfUnpack); + ctx.append( + `var ${resolveFuncTypeUnpack(selector.type, funcIdOf(selector.name), ctx)} = ${funcIdOf(selector.name)};`, + ); + + for (const s of f.ast.statements) { + writeStatement(s, selfRes, null, ctx); + } + + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + ctx.append(`return (${selfRes}, ());`); + } + }); + ctx.append(`}`); + ctx.append(); + return; + } + + // Empty receiver + if ( + selector.kind === "internal-empty" || + selector.kind === "external-empty" + ) { + ctx.append( + `((${selfType}), ()) ${ops.receiveEmpty(self.name, selector.kind === "internal-empty" ? "internal" : "external")}(${selfType + " " + funcIdOf("self")}) impure inline {`, + ); + ctx.inIndent(() => { + ctx.append(selfUnpack); + + for (const s of f.ast.statements) { + writeStatement(s, selfRes, null, ctx); + } + + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + ctx.append(`return (${selfRes}, ());`); + } + }); + ctx.append(`}`); + ctx.append(); + return; + } + + // Comment receiver + if ( + selector.kind === "internal-comment" || + selector.kind === "external-comment" + ) { + const hash = commentPseudoOpcode(selector.comment); + ctx.append( + `(${selfType}, ()) ${ops.receiveText(self.name, selector.kind === "internal-comment" ? "internal" : "external", hash)}(${selfType + " " + funcIdOf("self")}) impure inline {`, + ); + ctx.inIndent(() => { + ctx.append(selfUnpack); + + for (const s of f.ast.statements) { + writeStatement(s, selfRes, null, ctx); + } + + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + ctx.append(`return (${selfRes}, ());`); + } + }); + ctx.append(`}`); + ctx.append(); + return; + } + + // Fallback + if ( + selector.kind === "internal-comment-fallback" || + selector.kind === "external-comment-fallback" + ) { + ctx.append( + `(${selfType}, ()) ${ops.receiveAnyText(self.name, selector.kind === "internal-comment-fallback" ? "internal" : "external")}(${[selfType + " " + funcIdOf("self"), "slice " + funcIdOf(selector.name)].join(", ")}) impure inline {`, + ); + ctx.inIndent(() => { + ctx.append(selfUnpack); + + for (const s of f.ast.statements) { + writeStatement(s, selfRes, null, ctx); + } + + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + ctx.append(`return (${selfRes}, ());`); + } + }); + ctx.append(`}`); + ctx.append(); + return; + } + + // Fallback + if (selector.kind === "internal-fallback") { + ctx.append( + `(${selfType}, ()) ${ops.receiveAny(self.name, "internal")}(${selfType} ${funcIdOf("self")}, slice ${funcIdOf(selector.name)}) impure inline {`, + ); + ctx.inIndent(() => { + ctx.append(selfUnpack); + + for (const s of f.ast.statements) { + writeStatement(s, selfRes, null, ctx); + } + + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + ctx.append(`return (${selfRes}, ());`); + } + }); + ctx.append(`}`); + ctx.append(); + return; + } + + // Bounced + if (selector.kind === "bounce-fallback") { + ctx.append( + `(${selfType}, ()) ${ops.receiveBounceAny(self.name)}(${selfType} ${funcIdOf("self")}, slice ${funcIdOf(selector.name)}) impure inline {`, + ); + ctx.inIndent(() => { + ctx.append(selfUnpack); + + for (const s of f.ast.statements) { + writeStatement(s, selfRes, null, ctx); + } + + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + ctx.append(`return (${selfRes}, ());`); + } + }); + ctx.append(`}`); + ctx.append(); + return; + } + + if (selector.kind === "bounce-binary") { + const args = [ + selfType + " " + funcIdOf("self"), + resolveFuncType(selector.type, ctx, false, selector.bounced) + + " " + + funcIdOf(selector.name), + ]; + ctx.append( + `((${selfType}), ()) ${ops.receiveTypeBounce(self.name, selector.type)}(${args.join(", ")}) impure inline {`, + ); + ctx.inIndent(() => { + ctx.append(selfUnpack); + ctx.append( + `var ${resolveFuncTypeUnpack(selector.type, funcIdOf(selector.name), ctx, false, selector.bounced)} = ${funcIdOf(selector.name)};`, + ); + + for (const s of f.ast.statements) { + writeStatement(s, selfRes, null, ctx); + } + + if ( + f.ast.statements.length === 0 || + f.ast.statements[f.ast.statements.length - 1]!.kind !== + "statement_return" + ) { + ctx.append(`return (${selfRes}, ());`); + } + }); + ctx.append(`}`); + ctx.append(); + return; + } +} diff --git a/src/generatorNew/writers/writeSerialization.spec.ts b/src/generatorNew/writers/writeSerialization.spec.ts new file mode 100644 index 000000000..cafbd3307 --- /dev/null +++ b/src/generatorNew/writers/writeSerialization.spec.ts @@ -0,0 +1,96 @@ +import { __DANGER_resetNodeId } from "../../grammar/ast"; +import { CompilerContext } from "../../context"; +import { + getAllocation, + resolveAllocations, +} from "../../storage/resolveAllocation"; +import { + getAllTypes, + getType, + resolveDescriptors, +} from "../../types/resolveDescriptors"; +import { WriterContext } from "../Writer"; +import { writeParser, writeSerializer } from "./writeSerialization"; +import { writeStdlib } from "./writeStdlib"; +import { openContext } from "../../grammar/store"; +import { writeAccessors } from "./writeAccessors"; + +const code = ` +primitive Int; +primitive Bool; +primitive Builder; +primitive Cell; +primitive Slice; +primitive Address; + +struct A { + a: Int; + b: Int; + c: Int?; + d: Bool; + e: Bool?; + f: Int; + g: Int; +} + +struct B { + a: Int; + b: Int; + c: Int?; + d: Bool; + e: Bool?; + f: Int; + g: Int; +} + +struct C { + a: Cell; + b: Cell?; + c: Slice?; + d: Slice?; + e: Bool; + f: Int; + g: Int; + h: Address; +} +`; + +describe("writeSerialization", () => { + beforeEach(() => { + __DANGER_resetNodeId(); + }); + for (const s of ["A", "B", "C"]) { + it("should write serializer for " + s, () => { + let ctx = openContext( + new CompilerContext(), + [{ code, path: "", origin: "user" }], + [], + ); + ctx = resolveDescriptors(ctx); + ctx = resolveAllocations(ctx); + const wCtx = new WriterContext(ctx, s); + writeStdlib(wCtx); + writeSerializer( + getType(ctx, s).name, + false, + getAllocation(ctx, s), + "user", + wCtx, + ); + for (const t of getAllTypes(ctx)) { + if (t.kind === "contract" || t.kind === "struct") { + writeAccessors(t, "user", wCtx); + } + } + writeParser( + getType(ctx, s).name, + false, + getAllocation(ctx, s), + "user", + wCtx, + ); + const extracted = wCtx.extract(true); + expect(extracted).toMatchSnapshot(); + }); + } +}); diff --git a/src/codegen/serializers.ts b/src/generatorNew/writers/writeSerialization.ts similarity index 57% rename from src/codegen/serializers.ts rename to src/generatorNew/writers/writeSerialization.ts index 7459c76a7..aca186622 100644 --- a/src/codegen/serializers.ts +++ b/src/generatorNew/writers/writeSerialization.ts @@ -1,12 +1,13 @@ -import { contractErrors } from "../abi/errors"; -import { throwInternalCompilerError } from "../errors"; -import { dummySrcInfo } from "../grammar/grammar"; -import { AllocationCell, AllocationOperation } from "../storage/operation"; -import { StorageAllocation } from "../storage/StorageAllocation"; -import { getType } from "../types/resolveDescriptors"; -import { WriterContext, Location } from "./context"; -import { ops } from "./util"; -import { resolveFuncTypeFromAbiUnpack, resolveFuncTypeFromAbi } from "./type"; +import { contractErrors } from "../../abi/errors"; +import { throwInternalCompilerError } from "../../errors"; +import { dummySrcInfo, ItemOrigin } from "../../grammar/grammar"; +import { AllocationCell, AllocationOperation } from "../../storage/operation"; +import { StorageAllocation } from "../../storage/StorageAllocation"; +import { getType } from "../../types/resolveDescriptors"; +import { WriterContext } from "../Writer"; +import { ops } from "./ops"; +import { resolveFuncTypeFromAbi } from "./resolveFuncTypeFromAbi"; +import { resolveFuncTypeFromAbiUnpack } from "./resolveFuncTypeFromAbiUnpack"; const SMALL_STRUCT_MAX_FIELDS = 5; @@ -18,149 +19,178 @@ export function writeSerializer( name: string, forceInline: boolean, allocation: StorageAllocation, + origin: ItemOrigin, ctx: WriterContext, ) { - const parse = (code: string) => - ctx.parse(code, { context: Location.type(name) }); const isSmall = allocation.ops.length <= SMALL_STRUCT_MAX_FIELDS; // Write to builder - parse(`builder ${ops.writer(name)}(builder build_0, ${resolveFuncTypeFromAbi( - ctx.ctx, - allocation.ops.map((v) => v.type), - )} v) ${forceInline || isSmall ? "inline" : ""} { - ${allocation.ops.length > 0 ? `${resolveFuncTypeFromAbiUnpack(ctx.ctx, "v", allocation.ops)} = v;` : ""} - ${allocation.header ? `build_0 = store_uint(build_0, ${allocation.header.value}, ${allocation.header.bits});` : ""} - ${writeSerializerCell(allocation.root, 0, ctx)}; - return build_0; - } -`); + ctx.fun(ops.writer(name, ctx), () => { + ctx.signature( + `builder ${ops.writer(name, ctx)}(builder build_0, ${resolveFuncTypeFromAbi( + allocation.ops.map((v) => v.type), + ctx, + )} v)`, + ); + if (forceInline || isSmall) { + ctx.flag("inline"); + } + ctx.context("type:" + name); + ctx.body(() => { + if (allocation.ops.length > 0) { + ctx.append( + `var ${resolveFuncTypeFromAbiUnpack(`v`, allocation.ops, ctx)} = v;`, + ); + } + if (allocation.header) { + ctx.append( + `build_0 = store_uint(build_0, ${allocation.header.value}, ${allocation.header.bits});`, + ); + } + writeSerializerCell(allocation.root, 0, ctx); + ctx.append(`return build_0;`); + }); + }); // Write to cell - parse(`cell ${ops.writerCell(name)}(${resolveFuncTypeFromAbi( - ctx.ctx, - allocation.ops.map((v) => v.type), - )} v) inline { - return ${ops.writer(name)}(begin_cell(), v).end_cell(); - } - `); + ctx.fun(ops.writerCell(name, ctx), () => { + ctx.signature( + `cell ${ops.writerCell(name, ctx)}(${resolveFuncTypeFromAbi( + allocation.ops.map((v) => v.type), + ctx, + )} v)`, + ); + ctx.flag("inline"); + ctx.context("type:" + name); + ctx.body(() => { + ctx.append( + `return ${ops.writer(name, ctx)}(begin_cell(), v).end_cell();`, + ); + }); + }); } -export function writeOptionalSerializer(name: string, ctx: WriterContext) { - const parse = (code: string) => - ctx.parse(code, { context: Location.type(name) }); - parse(`cell ${ops.writerCellOpt(name)}(tuple v) inline { - if (null?(v)) { - return null(); - } - return ${ops.writerCell(name)}(${ops.typeNotNull(name)}(v)); - }`); +export function writeOptionalSerializer( + name: string, + origin: ItemOrigin, + ctx: WriterContext, +) { + ctx.fun(ops.writerCellOpt(name, ctx), () => { + ctx.signature(`cell ${ops.writerCellOpt(name, ctx)}(tuple v)`); + ctx.flag("inline"); + ctx.context("type:" + name); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + return null(); + } + return ${ops.writerCell(name, ctx)}(${ops.typeNotNull(name, ctx)}(v)); + `); + }); + }); } function writeSerializerCell( cell: AllocationCell, gen: number, ctx: WriterContext, -): string { - const result = []; - +) { // Write fields for (const f of cell.ops) { - result.push(writeSerializerField(f, gen, ctx)); + writeSerializerField(f, gen, ctx); } // Tail if (cell.next) { - result.push(`var build_${gen + 1} = begin_cell();`); - result.push(writeSerializerCell(cell.next, gen + 1, ctx)); - result.push( + ctx.append(`var build_${gen + 1} = begin_cell();`); + writeSerializerCell(cell.next, gen + 1, ctx); + ctx.append( `build_${gen} = store_ref(build_${gen}, build_${gen + 1}.end_cell());`, ); } - - return result.join("\n"); } function writeSerializerField( f: AllocationOperation, gen: number, ctx: WriterContext, -): string { - const result: string[] = []; +) { const fieldName = `v'${f.name}`; const op = f.op; switch (op.kind) { case "int": { if (op.optional) { - result.push( + ctx.append( `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_int(${fieldName}, ${op.bits}) : build_${gen}.store_int(false, 1);`, ); } else { - result.push( + ctx.append( `build_${gen} = build_${gen}.store_int(${fieldName}, ${op.bits});`, ); } - return result.join("\n"); + return; } case "uint": { if (op.optional) { - result.push( + ctx.append( `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_uint(${fieldName}, ${op.bits}) : build_${gen}.store_int(false, 1);`, ); } else { - result.push( + ctx.append( `build_${gen} = build_${gen}.store_uint(${fieldName}, ${op.bits});`, ); } - return result.join("\n"); + return; } case "coins": { if (op.optional) { - result.push( + ctx.append( `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_coins(${fieldName}) : build_${gen}.store_int(false, 1);`, ); } else { - result.push( + ctx.append( `build_${gen} = build_${gen}.store_coins(${fieldName});`, ); } - return result.join("\n"); + return; } case "boolean": { if (op.optional) { - result.push( + ctx.append( `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_int(${fieldName}, 1) : build_${gen}.store_int(false, 1);`, ); } else { - result.push( + ctx.append( `build_${gen} = build_${gen}.store_int(${fieldName}, 1);`, ); } - return result.join("\n"); + return; } case "address": { if (op.optional) { - result.push( + ctx.used(`__tact_store_address_opt`); + ctx.append( `build_${gen} = __tact_store_address_opt(build_${gen}, ${fieldName});`, ); } else { - result.push( + ctx.used(`__tact_store_address`); + ctx.append( `build_${gen} = __tact_store_address(build_${gen}, ${fieldName});`, ); } - return result.join("\n"); + return; } case "cell": { switch (op.format) { case "default": { if (op.optional) { - result.push( + ctx.append( `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_ref(${fieldName}) : build_${gen}.store_int(false, 1);`, ); } else { - result.push( + ctx.append( `build_${gen} = build_${gen}.store_ref(${fieldName});`, ); } @@ -171,24 +201,24 @@ function writeSerializerField( if (op.optional) { throw Error("Impossible"); } - result.push( + ctx.append( `build_${gen} = build_${gen}.store_slice(${fieldName}.begin_parse());`, ); } break; } - return result.join("\n"); + return; } case "slice": { switch (op.format) { case "default": { if (op.optional) { - result.push( + ctx.append( `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_ref(begin_cell().store_slice(${fieldName}).end_cell()) : build_${gen}.store_int(false, 1);`, ); } else { - result.push( + ctx.append( `build_${gen} = build_${gen}.store_ref(begin_cell().store_slice(${fieldName}).end_cell());`, ); } @@ -198,23 +228,23 @@ function writeSerializerField( if (op.optional) { throw Error("Impossible"); } - result.push( + ctx.append( `build_${gen} = build_${gen}.store_slice(${fieldName});`, ); } } - return result.join("\n"); + return; } case "builder": { switch (op.format) { case "default": { if (op.optional) { - result.push( + ctx.append( `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_ref(begin_cell().store_slice(${fieldName}.end_cell().begin_parse()).end_cell()) : build_${gen}.store_int(false, 1);`, ); } else { - result.push( + ctx.append( `build_${gen} = build_${gen}.store_ref(begin_cell().store_slice(${fieldName}.end_cell().begin_parse()).end_cell());`, ); } @@ -224,58 +254,56 @@ function writeSerializerField( if (op.optional) { throw Error("Impossible"); } - result.push( + ctx.append( `build_${gen} = build_${gen}.store_slice(${fieldName}.end_cell().begin_parse());`, ); } } - return result.join("\n"); + return; } case "string": { if (op.optional) { - result.push( + ctx.append( `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_ref(begin_cell().store_slice(${fieldName}).end_cell()) : build_${gen}.store_int(false, 1);`, ); } else { - result.push( + ctx.append( `build_${gen} = build_${gen}.store_ref(begin_cell().store_slice(${fieldName}).end_cell());`, ); } - return result.join("\n"); + return; } case "fixed-bytes": { if (op.optional) { - result.push( + ctx.append( `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).store_slice(${fieldName}) : build_${gen}.store_int(false, 1);`, ); } else { - result.push( + ctx.append( `build_${gen} = build_${gen}.store_slice(${fieldName});`, ); } - return result.join("\n"); + return; } case "map": { - result.push( - `build_${gen} = build_${gen}.store_dict(${fieldName});`, - ); - return result.join("\n"); + ctx.append(`build_${gen} = build_${gen}.store_dict(${fieldName});`); + return; } case "struct": { if (op.ref) { throw Error("Not implemented"); } if (op.optional) { - result.push( - `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).${ops.writer(op.type)}(${ops.typeNotNull(op.type)}(${fieldName})) : build_${gen}.store_int(false, 1);`, + ctx.append( + `build_${gen} = ~ null?(${fieldName}) ? build_${gen}.store_int(true, 1).${ops.writer(op.type, ctx)}(${ops.typeNotNull(op.type, ctx)}(${fieldName})) : build_${gen}.store_int(false, 1);`, ); } else { const ff = getType(ctx.ctx, op.type).fields.map((f) => f.abi); - result.push( - `build_${gen} = ${ops.writer(op.type)}(build_${gen}, ${resolveFuncTypeFromAbiUnpack(ctx.ctx, fieldName, ff)});`, + ctx.append( + `build_${gen} = ${ops.writer(op.type, ctx)}(build_${gen}, ${resolveFuncTypeFromAbiUnpack(fieldName, ff, ctx)});`, ); } - return result.join("\n"); + return; } } @@ -290,298 +318,330 @@ export function writeParser( name: string, forceInline: boolean, allocation: StorageAllocation, + origin: ItemOrigin, ctx: WriterContext, ) { const isSmall = allocation.ops.length <= SMALL_STRUCT_MAX_FIELDS; - const parse = (code: string) => - ctx.parse(code, { context: Location.type(name) }); - { - const result = []; - result.push( + ctx.fun(ops.reader(name, ctx), () => { + ctx.signature( `(slice, (${resolveFuncTypeFromAbi( - ctx.ctx, allocation.ops.map((v) => v.type), - )})) ${ops.reader(name)}(slice sc_0) ${forceInline || isSmall ? "inline" : ""} {`, + ctx, + )})) ${ops.reader(name, ctx)}(slice sc_0)`, ); - if (allocation.header) { - result.push(` - throw_unless(${contractErrors.invalidPrefix.id}, sc_0~load_uint(${allocation.header.bits}) == ${allocation.header.value}); - `); + if (forceInline || isSmall) { + ctx.flag("inline"); } - result.push(writeCellParser(allocation.root, 0, ctx)); - if (allocation.ops.length === 0) { - result.push("return (sc_0, null());"); - } else { - result.push(` - return (sc_0, (${allocation.ops.map((v) => `v'${v.name}`).join(", ")})); - `); - } - result.push("}"); - parse(result.join("\n")); - } + ctx.context("type:" + name); + ctx.body(() => { + // Check prefix + if (allocation.header) { + ctx.append( + `throw_unless(${contractErrors.invalidPrefix.id}, sc_0~load_uint(${allocation.header.bits}) == ${allocation.header.value});`, + ); + } + + // Write cell parser + writeCellParser(allocation.root, 0, ctx); + + // Compile tuple + if (allocation.ops.length === 0) { + ctx.append(`return (sc_0, null());`); + } else { + ctx.append( + `return (sc_0, (${allocation.ops.map((v) => `v'${v.name}`).join(", ")}));`, + ); + } + }); + }); // Write non-modifying variant - parse(`${resolveFuncTypeFromAbi( - ctx.ctx, - allocation.ops.map((v) => v.type), - )} ${ops.readerNonModifying(name)}(slice sc_0) ${forceInline || isSmall ? "inline" : ""} { - var r = sc_0~${ops.reader(name)}(); - sc_0.end_parse(); - return r; - }`); + + ctx.fun(ops.readerNonModifying(name, ctx), () => { + ctx.signature( + `(${resolveFuncTypeFromAbi( + allocation.ops.map((v) => v.type), + ctx, + )}) ${ops.readerNonModifying(name, ctx)}(slice sc_0)`, + ); + if (forceInline || isSmall) { + ctx.flag("inline"); + } + ctx.context("type:" + name); + ctx.body(() => { + ctx.append(`var r = sc_0~${ops.reader(name, ctx)}();`); + ctx.append(`sc_0.end_parse();`); + ctx.append(`return r;`); + }); + }); } export function writeBouncedParser( name: string, forceInline: boolean, allocation: StorageAllocation, + origin: ItemOrigin, ctx: WriterContext, ) { const isSmall = allocation.ops.length <= SMALL_STRUCT_MAX_FIELDS; - const parse = (code: string) => - ctx.parse(code, { context: Location.type(name) }); - { - const result = []; - result.push( + ctx.fun(ops.readerBounced(name, ctx), () => { + ctx.signature( `(slice, (${resolveFuncTypeFromAbi( - ctx.ctx, allocation.ops.map((v) => v.type), - )})) ${ops.readerBounced(name)}(slice sc_0) ${forceInline || isSmall ? "inline" : ""} {`, + ctx, + )})) ${ops.readerBounced(name, ctx)}(slice sc_0)`, ); - if (allocation.header) { - result.push( - `throw_unless(${contractErrors.invalidPrefix.id}, sc_0~load_uint(${allocation.header.bits}) == ${allocation.header.value});`, - ); - } - result.push(writeCellParser(allocation.root, 0, ctx)); - if (allocation.ops.length === 0) { - result.push("return (sc_0, null());"); - } else { - result.push( - `return (sc_0, (${allocation.ops.map((v) => `v'${v.name}`).join(", ")}));`, - ); + if (forceInline || isSmall) { + ctx.flag("inline"); } - result.push("}"); - parse(result.join("\n")); - } + ctx.context("type:" + name); + ctx.body(() => { + // Check prefix + if (allocation.header) { + ctx.append( + `throw_unless(${contractErrors.invalidPrefix.id}, sc_0~load_uint(${allocation.header.bits}) == ${allocation.header.value});`, + ); + } + + // Write cell parser + writeCellParser(allocation.root, 0, ctx); + + // Compile tuple + if (allocation.ops.length === 0) { + ctx.append(`return (sc_0, null());`); + } else { + ctx.append( + `return (sc_0, (${allocation.ops.map((v) => `v'${v.name}`).join(", ")}));`, + ); + } + }); + }); } -export function writeOptionalParser(name: string, ctx: WriterContext) { - const parse = (code: string) => - ctx.parse(code, { context: Location.type(name) }); - parse(`tuple ${ops.readerOpt(name)}(cell cl) inline { - if (null?(cl)) { - return null(); - } - var sc = cl.begin_parse(); - return ${ops.typeAsOptional(name)}(sc~${ops.reader(name)}()); - }`); +export function writeOptionalParser( + name: string, + origin: ItemOrigin, + ctx: WriterContext, +) { + ctx.fun(ops.readerOpt(name, ctx), () => { + ctx.signature(`tuple ${ops.readerOpt(name, ctx)}(cell cl)`); + ctx.flag("inline"); + ctx.context("type:" + name); + ctx.body(() => { + ctx.write(` + if (null?(cl)) { + return null(); + } + var sc = cl.begin_parse(); + return ${ops.typeAsOptional(name, ctx)}(sc~${ops.reader(name, ctx)}()); + `); + }); + }); } function writeCellParser( cell: AllocationCell, gen: number, ctx: WriterContext, -): string { - const result: string[] = []; - +): number { // Write current fields for (const f of cell.ops) { - result.push(writeFieldParser(f, gen)); + writeFieldParser(f, gen, ctx); } // Handle next cell if (cell.next) { - result.push( - `slice sc_${gen + 1} = sc_${gen}~load_ref().begin_parse();\n`, - ); - result.push(writeCellParser(cell.next, gen + 1, ctx)); + ctx.append(`slice sc_${gen + 1} = sc_${gen}~load_ref().begin_parse();`); + return writeCellParser(cell.next, gen + 1, ctx); + } else { + return gen; } - - return result.join("\n"); } -function writeFieldParser(f: AllocationOperation, gen: number): string { - const result: string[] = []; +function writeFieldParser( + f: AllocationOperation, + gen: number, + ctx: WriterContext, +) { const op = f.op; const varName = `var v'${f.name}`; switch (op.kind) { case "int": { if (op.optional) { - result.push( + ctx.append( `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_int(${op.bits}) : null();`, ); } else { - result.push(`${varName} = sc_${gen}~load_int(${op.bits});`); + ctx.append(`${varName} = sc_${gen}~load_int(${op.bits});`); } - return result.join("\n"); + return; } case "uint": { if (op.optional) { - result.push( + ctx.append( `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_uint(${op.bits}) : null();`, ); } else { - result.push(`${varName} = sc_${gen}~load_uint(${op.bits});`); + ctx.append(`${varName} = sc_${gen}~load_uint(${op.bits});`); } - return result.join("\n"); + return; } case "coins": { if (op.optional) { - result.push( + ctx.append( `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_coins() : null();`, ); } else { - result.push(`${varName} = sc_${gen}~load_coins();`); + ctx.append(`${varName} = sc_${gen}~load_coins();`); } - return result.join("\n"); + return; } case "boolean": { if (op.optional) { - result.push( + ctx.append( `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_int(1) : null();`, ); } else { - result.push(`${varName} = sc_${gen}~load_int(1);`); + ctx.append(`${varName} = sc_${gen}~load_int(1);`); } - return result.join("\n"); + return; } case "address": { if (op.optional) { - result.push( - `${varName} = sc_${gen}~__tact_load_address_opt();`, - ); + ctx.used(`__tact_load_address_opt`); + ctx.append(`${varName} = sc_${gen}~__tact_load_address_opt();`); } else { - result.push(`${varName} = sc_${gen}~__tact_load_address();`); + ctx.used(`__tact_load_address`); + ctx.append(`${varName} = sc_${gen}~__tact_load_address();`); } - return result.join("\n"); + return; } case "cell": { if (op.optional) { if (op.format !== "default") { throw new Error(`Impossible`); } - result.push( + ctx.append( `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_ref() : null();`, ); } else { switch (op.format) { case "default": { - result.push(`${varName} = sc_${gen}~load_ref();`); + ctx.append(`${varName} = sc_${gen}~load_ref();`); } break; case "remainder": { - result.push( + ctx.append( `${varName} = begin_cell().store_slice(sc_${gen}).end_cell();`, ); } } } - return result.join("\n"); + return; } case "slice": { if (op.optional) { if (op.format !== "default") { throw new Error(`Impossible`); } - result.push( + ctx.append( `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_ref().begin_parse() : null();`, ); } else { switch (op.format) { case "default": { - result.push( + ctx.append( `${varName} = sc_${gen}~load_ref().begin_parse();`, ); } break; case "remainder": { - result.push(`${varName} = sc_${gen};`); + ctx.append(`${varName} = sc_${gen};`); } break; } } - return result.join("\n"); + return; } case "builder": { if (op.optional) { if (op.format !== "default") { throw new Error(`Impossible`); } - result.push( + ctx.append( `${varName} = sc_${gen}~load_int(1) ? begin_cell().store_slice(sc_${gen}~load_ref().begin_parse()) : null();`, ); } else { switch (op.format) { case "default": { - result.push( + ctx.append( `${varName} = begin_cell().store_slice(sc_${gen}~load_ref().begin_parse());`, ); } break; case "remainder": { - result.push( + ctx.append( `${varName} = begin_cell().store_slice(sc_${gen});`, ); } break; } } - return result.join("\n"); + return; } case "string": { if (op.optional) { - result.push( + ctx.append( `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_ref().begin_parse() : null();`, ); } else { - result.push(`${varName} = sc_${gen}~load_ref().begin_parse();`); + ctx.append(`${varName} = sc_${gen}~load_ref().begin_parse();`); } - return result.join("\n"); + return; } case "fixed-bytes": { if (op.optional) { - result.push( + ctx.append( `${varName} = sc_${gen}~load_int(1) ? sc_${gen}~load_bits(${op.bytes * 8}) : null();`, ); } else { - result.push( + ctx.append( `${varName} = sc_${gen}~load_bits(${op.bytes * 8});`, ); } - return result.join("\n"); + return; } case "map": { - result.push(`${varName} = sc_${gen}~load_dict();`); - return result.join("\n"); + ctx.append(`${varName} = sc_${gen}~load_dict();`); + return; } case "struct": { if (op.optional) { if (op.ref) { throw Error("Not implemented"); } else { - result.push( - `${varName} = sc_${gen}~load_int(1) ? ${ops.typeAsOptional(op.type)}(sc_${gen}~${ops.reader(op.type)}()) : null();`, + ctx.append( + `${varName} = sc_${gen}~load_int(1) ? ${ops.typeAsOptional(op.type, ctx)}(sc_${gen}~${ops.reader(op.type, ctx)}()) : null();`, ); } } else { if (op.ref) { throw Error("Not implemented"); } else { - result.push( - `${varName} = sc_${gen}~${ops.reader(op.type)}();`, + ctx.append( + `${varName} = sc_${gen}~${ops.reader(op.type, ctx)}();`, ); } } - return result.join("\n"); + return; } } } diff --git a/src/codegen/stdlib.ts b/src/generatorNew/writers/writeStdlib.ts similarity index 99% rename from src/codegen/stdlib.ts rename to src/generatorNew/writers/writeStdlib.ts index fde94ea45..7d563f8c6 100644 --- a/src/codegen/stdlib.ts +++ b/src/generatorNew/writers/writeStdlib.ts @@ -1,10 +1,10 @@ -import { WriterContext, Location } from "./context"; -import { contractErrors } from "../abi/errors"; -import { enabledMasterchain } from "../config/features"; +import { WriterContext } from "../Writer"; +import { contractErrors } from "../../abi/errors"; +import { enabledMasterchain } from "../../config/features"; -export function writeStdlib(ctx: WriterContext) { +export function writeStdlib(ctx: WriterContext): void { const parse = (code: string) => - ctx.parse(code, { context: Location.stdlib() }); + ctx.parse(code, { context: "stdlib" }); // // stdlib extension functions @@ -21,7 +21,7 @@ export function writeStdlib(ctx: WriterContext) { // parse( - `slice __tact_verify_address(slice address) inline { + `slice __tact_verify_address(slice address) impure inline { throw_unless(${contractErrors.invalidAddress.id}, address.slice_bits() == 267); var h = address.preload_uint(11); diff --git a/src/pipeline/compile.ts b/src/pipeline/compile.ts index f30c25b8c..41cae3827 100644 --- a/src/pipeline/compile.ts +++ b/src/pipeline/compile.ts @@ -1,7 +1,7 @@ import { CompilerContext } from "../context"; import { createABI } from "../generator/createABI"; import { writeProgram } from "../generator/writeProgram"; -import { FuncGenerator } from "../codegen"; +import { writeProgram as writeProgramNew } from "../generatorNew/writeProgram"; export type CompilationOutput = { entrypoint: string; @@ -36,14 +36,11 @@ export async function compile( ): Promise { const abi = createABI(ctx, contractName); let output: CompilationOutput; + const debug = process.env.DEBUG === "1"; if (backend === "new" || process.env.NEW_CODEGEN === "1") { - output = await FuncGenerator.fromTactProject( - ctx, - abi, - abiName, - ).writeProgram(); + output = await writeProgramNew(ctx, abi, abiName, debug); } else { - output = await writeProgram(ctx, abi, abiName); + output = await writeProgram(ctx, abi, abiName, debug); } if (process.env.PRINT_FUNC === "1") { printOutput(contractName, output); diff --git a/src/test/new-codegen/codegen.spec.ts b/src/test/new-codegen/codegen.spec.ts new file mode 100644 index 000000000..908c30c7b --- /dev/null +++ b/src/test/new-codegen/codegen.spec.ts @@ -0,0 +1,171 @@ +import { __DANGER_resetNodeId } from "../../grammar/ast"; +import { compile } from "../../pipeline/compile"; +import { precompile } from "../../pipeline/precompile"; +import { getContracts } from "../../types/resolveDescriptors"; +import { CompilationOutput, CompilationResults } from "../../pipeline/compile"; +import { createNodeFileSystem } from "../../vfs/createNodeFileSystem"; +import { CompilerContext } from "../../context"; +import * as fs from "fs"; +import * as path from "path"; + +const CONTRACTS_DIR = path.join(__dirname, "./contracts/"); + +function capitalize(str: string): string { + if (str.length === 0) return str; + return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); +} + +/** + * Generates a Tact configuration file for the given contract (imported from Misti). + */ +export function generateConfig(contractName: string): string { + const config = { + projects: [ + { + name: `${contractName}`, + path: `./${contractName}.tact`, + output: `./output`, + options: {}, + }, + ], + }; + const configPath = path.join(CONTRACTS_DIR, `${contractName}.config.json`); + fs.writeFileSync(configPath, JSON.stringify(config), { + encoding: "utf8", + flag: "w", + }); + return configPath; +} + +/** + * Compiles the contract on the given filepath to CompilationResults replicating the Tact compiler pipeline. + */ +async function compileContract( + backend: "new" | "old", + contractName: string, +): Promise { + generateConfig(contractName); + + // see: pipeline/build.ts + const project = createNodeFileSystem(CONTRACTS_DIR, false); + const stdlib = createNodeFileSystem( + path.resolve(__dirname, "..", "..", "..", "stdlib"), + false, + ); + let ctx: CompilerContext = new CompilerContext(); + ctx = precompile(ctx, project, stdlib, contractName); + + return await Promise.all( + getContracts(ctx).map(async (contract) => { + const res = await compile( + ctx, + contract, + `${contractName}_${contract}`, + backend, + ); + return res; + }), + ); +} + +function compareCompilationOutputs( + newOut: CompilationOutput, + oldOut: CompilationOutput, +): void { + const errors: string[] = []; + + if (newOut === undefined || oldOut === undefined) { + errors.push("One of the outputs is undefined."); + } else { + try { + expect(newOut.entrypoint).toBe(oldOut.entrypoint); + } catch (error) { + if (error instanceof Error) { + errors.push(`Entrypoint mismatch: ${error.message}`); + } else { + errors.push(`Entrypoint mismatch: ${String(error)}`); + } + } + + try { + expect(newOut.abi).toBe(oldOut.abi); + } catch (error) { + if (error instanceof Error) { + errors.push(`ABI mismatch: ${error.message}`); + } else { + errors.push(`ABI mismatch: ${String(error)}`); + } + } + + const unmatchedFiles = new Set(oldOut.files.map((file) => file.name)); + + for (const newFile of newOut.files) { + const oldFile = oldOut.files.find( + (file) => file.name === newFile.name, + ); + if (oldFile) { + unmatchedFiles.delete(oldFile.name); + try { + expect(newFile.code).toBe(oldFile.code); + } catch (error) { + if (error instanceof Error) { + errors.push( + `Code mismatch in file ${newFile.name}: ${error.message}`, + ); + } else { + errors.push( + `Code mismatch in file ${newFile.name}: ${String(error)}`, + ); + } + } + } else { + errors.push( + `File ${newFile.name} is missing in the old output.`, + ); + } + } + + for (const missingFile of unmatchedFiles) { + errors.push(`File ${missingFile} is missing in the new output.`); + } + } + + if (errors.length > 0) { + throw new Error(errors.join("\n")); + } +} + +describe("codegen", () => { + beforeEach(async () => { + __DANGER_resetNodeId(); + }); + + fs.readdirSync(CONTRACTS_DIR).forEach((file) => { + if (!file.endsWith(".tact")) { + return; + } + const contractName = capitalize(file); + // Differential tests with the old backend + it(`Should compile the ${file} contract`, async () => { + Promise.all([ + compileContract("new", contractName), + compileContract("old", contractName), + ]) + .then(([resultsNew, resultsOld]) => { + if (resultsNew.length !== resultsOld.length) { + throw new Error("Not all contracts have been compiled"); + } + const zipped = resultsNew.map((value, idx) => [ + value, + resultsOld[idx], + ]); + zipped.forEach(([newRes, oldRes]) => { + expect(() => compareCompilationOutputs( + newRes!.output, + oldRes!.output, + )).not.toThrow(); + }); + }) + }); + }); +}); diff --git a/src/test/new-codegen/contracts/Simple.tact b/src/test/new-codegen/contracts/Simple.tact new file mode 100644 index 000000000..4e06edb30 --- /dev/null +++ b/src/test/new-codegen/contracts/Simple.tact @@ -0,0 +1,5 @@ +contract A { + get fun foo(): Int { + return 1; + } +} diff --git a/src/test/new-codegen/contracts/Simple.tact.config.json b/src/test/new-codegen/contracts/Simple.tact.config.json new file mode 100644 index 000000000..d5e4321f2 --- /dev/null +++ b/src/test/new-codegen/contracts/Simple.tact.config.json @@ -0,0 +1 @@ +{"projects":[{"name":"Simple.tact","path":"./Simple.tact","output":"./output","options":{}}]} From f79211167ed3eb9617f00565f3f98de4e29bf65b Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 11 Sep 2024 11:32:47 +0000 Subject: [PATCH 147/162] fix(codegen): Remove extra attributes --- src/generatorNew/emitter/emit.ts | 4 +++- src/generatorNew/writeProgram.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/generatorNew/emitter/emit.ts b/src/generatorNew/emitter/emit.ts index b445083c6..a3d3087c7 100644 --- a/src/generatorNew/emitter/emit.ts +++ b/src/generatorNew/emitter/emit.ts @@ -29,6 +29,7 @@ export function emit(args: { } if (f.code.kind === "generic") { let sig = f.signature; + if (!f.parsed) { if (f.flags.has("impure")) { sig = `${sig} impure`; } @@ -37,11 +38,12 @@ export function emit(args: { } else { sig = `${sig} inline_ref`; } + } res += `${sig} {\n${createPadded(f.code.code)}\n}`; } else if (f.code.kind === "asm") { let sig = f.signature; - if (f.flags.has("impure")) { + if (!f.parsed && f.flags.has("impure")) { sig = `${sig} impure`; } res += `${sig} asm${f.code.shuffle} "${f.code.code}";`; diff --git a/src/generatorNew/writeProgram.ts b/src/generatorNew/writeProgram.ts index 51acceea6..02d8a4472 100644 --- a/src/generatorNew/writeProgram.ts +++ b/src/generatorNew/writeProgram.ts @@ -72,6 +72,7 @@ export async function writeProgram( if (f.code.kind === "generic" && f.signature) { headers.push(`;; ${f.name}`); let sig = f.signature; + if (!f.parsed) { if (f.flags.has("impure")) { sig = sig + " impure"; } @@ -80,6 +81,7 @@ export async function writeProgram( } else { sig = sig + " inline_ref"; } + } headers.push(sig + ";"); headers.push(""); } From a3b287788d72528a49e962d0c6d64bf861acaf0f Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 11 Sep 2024 11:33:50 +0000 Subject: [PATCH 148/162] chore(codegen): Roll-back porting `writeStdlib` because of FunC parser erorrs --- src/generatorNew/writers/writeStdlib.ts | 3014 ++++++++++++++--------- 1 file changed, 1899 insertions(+), 1115 deletions(-) diff --git a/src/generatorNew/writers/writeStdlib.ts b/src/generatorNew/writers/writeStdlib.ts index 7d563f8c6..8872dbcd3 100644 --- a/src/generatorNew/writers/writeStdlib.ts +++ b/src/generatorNew/writers/writeStdlib.ts @@ -1,15 +1,13 @@ -import { WriterContext } from "../Writer"; import { contractErrors } from "../../abi/errors"; +import { maxTupleSize } from "../../bindings/typescript/writeStruct"; import { enabledMasterchain } from "../../config/features"; +import { WriterContext } from "../Writer"; -export function writeStdlib(ctx: WriterContext): void { - const parse = (code: string) => - ctx.parse(code, { context: "stdlib" }); - +export function writeStdlib(ctx: WriterContext) { // // stdlib extension functions // - // + ctx.skip("__tact_set"); ctx.skip("__tact_nop"); ctx.skip("__tact_str_to_slice"); @@ -20,1207 +18,1993 @@ export function writeStdlib(ctx: WriterContext): void { // Addresses // - parse( - `slice __tact_verify_address(slice address) impure inline { - throw_unless(${contractErrors.invalidAddress.id}, address.slice_bits() == 267); - var h = address.preload_uint(11); - - ${ - enabledMasterchain(ctx.ctx) - ? ` - throw_unless(${contractErrors.invalidAddress.id}, (h == 1024) | (h == 1279)); - ` - : ` - throw_if(${contractErrors.masterchainNotEnabled.id}, h == 1279); - throw_unless(${contractErrors.invalidAddress.id}, h == 1024); - ` - } - - return address; - }`, - ); - - parse(`(slice, int) __tact_load_bool(slice s) asm(s -> 1 0) "1 LDI";`); - - parse( - `(slice, slice) __tact_load_address(slice cs) inline { - slice raw = cs~load_msg_addr(); - return (cs, __tact_verify_address(raw)); - }`, - ); - - parse( - `(slice, slice) __tact_load_address_opt(slice cs) inline { - if (cs.preload_uint(2) != 0) { - slice raw = cs~load_msg_addr(); - return (cs, __tact_verify_address(raw)); - } else { - cs~skip_bits(2); - return (cs, null()); - } - }`, - ); - - parse( - `builder __tact_store_address(builder b, slice address) inline { - return b.store_slice(__tact_verify_address(address)); - }`, - ); - - parse( - `builder __tact_store_address_opt(builder b, slice address) inline { - if (null?(address)) { - b = b.store_uint(0, 2); - return b; - } else { - return __tact_store_address(b, address); - } - }`, - ); - - parse( - `slice __tact_create_address(int chain, int hash) inline { - var b = begin_cell(); - b = b.store_uint(2, 2); - b = b.store_uint(0, 1); - b = b.store_int(chain, 8); - b = b.store_uint(hash, 256); - var addr = b.end_cell().begin_parse(); - return __tact_verify_address(addr); - }`, - ); - - parse( - `slice __tact_compute_contract_address(int chain, cell code, cell data) inline { - var b = begin_cell(); - b = b.store_uint(0, 2); - b = b.store_uint(3, 2); - b = b.store_uint(0, 1); - b = b.store_ref(code); - b = b.store_ref(data); - var hash = cell_hash(b.end_cell()); - return __tact_create_address(chain, hash); - }`, - ); - - parse( - `int __tact_my_balance() inline { - return pair_first(get_balance()); - }`, - ); - - parse( - `forall X -> X __tact_not_null(X x) inline { - throw_if(${contractErrors.null.id}, null?(x)); - return x; - }`, - ); - - parse( - `(cell, int) __tact_dict_delete(cell dict, int key_len, slice index) asm(index dict key_len) "DICTDEL";`, - ); - - parse( - `(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL";`, - ); - - parse( - `(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL";`, - ); - - parse( - `((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value) asm(value index dict key_len) "DICTSETREF";`, - ); - - parse( - `(slice, int) __tact_dict_get(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGET" "NULLSWAPIFNOT";`, - ); - - parse( - `(cell, int) __tact_dict_get_ref(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGETREF" "NULLSWAPIFNOT";`, - ); - - parse( - `(slice, slice, int) __tact_dict_min(cell dict, int key_len) asm(dict key_len -> 1 0 2) "DICTMIN" "NULLSWAPIFNOT2";`, - ); - - parse( - `(slice, cell, int) __tact_dict_min_ref(cell dict, int key_len) asm(dict key_len -> 1 0 2) "DICTMINREF" "NULLSWAPIFNOT2";`, - ); - - parse( - `(slice, slice, int) __tact_dict_next(cell dict, int key_len, slice pivot) asm(pivot dict key_len -> 1 0 2) "DICTGETNEXT" "NULLSWAPIFNOT2";`, - ); - - parse( - `(slice, cell, int) __tact_dict_next_ref(cell dict, int key_len, slice pivot) inline { - var (key, value, flag) = __tact_dict_next(dict, key_len, pivot); - if (flag) { - return (key, value~load_ref(), flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `forall X -> () __tact_debug(X value, slice debug_print) impure asm "STRDUMP" "DROP" "s0 DUMP" "DROP";`, - ); - - parse( - `() __tact_debug_str(slice value, slice debug_print) impure asm "STRDUMP" "DROP" "STRDUMP" "DROP";`, - ); - - parse( - `() __tact_debug_bool(int value, slice debug_print) impure { - if (value) { - __tact_debug_str("true", debug_print); - } else { - __tact_debug_str("false", debug_print); - } - }`, - ); - - parse( - `(slice) __tact_preload_offset(slice s, int offset, int bits) inline asm "SDSUBSTR";`, - ); - - parse( - `(slice) __tact_crc16(slice data) inline_ref { - slice new_data = begin_cell() - .store_slice(data) - .store_slice("0000"s) - .end_cell().begin_parse(); - int reg = 0; - while (~new_data.slice_data_empty?()) { - int byte = new_data~load_uint(8); - int mask = 0x80; - while (mask > 0) { - reg <<= 1; - if (byte & mask) { - reg += 1; - } - mask >>= 1; - if (reg > 0xffff) { - reg &= 0xffff; - reg ^= 0x1021; - } + ctx.fun("__tact_verify_address", () => { + ctx.signature(`slice __tact_verify_address(slice address)`); + ctx.flag("impure"); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + throw_unless(${contractErrors.invalidAddress.id}, address.slice_bits() == 267); + var h = address.preload_uint(11); + `); + + if (enabledMasterchain(ctx.ctx)) { + ctx.write(` + throw_unless(${contractErrors.invalidAddress.id}, (h == 1024) | (h == 1279)); + `); + } else { + ctx.write(` + throw_if(${contractErrors.masterchainNotEnabled.id}, h == 1279); + throw_unless(${contractErrors.invalidAddress.id}, h == 1024); + `); } - } - (int q, int r) = divmod(reg, 256); - return begin_cell() - .store_uint(q, 8) - .store_uint(r, 8) - .end_cell().begin_parse(); - }`, - ); - - parse( - `(slice) __tact_base64_encode(slice data) inline { - slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; - builder res = begin_cell(); - - while (data.slice_bits() >= 24) { - (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); - - int n = (bs1 << 16) | (bs2 << 8) | bs3; - - res = res - .store_slice(__tact_preload_offset(chars, ((n >> 18) & 63) * 8, 8)) - .store_slice(__tact_preload_offset(chars, ((n >> 12) & 63) * 8, 8)) - .store_slice(__tact_preload_offset(chars, ((n >> 6) & 63) * 8, 8)) - .store_slice(__tact_preload_offset(chars, ((n ) & 63) * 8, 8)); - } - - return res.end_cell().begin_parse(); - }`, - ); - - parse( - `(slice) __tact_address_to_user_friendly(slice address) inline { - (int wc, int hash) = address.parse_std_addr(); - - slice user_friendly_address = begin_cell() - .store_slice("11"s) - .store_uint((wc + 0x100) % 0x100, 8) - .store_uint(hash, 256) - .end_cell().begin_parse(); - - slice checksum = __tact_crc16(user_friendly_address); - slice user_friendly_address_with_checksum = begin_cell() - .store_slice(user_friendly_address) - .store_slice(checksum) - .end_cell().begin_parse(); - - return __tact_base64_encode(user_friendly_address_with_checksum); - }`, - ); - - parse( - `() __tact_debug_address(slice address, slice debug_print) impure { - __tact_debug_str(__tact_address_to_user_friendly(address), debug_print); - }`, - ); - - parse( - `() __tact_debug_stack(slice debug_print) impure asm "STRDUMP" "DROP" "DUMPSTK";`, - ); - - parse( - `(int, slice, int, slice) __tact_context_get() inline { - return __tact_context; - }`, - ); - - parse( - `slice __tact_context_get_sender() inline { - return __tact_context_sender; - }`, - ); - - parse( - `() __tact_prepare_random() impure inline { - if (null?(__tact_randomized)) { - randomize_lt(); - __tact_randomized = true; - } - }`, - ); - - parse( - `builder __tact_store_bool(builder b, int v) inline { - return b.store_int(v, 1); - }`, - ); - - parse(`forall X -> tuple __tact_to_tuple(X x) asm "NOP";`); - - parse(`forall X -> X __tact_from_tuple(tuple x) asm "NOP";`); + ctx.write(` + return address; + `); + }); + }); + + ctx.fun("__tact_load_address", () => { + ctx.signature(`(slice, slice) __tact_load_address(slice cs)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + slice raw = cs~load_msg_addr(); + return (cs, ${ctx.used(`__tact_verify_address`)}(raw)); + `); + }); + }); + + ctx.fun("__tact_load_address_opt", () => { + ctx.signature(`(slice, slice) __tact_load_address_opt(slice cs)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (cs.preload_uint(2) != 0) { + slice raw = cs~load_msg_addr(); + return (cs, ${ctx.used(`__tact_verify_address`)}(raw)); + } else { + cs~skip_bits(2); + return (cs, null()); + } + `); + }); + }); + + ctx.fun("__tact_store_address", () => { + ctx.signature(`builder __tact_store_address(builder b, slice address)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return b.store_slice(${ctx.used(`__tact_verify_address`)}(address)); + `); + }); + }); + + ctx.fun("__tact_store_address_opt", () => { + ctx.signature( + `builder __tact_store_address_opt(builder b, slice address)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(address)) { + b = b.store_uint(0, 2); + return b; + } else { + return ${ctx.used(`__tact_store_address`)}(b, address); + } + `); + }); + }); + + ctx.fun("__tact_create_address", () => { + ctx.signature(`slice __tact_create_address(int chain, int hash)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var b = begin_cell(); + b = b.store_uint(2, 2); + b = b.store_uint(0, 1); + b = b.store_int(chain, 8); + b = b.store_uint(hash, 256); + var addr = b.end_cell().begin_parse(); + return ${ctx.used(`__tact_verify_address`)}(addr); + `); + }); + }); + + ctx.fun("__tact_compute_contract_address", () => { + ctx.signature( + `slice __tact_compute_contract_address(int chain, cell code, cell data)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var b = begin_cell(); + b = b.store_uint(0, 2); + b = b.store_uint(3, 2); + b = b.store_uint(0, 1); + b = b.store_ref(code); + b = b.store_ref(data); + var hash = cell_hash(b.end_cell()); + return ${ctx.used(`__tact_create_address`)}(chain, hash); + `); + }); + }); + + ctx.fun("__tact_not_null", () => { + ctx.signature(`forall X -> X __tact_not_null(X x)`); + ctx.flag("impure"); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write( + `throw_if(${contractErrors.null.id}, null?(x)); return x;`, + ); + }); + }); + + ctx.fun("__tact_dict_delete", () => { + ctx.signature( + `(cell, int) __tact_dict_delete(cell dict, int key_len, slice index)`, + ); + ctx.context("stdlib"); + ctx.asm("(index dict key_len)", "DICTDEL"); + }); + + ctx.fun("__tact_dict_delete_int", () => { + ctx.signature( + `(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index)`, + ); + ctx.context("stdlib"); + ctx.asm("(index dict key_len)", "DICTIDEL"); + }); + + ctx.fun("__tact_dict_delete_uint", () => { + ctx.signature( + `(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index)`, + ); + ctx.context("stdlib"); + ctx.asm("(index dict key_len)", "DICTUDEL"); + }); + + ctx.fun("__tact_dict_set_ref", () => { + ctx.signature( + `((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value)`, + ); + ctx.context("stdlib"); + ctx.asm("(value index dict key_len)", "DICTSETREF"); + }); + + ctx.fun("__tact_dict_get", () => { + ctx.signature( + `(slice, int) __tact_dict_get(cell dict, int key_len, slice index)`, + ); + ctx.context("stdlib"); + ctx.asm("(index dict key_len)", "DICTGET NULLSWAPIFNOT"); + }); + + ctx.fun("__tact_dict_delete_get", () => { + ctx.signature( + `(cell, (slice, int)) __tact_dict_delete_get(cell dict, int key_len, slice index)`, + ); + ctx.context("stdlib"); + ctx.asm("(index dict key_len)", "DICTDELGET NULLSWAPIFNOT2"); + }); + + ctx.fun("__tact_dict_get_ref", () => { + ctx.signature( + `(cell, int) __tact_dict_get_ref(cell dict, int key_len, slice index)`, + ); + ctx.context("stdlib"); + ctx.asm("(index dict key_len)", "DICTGETREF NULLSWAPIFNOT"); + }); + + ctx.fun("__tact_dict_min", () => { + ctx.signature( + `(slice, slice, int) __tact_dict_min(cell dict, int key_len)`, + ); + ctx.context("stdlib"); + ctx.asm("(dict key_len -> 1 0 2)", "DICTMIN NULLSWAPIFNOT2"); + }); + + ctx.fun("__tact_dict_min_ref", () => { + ctx.signature( + `(slice, cell, int) __tact_dict_min_ref(cell dict, int key_len)`, + ); + ctx.context("stdlib"); + ctx.asm("(dict key_len -> 1 0 2)", "DICTMINREF NULLSWAPIFNOT2"); + }); + + ctx.fun("__tact_dict_next", () => { + ctx.signature( + `(slice, slice, int) __tact_dict_next(cell dict, int key_len, slice pivot)`, + ); + ctx.context("stdlib"); + ctx.asm("(pivot dict key_len -> 1 0 2)", "DICTGETNEXT NULLSWAPIFNOT2"); + }); + + ctx.fun("__tact_dict_next_ref", () => { + ctx.signature( + `(slice, cell, int) __tact_dict_next_ref(cell dict, int key_len, slice pivot)`, + ); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = ${ctx.used("__tact_dict_next")}(dict, key_len, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_debug", () => { + ctx.signature( + `forall X -> () __tact_debug(X value, slice debug_print_1, slice debug_print_2)`, + ); + ctx.flag("impure"); + ctx.context("stdlib"); + ctx.asm("", "STRDUMP DROP STRDUMP DROP s0 DUMP DROP"); + }); + + ctx.fun("__tact_debug_str", () => { + ctx.signature( + `() __tact_debug_str(slice value, slice debug_print_1, slice debug_print_2)`, + ); + ctx.flag("impure"); + ctx.context("stdlib"); + ctx.asm("", "STRDUMP DROP STRDUMP DROP STRDUMP DROP"); + }); + + ctx.fun("__tact_debug_bool", () => { + ctx.signature( + `() __tact_debug_bool(int value, slice debug_print_1, slice debug_print_2)`, + ); + ctx.flag("impure"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (value) { + ${ctx.used("__tact_debug_str")}("true", debug_print_1, debug_print_2); + } else { + ${ctx.used("__tact_debug_str")}("false", debug_print_1, debug_print_2); + } + `); + }); + }); + + ctx.fun("__tact_preload_offset", () => { + ctx.signature( + `(slice) __tact_preload_offset(slice s, int offset, int bits)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.asm("", "SDSUBSTR"); + }); + + ctx.fun("__tact_crc16", () => { + ctx.signature(`(slice) __tact_crc16(slice data)`); + ctx.flag("inline_ref"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + slice new_data = begin_cell() + .store_slice(data) + .store_slice("0000"s) + .end_cell().begin_parse(); + int reg = 0; + while (~ new_data.slice_data_empty?()) { + int byte = new_data~load_uint(8); + int mask = 0x80; + while (mask > 0) { + reg <<= 1; + if (byte & mask) { + reg += 1; + } + mask >>= 1; + if (reg > 0xffff) { + reg &= 0xffff; + reg ^= 0x1021; + } + } + } + (int q, int r) = divmod(reg, 256); + return begin_cell() + .store_uint(q, 8) + .store_uint(r, 8) + .end_cell().begin_parse(); + `); + }); + }); + + ctx.fun("__tact_base64_encode", () => { + ctx.signature(`(slice) __tact_base64_encode(slice data)`); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; + builder res = begin_cell(); + + while (data.slice_bits() >= 24) { + (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); + + int n = (bs1 << 16) | (bs2 << 8) | bs3; + + res = res + .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 18) & 63) * 8, 8)) + .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 12) & 63) * 8, 8)) + .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 6) & 63) * 8, 8)) + .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n ) & 63) * 8, 8)); + } + + return res.end_cell().begin_parse(); + `); + }); + }); + + ctx.fun("__tact_address_to_user_friendly", () => { + ctx.signature(`(slice) __tact_address_to_user_friendly(slice address)`); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + (int wc, int hash) = address.parse_std_addr(); + + slice user_friendly_address = begin_cell() + .store_slice("11"s) + .store_uint((wc + 0x100) % 0x100, 8) + .store_uint(hash, 256) + .end_cell().begin_parse(); + + slice checksum = ${ctx.used("__tact_crc16")}(user_friendly_address); + slice user_friendly_address_with_checksum = begin_cell() + .store_slice(user_friendly_address) + .store_slice(checksum) + .end_cell().begin_parse(); + + return ${ctx.used("__tact_base64_encode")}(user_friendly_address_with_checksum); + `); + }); + }); + + ctx.fun("__tact_debug_address", () => { + ctx.signature( + `() __tact_debug_address(slice address, slice debug_print_1, slice debug_print_2)`, + ); + ctx.flag("impure"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + ${ctx.used("__tact_debug_str")}(${ctx.used("__tact_address_to_user_friendly")}(address), debug_print_1, debug_print_2); + `); + }); + }); + + ctx.fun("__tact_debug_stack", () => { + ctx.signature( + `() __tact_debug_stack(slice debug_print_1, slice debug_print_2)`, + ); + ctx.flag("impure"); + ctx.context("stdlib"); + ctx.asm("", "STRDUMP DROP STRDUMP DROP DUMPSTK"); + }); + + ctx.fun("__tact_context_get", () => { + ctx.signature(`(int, slice, int, slice) __tact_context_get()`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(`return __tact_context;`); + }); + }); + + ctx.fun("__tact_context_get_sender", () => { + ctx.signature(`slice __tact_context_get_sender()`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(`return __tact_context_sender;`); + }); + }); + + ctx.fun("__tact_prepare_random", () => { + ctx.signature(`() __tact_prepare_random()`); + ctx.flag("impure"); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(__tact_randomized)) { + randomize_lt(); + __tact_randomized = true; + } + `); + }); + }); + + ctx.fun("__tact_store_bool", () => { + ctx.signature(`builder __tact_store_bool(builder b, int v)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return b.store_int(v, 1); + `); + }); + }); + + ctx.fun("__tact_to_tuple", () => { + ctx.signature(`forall X -> tuple __tact_to_tuple(X x)`); + ctx.context("stdlib"); + ctx.asm("", "NOP"); + }); + + ctx.fun("__tact_from_tuple", () => { + ctx.signature(`forall X -> X __tact_from_tuple(tuple x)`); + ctx.context("stdlib"); + ctx.asm("", "NOP"); + }); + + // + // Dict Int -> Int + // + + ctx.fun("__tact_dict_set_int_int", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_int_int", () => { + ctx.signature( + `int __tact_dict_get_int_int(cell d, int kl, int k, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = idict_get?(d, kl, k); + if (ok) { + return r~load_int(vl); + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_int_int", () => { + ctx.signature( + `(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = idict_get_min?(d, kl); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_int_int", () => { + ctx.signature( + `(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Int -> Int // - parse( - `(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl) inline { - if (null?(v)) { - var (r, ok) = idict_delete?(d, kl, k); - return (r, ()); - } else { - return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); - } - }`, - ); - - parse( - `int __tact_dict_get_int_int(cell d, int kl, int k, int vl) inline { - var (r, ok) = idict_get?(d, kl, k); - if (ok) { - return r~load_int(vl); - } else { - return null(); - } - }`, - ); - - parse( - `(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl) inline { - var (key, value, flag) = idict_get_min?(d, kl); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl) inline { - var (key, value, flag) = idict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_int_uint", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_int_uint(cell d, int kl, int k, int v, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_int_uint", () => { + ctx.signature( + `int __tact_dict_get_int_uint(cell d, int kl, int k, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = idict_get?(d, kl, k); + if (ok) { + return r~load_uint(vl); + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_int_uint", () => { + ctx.signature( + `(int, int, int) __tact_dict_min_int_uint(cell d, int kl, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = idict_get_min?(d, kl); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_int_uint", () => { + ctx.signature( + `(int, int, int) __tact_dict_next_int_uint(cell d, int kl, int pivot, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // - // Dict Int -> Uint + // Dict Uint -> Int // - parse( - `(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl) inline { - if (null?(v)) { - var (r, ok) = udict_delete?(d, kl, k); - return (r, ()); - } else { - return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); - } - }`, - ); - - parse( - `int __tact_dict_get_uint_int(cell d, int kl, int k, int vl) inline { - var (r, ok) = udict_get?(d, kl, k); - if (ok) { - return r~load_int(vl); - } else { - return null(); - } - }`, - ); - - parse( - `(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl) inline { - var (key, value, flag) = udict_get_min?(d, kl); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl) inline { - var (key, value, flag) = udict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_uint_int", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_uint_int", () => { + ctx.signature( + `int __tact_dict_get_uint_int(cell d, int kl, int k, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = udict_get?(d, kl, k); + if (ok) { + return r~load_int(vl); + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_uint_int", () => { + ctx.signature( + `(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = udict_get_min?(d, kl); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_uint_int", () => { + ctx.signature( + `(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Uint -> Uint // - parse( - `(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl) inline { - if (null?(v)) { - var (r, ok) = udict_delete?(d, kl, k); - return (r, ()); - } else { - return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); - } - }`, - ); - - parse( - `int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl) inline { - var (r, ok) = udict_get?(d, kl, k); - if (ok) { - return r~load_uint(vl); - } else { - return null(); - } - }`, - ); - - parse( - `(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl) inline { - var (key, value, flag) = udict_get_min?(d, kl); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl) inline { - var (key, value, flag) = udict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_uint_uint", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_uint_uint", () => { + ctx.signature( + `int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = udict_get?(d, kl, k); + if (ok) { + return r~load_uint(vl); + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_uint_uint", () => { + ctx.signature( + `(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = udict_get_min?(d, kl); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_uint_uint", () => { + ctx.signature( + `(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Int -> Cell // - parse( - `(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v) inline { - if (null?(v)) { - var (r, ok) = idict_delete?(d, kl, k); - return (r, ()); - } else { - return (idict_set_ref(d, kl, k, v), ()); - } - }`, - ); - - parse( - `cell __tact_dict_get_int_cell(cell d, int kl, int k) inline { - var (r, ok) = idict_get_ref?(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - }`, - ); - - parse( - `(int, cell, int) __tact_dict_min_int_cell(cell d, int kl) inline { - var (key, value, flag) = idict_get_min_ref?(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot) inline { - var (key, value, flag) = idict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_ref(), flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_int_cell", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set_ref(d, kl, k, v), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_int_cell", () => { + ctx.signature(`cell __tact_dict_get_int_cell(cell d, int kl, int k)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = idict_get_ref?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_int_cell", () => { + ctx.signature( + `(int, cell, int) __tact_dict_min_int_cell(cell d, int kl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = idict_get_min_ref?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_int_cell", () => { + ctx.signature( + `(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Uint -> Cell // - parse( - `(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v) inline { - if (null?(v)) { - var (r, ok) = udict_delete?(d, kl, k); - return (r, ()); - } else { - return (udict_set_ref(d, kl, k, v), ()); - } - }`, - ); - - parse( - `cell __tact_dict_get_uint_cell(cell d, int kl, int k) inline { - var (r, ok) = udict_get_ref?(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - }`, - ); - - parse( - `(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl) inline { - var (key, value, flag) = udict_get_min_ref?(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot) inline { - var (key, value, flag) = udict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_ref(), flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_uint_cell", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set_ref(d, kl, k, v), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_uint_cell", () => { + ctx.signature(`cell __tact_dict_get_uint_cell(cell d, int kl, int k)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = udict_get_ref?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_uint_cell", () => { + ctx.signature( + `(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = udict_get_min_ref?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_uint_cell", () => { + ctx.signature( + `(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Int -> Slice // - parse( - `(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v) inline { - if (null?(v)) { - var (r, ok) = idict_delete?(d, kl, k); - return (r, ()); - } else { - return (idict_set(d, kl, k, v), ()); - } - }`, - ); - - parse( - `slice __tact_dict_get_int_slice(cell d, int kl, int k) inline { - var (r, ok) = idict_get?(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - }`, - ); - - parse( - `(int, slice, int) __tact_dict_min_int_slice(cell d, int kl) inline { - var (key, value, flag) = idict_get_min?(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot) inline { - var (key, value, flag) = idict_get_next?(d, kl, pivot); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_int_slice", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set(d, kl, k, v), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_int_slice", () => { + ctx.signature(`slice __tact_dict_get_int_slice(cell d, int kl, int k)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = idict_get?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_int_slice", () => { + ctx.signature( + `(int, slice, int) __tact_dict_min_int_slice(cell d, int kl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = idict_get_min?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_int_slice", () => { + ctx.signature( + `(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Uint -> Slice // - parse( - `(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v) inline { - if (null?(v)) { - var (r, ok) = udict_delete?(d, kl, k); - return (r, ()); - } else { - return (udict_set(d, kl, k, v), ()); - } - }`, - ); - - parse( - `slice __tact_dict_get_uint_slice(cell d, int kl, int k) inline { - var (r, ok) = udict_get?(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - }`, - ); - - parse( - `(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl) inline { - var (key, value, flag) = udict_get_min?(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot) inline { - var (key, value, flag) = udict_get_next?(d, kl, pivot); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_uint_slice", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set(d, kl, k, v), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_uint_slice", () => { + ctx.signature( + `slice __tact_dict_get_uint_slice(cell d, int kl, int k)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = udict_get?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_uint_slice", () => { + ctx.signature( + `(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = udict_get_min?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_uint_slice", () => { + ctx.signature( + `(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Slice -> Int // - parse( - `(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl) inline { - if (null?(v)) { - var (r, ok) = __tact_dict_delete(d, kl, k); - return (r, ()); - } else { - return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); - } - }`, - ); - - parse( - `int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl) inline { - var (r, ok) = __tact_dict_get(d, kl, k); - if (ok) { - return r~load_int(vl); - } else { - return null(); - } - }`, - ); - - parse( - `(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl) inline { - var (key, value, flag) = __tact_dict_min(d, kl); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl) inline { - var (key, value, flag) = __tact_dict_next(d, kl, pivot); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_slice_int", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); + return (r, ()); + } else { + return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_slice_int", () => { + ctx.signature( + `int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); + if (ok) { + return r~load_int(vl); + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_slice_int", () => { + ctx.signature( + `(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_slice_int", () => { + ctx.signature( + `(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Slice -> UInt // - parse( - `(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl) inline { - if (null?(v)) { - var (r, ok) = __tact_dict_delete(d, kl, k); - return (r, ()); - } else { - return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); - } - }`, - ); - - parse( - `int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl) inline { - var (r, ok) = __tact_dict_get(d, kl, k); - if (ok) { - return r~load_uint(vl); - } else { - return null(); - } - }`, - ); - - parse( - `(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl) inline { - var (key, value, flag) = __tact_dict_min(d, kl); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl) inline { - var (key, value, flag) = __tact_dict_next(d, kl, pivot); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_slice_uint", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); + return (r, ()); + } else { + return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + } + `); + }); + }); + + ctx.fun("__tact_dict_get_slice_uint", () => { + ctx.signature( + `int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); + if (ok) { + return r~load_uint(vl); + } else { + return null(); + } + `); + }); + }); + + ctx.fun("__tact_dict_min_slice_uint", () => { + ctx.signature( + `(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun("__tact_dict_next_slice_uint", () => { + ctx.signature( + `(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Slice -> Cell // - parse( - `(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v) inline { - if (null?(v)) { - var (r, ok) = __tact_dict_delete(d, kl, k); - return (r, ()); - } else { - return __tact_dict_set_ref(d, kl, k, v); - } - }`, - ); - - parse( - `cell __tact_dict_get_slice_cell(cell d, int kl, slice k) inline { - var (r, ok) = __tact_dict_get_ref(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - }`, - ); - - parse( - `(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl) inline { - var (key, value, flag) = __tact_dict_min_ref(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot) inline { - var (key, value, flag) = __tact_dict_next(d, kl, pivot); - if (flag) { - return (key, value~load_ref(), flag); - } else { - return (null(), null(), flag); - } - }`, - ); + ctx.fun("__tact_dict_set_slice_cell", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); + return (r, ()); + } else { + return ${ctx.used(`__tact_dict_set_ref`)}(d, kl, k, v); + } + `); + }); + }); + + ctx.fun(`__tact_dict_get_slice_cell`, () => { + ctx.signature( + `cell __tact_dict_get_slice_cell(cell d, int kl, slice k)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = ${ctx.used(`__tact_dict_get_ref`)}(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + `); + }); + }); + + ctx.fun(`__tact_dict_min_slice_cell`, () => { + ctx.signature( + `(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = ${ctx.used(`__tact_dict_min_ref`)}(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun(`__tact_dict_next_slice_cell`, () => { + ctx.signature( + `(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); // // Dict Slice -> Slice // - parse( - `(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v) inline { - if (null?(v)) { - var (r, ok) = __tact_dict_delete(d, kl, k); - return (r, ()); - } else { - return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); - } - }`, - ); - - parse( - `slice __tact_dict_get_slice_slice(cell d, int kl, slice k) inline { - var (r, ok) = __tact_dict_get(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - }`, - ); - - parse( - `(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl) inline { - var (key, value, flag) = __tact_dict_min(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - }`, - ); - - parse( - `(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot) inline { - return __tact_dict_next(d, kl, pivot); - }`, - ); + ctx.fun("__tact_dict_set_slice_slice", () => { + ctx.signature( + `(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + if (null?(v)) { + var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); + return (r, ()); + } else { + return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); + } + `); + }); + }); + + ctx.fun(`__tact_dict_get_slice_slice`, () => { + ctx.signature( + `slice __tact_dict_get_slice_slice(cell d, int kl, slice k)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + `); + }); + }); + + ctx.fun(`__tact_dict_min_slice_slice`, () => { + ctx.signature( + `(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + `); + }); + }); + + ctx.fun(`__tact_dict_next_slice_slice`, () => { + ctx.signature( + `(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); + `); + }); + }); // // Address // - parse( - `int __tact_slice_eq_bits(slice a, slice b) inline { - return equal_slice_bits(a, b); - }`, - ); - - parse( - `int __tact_slice_eq_bits_nullable_one(slice a, slice b) inline { - return (null?(a)) ? (false) : (equal_slice_bits(a, b)); - }`, - ); - - parse( - `int __tact_slice_eq_bits_nullable(slice a, slice b) inline { - var a_is_null = null?(a); - var b_is_null = null?(b); - return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (equal_slice_bits(a, b)) : (false); - }`, - ); + ctx.fun(`__tact_slice_eq_bits`, () => { + ctx.signature(`int __tact_slice_eq_bits(slice a, slice b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return equal_slices_bits(a, b); + `); + }); + }); + + ctx.fun(`__tact_slice_eq_bits_nullable_one`, () => { + ctx.signature( + `int __tact_slice_eq_bits_nullable_one(slice a, slice b)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (null?(a)) ? (false) : (equal_slices_bits(a, b)); + `); + }); + }); + + ctx.fun(`__tact_slice_eq_bits_nullable`, () => { + ctx.signature(`int __tact_slice_eq_bits_nullable(slice a, slice b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var a_is_null = null?(a); + var b_is_null = null?(b); + return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( equal_slices_bits(a, b) ) : ( false ) ); + `); + }); + }); + + // + // Dictionary deep equality + // + + ctx.fun(`__tact_dict_eq`, () => { + ctx.signature(`int __tact_dict_eq(cell a, cell b, int kl)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + (slice key, slice value, int flag) = ${ctx.used("__tact_dict_min")}(a, kl); + while (flag) { + (slice value_b, int flag_b) = b~${ctx.used("__tact_dict_delete_get")}(kl, key); + ifnot (flag_b) { + return 0; + } + ifnot (value.slice_hash() == value_b.slice_hash()) { + return 0; + } + (key, value, flag) = ${ctx.used("__tact_dict_next")}(a, kl, key); + } + return null?(b); + `); + }); + }); // // Int Eq // - parse( - `int __tact_int_eq_nullable_one(int a, int b) inline { - return (null?(a)) ? (false) : (a == b); - }`, - ); - - parse( - `int __tact_int_neq_nullable_one(int a, int b) inline { - return (null?(a)) ? (true) : (a != b); - }`, - ); - - parse( - `int __tact_int_eq_nullable(int a, int b) inline { - var a_is_null = null?(a); - var b_is_null = null?(b); - return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a == b) : (false); - }`, - ); - - parse( - `int __tact_int_neq_nullable(int a, int b) inline { - var a_is_null = null?(a); - var b_is_null = null?(b); - return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a != b) : (true); - }`, - ); + ctx.fun(`__tact_int_eq_nullable_one`, () => { + ctx.signature(`int __tact_int_eq_nullable_one(int a, int b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (null?(a)) ? (false) : (a == b); + `); + }); + }); + + ctx.fun(`__tact_int_neq_nullable_one`, () => { + ctx.signature(`int __tact_int_neq_nullable_one(int a, int b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (null?(a)) ? (true) : (a != b); + `); + }); + }); + + ctx.fun(`__tact_int_eq_nullable`, () => { + ctx.signature(`int __tact_int_eq_nullable(int a, int b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var a_is_null = null?(a); + var b_is_null = null?(b); + return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a == b ) : ( false ) ); + `); + }); + }); + + ctx.fun(`__tact_int_neq_nullable`, () => { + ctx.signature(`int __tact_int_neq_nullable(int a, int b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var a_is_null = null?(a); + var b_is_null = null?(b); + return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a != b ) : ( true ) ); + `); + }); + }); // // Cell Eq // - parse( - `int __tact_cell_eq(cell a, cell b) inline { - return (a.cell_hash() == b.cell_hash()); - }`, - ); - - parse( - `int __tact_cell_neq(cell a, cell b) inline { - return (a.cell_hash() != b.cell_hash()); - }`, - ); - - parse( - `int __tact_cell_eq_nullable_one(cell a, cell b) inline { - return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash()); - }`, - ); - - parse( - `int __tact_cell_neq_nullable_one(cell a, cell b) inline { - return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash()); - }`, - ); - - parse( - `int __tact_cell_eq_nullable(cell a, cell b) inline { - var a_is_null = null?(a); - var b_is_null = null?(b); - return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a.cell_hash() == b.cell_hash()) : (false); - }`, - ); - - parse( - `int __tact_cell_neq_nullable(cell a, cell b) inline { - var a_is_null = null?(a); - var b_is_null = null?(b); - return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a.cell_hash() != b.cell_hash()) : (true); - }`, - ); + ctx.fun(`__tact_cell_eq`, () => { + ctx.signature(`int __tact_cell_eq(cell a, cell b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (a.cell_hash() == b.cell_hash()); + `); + }); + }); + + ctx.fun(`__tact_cell_neq`, () => { + ctx.signature(`int __tact_cell_neq(cell a, cell b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (a.cell_hash() != b.cell_hash()); + `); + }); + }); + + ctx.fun(`__tact_cell_eq_nullable_one`, () => { + ctx.signature(`int __tact_cell_eq_nullable_one(cell a, cell b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash()); + `); + }); + }); + + ctx.fun(`__tact_cell_neq_nullable_one`, () => { + ctx.signature(`int __tact_cell_neq_nullable_one(cell a, cell b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash()); + `); + }); + }); + + ctx.fun(`__tact_cell_eq_nullable`, () => { + ctx.signature(`int __tact_cell_eq_nullable(cell a, cell b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var a_is_null = null?(a); + var b_is_null = null?(b); + return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() == b.cell_hash() ) : ( false ) ); + `); + }); + }); + + ctx.fun(`__tact_cell_neq_nullable`, () => { + ctx.signature(`int __tact_cell_neq_nullable(cell a, cell b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var a_is_null = null?(a); + var b_is_null = null?(b); + return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() != b.cell_hash() ) : ( true ) ); + `); + }); + }); // // Slice Eq // - parse( - `int __tact_slice_eq(slice a, slice b) inline { - return (a.slice_hash() == b.slice_hash()); - }`, - ); - - parse( - `int __tact_slice_neq(slice a, slice b) inline { - return (a.slice_hash() != b.slice_hash()); - }`, - ); - - parse( - `int __tact_slice_eq_nullable_one(slice a, slice b) inline { - return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash()); - }`, - ); - - parse( - `int __tact_slice_neq_nullable_one(slice a, slice b) inline { - return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash()); - }`, - ); - - parse( - `int __tact_slice_eq_nullable(slice a, slice b) inline { - var a_is_null = null?(a); - var b_is_null = null?(b); - return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a.slice_hash() == b.slice_hash()) : (false); - }`, - ); - - parse( - `int __tact_slice_neq_nullable(slice a, slice b) inline { - var a_is_null = null?(a); - var b_is_null = null?(b); - return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a.slice_hash() != b.slice_hash()) : (true); - }`, - ); + ctx.fun(`__tact_slice_eq`, () => { + ctx.signature(`int __tact_slice_eq(slice a, slice b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (a.slice_hash() == b.slice_hash()); + `); + }); + }); + + ctx.fun(`__tact_slice_neq`, () => { + ctx.signature(`int __tact_slice_neq(slice a, slice b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (a.slice_hash() != b.slice_hash()); + `); + }); + }); + + ctx.fun(`__tact_slice_eq_nullable_one`, () => { + ctx.signature(`int __tact_slice_eq_nullable_one(slice a, slice b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash()); + `); + }); + }); + + ctx.fun(`__tact_slice_neq_nullable_one`, () => { + ctx.signature(`int __tact_slice_neq_nullable_one(slice a, slice b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash()); + `); + }); + }); + + ctx.fun(`__tact_slice_eq_nullable`, () => { + ctx.signature(`int __tact_slice_eq_nullable(slice a, slice b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var a_is_null = null?(a); + var b_is_null = null?(b); + return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() == b.slice_hash() ) : ( false ) ); + `); + }); + }); + + ctx.fun(`__tact_slice_neq_nullable`, () => { + ctx.signature(`int __tact_slice_neq_nullable(slice a, slice b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var a_is_null = null?(a); + var b_is_null = null?(b); + return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() != b.slice_hash() ) : ( true ) ); + `); + }); + }); // // Sys Dict // - parse( - `cell __tact_dict_set_code(cell dict, int id, cell code) inline { - return udict_set_ref(dict, 16, id, code); - }`, - ); - - parse( - `cell __tact_dict_get_code(cell dict, int id) inline { - var (data, ok) = udict_get_ref?(dict, 16, id); - throw_unless(${contractErrors.codeNotFound.id}, ok); - return data; - }`, - ); + ctx.fun(`__tact_dict_set_code`, () => { + ctx.signature( + `cell __tact_dict_set_code(cell dict, int id, cell code)`, + ); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return udict_set_ref(dict, 16, id, code); + `); + }); + }); + + ctx.fun(`__tact_dict_get_code`, () => { + ctx.signature(`cell __tact_dict_get_code(cell dict, int id)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (data, ok) = udict_get_ref?(dict, 16, id); + throw_unless(${contractErrors.codeNotFound.id}, ok); + return data; + `); + }); + }); // // Tuples // - parse(`tuple __tact_tuple_create_0() asm "NIL";`); - - parse( - `() __tact_tuple_destroy_0() inline { - return (); - }`, - ); + ctx.fun(`__tact_tuple_create_0`, () => { + ctx.signature(`tuple __tact_tuple_create_0()`); + ctx.context("stdlib"); + ctx.asm("", "NIL"); + }); + ctx.fun(`__tact_tuple_destroy_0`, () => { + ctx.signature(`() __tact_tuple_destroy_0()`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.append(`return ();`); + }); + }); + + for (let i = 1; i <= maxTupleSize; i++) { + ctx.fun(`__tact_tuple_create_${i}`, () => { + const args: string[] = []; + for (let j = 0; j < i; j++) { + args.push(`X${j}`); + } + ctx.signature( + `forall ${args.join(", ")} -> tuple __tact_tuple_create_${i}((${args.join(", ")}) v)`, + ); + ctx.context("stdlib"); + ctx.asm("", `${i} TUPLE`); + }); + ctx.fun(`__tact_tuple_destroy_${i}`, () => { + const args: string[] = []; + for (let j = 0; j < i; j++) { + args.push(`X${j}`); + } + ctx.signature( + `forall ${args.join(", ")} -> (${args.join(", ")}) __tact_tuple_destroy_${i}(tuple v)`, + ); + ctx.context("stdlib"); + ctx.asm("", `${i} UNTUPLE`); + }); + } - for (let i = 1; i < 64; i++) { - const args: string[] = []; - for (let j = 0; j < i; j++) { - args.push(`X${j}`); - } + // + // Strings + // - parse( - `forall ${args.join(", ")} -> tuple __tact_tuple_create_${i}((${args.join(", ")}) v) asm "${i} TUPLE";`, + ctx.fun(`__tact_string_builder_start_comment`, () => { + ctx.signature(`tuple __tact_string_builder_start_comment()`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return ${ctx.used("__tact_string_builder_start")}(begin_cell().store_uint(0, 32)); + `); + }); + }); + + ctx.fun(`__tact_string_builder_start_tail_string`, () => { + ctx.signature(`tuple __tact_string_builder_start_tail_string()`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return ${ctx.used("__tact_string_builder_start")}(begin_cell().store_uint(0, 8)); + `); + }); + }); + + ctx.fun(`__tact_string_builder_start_string`, () => { + ctx.signature(`tuple __tact_string_builder_start_string()`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return ${ctx.used("__tact_string_builder_start")}(begin_cell()); + `); + }); + }); + + ctx.fun(`__tact_string_builder_start`, () => { + ctx.signature(`tuple __tact_string_builder_start(builder b)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return tpush(tpush(empty_tuple(), b), null()); + `); + }); + }); + + ctx.fun(`__tact_string_builder_end`, () => { + ctx.signature(`cell __tact_string_builder_end(tuple builders)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + (builder b, tuple tail) = uncons(builders); + cell c = b.end_cell(); + while(~ null?(tail)) { + (b, tail) = uncons(tail); + c = b.store_ref(c).end_cell(); + } + return c; + `); + }); + }); + + ctx.fun(`__tact_string_builder_end_slice`, () => { + ctx.signature(`slice __tact_string_builder_end_slice(tuple builders)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + return ${ctx.used("__tact_string_builder_end")}(builders).begin_parse(); + `); + }); + }); + + ctx.fun(`__tact_string_builder_append`, () => { + ctx.signature( + `((tuple), ()) __tact_string_builder_append(tuple builders, slice sc)`, ); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + int sliceRefs = slice_refs(sc); + int sliceBits = slice_bits(sc); + + while((sliceBits > 0) | (sliceRefs > 0)) { + + ;; Load the current builder + (builder b, tuple tail) = uncons(builders); + int remBytes = 127 - (builder_bits(b) / 8); + int exBytes = sliceBits / 8; + + ;; Append bits + int amount = min(remBytes, exBytes); + if (amount > 0) { + slice read = sc~load_bits(amount * 8); + b = b.store_slice(read); + } + + ;; Update builders + builders = cons(b, tail); + + ;; Check if we need to add a new cell and continue + if (exBytes - amount > 0) { + var bb = begin_cell(); + builders = cons(bb, builders); + sliceBits = (exBytes - amount) * 8; + } elseif (sliceRefs > 0) { + sc = sc~load_ref().begin_parse(); + sliceRefs = slice_refs(sc); + sliceBits = slice_bits(sc); + } else { + sliceBits = 0; + sliceRefs = 0; + } + } + + return ((builders), ()); + `); + }); + }); - parse( - `forall ${args.join(", ")} -> (${args.join(", ")}) __tact_tuple_destroy_${i}(tuple v) asm "${i} UNTUPLE";`, + ctx.fun(`__tact_string_builder_append_not_mut`, () => { + ctx.signature( + `(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc)`, ); - } + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + builders~${ctx.used("__tact_string_builder_append")}(sc); + return builders; + `); + }); + }); + + ctx.fun(`__tact_int_to_string`, () => { + ctx.signature(`slice __tact_int_to_string(int src)`); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var b = begin_cell(); + if (src < 0) { + b = b.store_uint(45, 8); + src = - src; + } + + if (src < ${(10n ** 30n).toString(10)}) { + int len = 0; + int value = 0; + int mult = 1; + do { + (src, int res) = src.divmod(10); + value = value + (res + 48) * mult; + mult = mult * 256; + len = len + 1; + } until (src == 0); + + b = b.store_uint(value, len * 8); + } else { + tuple t = empty_tuple(); + int len = 0; + do { + int digit = src % 10; + t~tpush(digit); + len = len + 1; + src = src / 10; + } until (src == 0); + + int c = len - 1; + repeat(len) { + int v = t.at(c); + b = b.store_uint(v + 48, 8); + c = c - 1; + } + } + return b.end_cell().begin_parse(); + `); + }); + }); + + ctx.fun(`__tact_float_to_string`, () => { + ctx.signature(`slice __tact_float_to_string(int src, int digits)`); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + throw_if(${contractErrors.invalidArgument.id}, (digits <= 0) | (digits > 77)); + builder b = begin_cell(); + + if (src < 0) { + b = b.store_uint(45, 8); + src = - src; + } + + ;; Process rem part + int skip = true; + int len = 0; + int rem = 0; + tuple t = empty_tuple(); + repeat(digits) { + (src, rem) = src.divmod(10); + if ( ~ ( skip & ( rem == 0 ) ) ) { + skip = false; + t~tpush(rem + 48); + len = len + 1; + } + } + + ;; Process dot + if (~ skip) { + t~tpush(46); + len = len + 1; + } + + ;; Main + do { + (src, rem) = src.divmod(10); + t~tpush(rem + 48); + len = len + 1; + } until (src == 0); + + ;; Assemble + int c = len - 1; + repeat(len) { + int v = t.at(c); + b = b.store_uint(v, 8); + c = c - 1; + } + + ;; Result + return b.end_cell().begin_parse(); + `); + }); + }); + + ctx.fun(`__tact_log`, () => { + ctx.signature(`int __tact_log(int num, int base)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + throw_unless(5, num > 0); + throw_unless(5, base > 1); + if (num < base) { + return 0; + } + int result = 0; + while (num >= base) { + num /= base; + result += 1; + } + return result; + `); + }); + }); + + ctx.fun(`__tact_pow`, () => { + ctx.signature(`int __tact_pow(int base, int exp)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + throw_unless(5, exp >= 0); + int result = 1; + repeat (exp) { + result *= base; + } + return result; + `); + }); + }); // - // Strings + // Dict Exists // - parse( - `tuple __tact_string_builder_start_comment() inline { - return __tact_string_builder_start(begin_cell().store_uint(0, 32)); - }`, - ); - - parse( - `tuple __tact_string_builder_start_tail_string() inline { - return __tact_string_builder_start(begin_cell().store_uint(0, 8)); - }`, - ); - - parse( - `tuple __tact_string_builder_start_string() inline { - return __tact_string_builder_start(begin_cell()); - }`, - ); - - parse( - `tuple __tact_string_builder_start(builder b) inline { - return tpush(tpush(empty_tuple(), b), null()); - }`, - ); - - parse( - `cell __tact_string_builder_end(tuple builders) inline { - (builder b, tuple tail) = uncons(builders); - cell c = b.end_cell(); - while (~null?(tail)) { - (b, tail) = uncons(tail); - c = b.store_ref(c).end_cell(); - } - return c; - }`, - ); - - parse( - `slice __tact_string_builder_end_slice(tuple builders) inline { - return __tact_string_builder_end(builders).begin_parse(); - }`, - ); - - parse( - `((tuple), ()) __tact_string_builder_append(tuple builders, slice sc) { - int sliceRefs = slice_refs(sc); - int sliceBits = slice_bits(sc); - - while ((sliceBits > 0) | (sliceRefs > 0)) { - ;; Load the current builder - (builder b, tuple tail) = uncons(builders); - int remBytes = 127 - (builder_bits(b) / 8); - int exBytes = sliceBits / 8; - - ;; Append bits - int amount = min(remBytes, exBytes); - if (amount > 0) { - slice read = sc~load_bits(amount * 8); - b = b.store_slice(read); - } - - ;; Update builders - builders = cons(b, tail); - - ;; Check if we need to add a new cell and continue - if (exBytes - amount > 0) { - var bb = begin_cell(); - builders = cons(bb, builders); - sliceBits = (exBytes - amount) * 8; - } elseif (sliceRefs > 0) { - sc = sc~load_ref().begin_parse(); - sliceRefs = slice_refs(sc); - sliceBits = slice_bits(sc); - } else { - sliceBits = 0; - sliceRefs = 0; - } - } - - return ((builders), ()); - }`, - ); - - parse( - `(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc) { - builders~__tact_string_builder_append(sc); - return builders; - }`, - ); - - parse( - `slice __tact_int_to_string(int src) { - var b = begin_cell(); - if (src < 0) { - b = b.store_uint(45, 8); - src = -src; - } - - if (src < ${(10n ** 30n).toString(10)}) { - int len = 0; - int value = 0; - int mult = 1; - do { - (src, int res) = src.divmod(10); - value = value + (res + 48) * mult; - mult = mult * 256; - len = len + 1; - } until (src == 0); - - b = b.store_uint(value, len * 8); - } else { - tuple t = empty_tuple(); - int len = 0; - do { - int digit = src % 10; - t~tpush(digit); - len = len + 1; - src = src / 10; - } until (src == 0); - - int c = len - 1; - repeat(len) { - int v = t.at(c); - b = b.store_uint(v + 48, 8); - c = c - 1; - } - } - return b.end_cell().begin_parse(); - }`, - ); - - parse( - `slice __tact_float_to_string(int src, int digits) { - throw_if(${contractErrors.invalidArgument.id}, (digits <= 0) | (digits > 77)); - builder b = begin_cell(); - - if (src < 0) { - b = b.store_uint(45, 8); - src = -src; - } - - ;; Process rem part - int skip = true; - int len = 0; - int rem = 0; - tuple t = empty_tuple(); - repeat(digits) { - (src, rem) = src.divmod(10); - if (~ (skip & (rem == 0))) { - skip = false; - t~tpush(rem + 48); - len = len + 1; - } - } - - ;; Process dot - if (~skip) { - t~tpush(46); - len = len + 1; - } - - ;; Main - do { - (src, rem) = src.divmod(10); - t~tpush(rem + 48); - len = len + 1; - } until (src == 0); - - ;; Assemble - int c = len - 1; - repeat(len) { - int v = t.at(c); - b = b.store_uint(v, 8); - c = c - 1; - } - - ;; Result - return b.end_cell().begin_parse(); - }`, - ); - - parse(`int __tact_log2(int num) asm "DUP 5 THROWIFNOT UBITSIZE DEC";`); - - parse( - `int __tact_log(int num, int base) { - throw_unless(5, num > 0); - throw_unless(5, base > 1); - if (num < base) { - return 0; - } - int result = 0; - while (num >= base) { - num /= base; - result += 1; - } - return result; - }`, - ); - - parse( - `int __tact_pow(int base, int exp) { - throw_unless(5, exp >= 0); - int result = 1; - repeat(exp) { - result *= base; - } - return result; - }`, - ); - - parse(`int __tact_pow2(int exp) asm "POW2";`); + ctx.fun("__tact_dict_exists_int", () => { + ctx.signature(`int __tact_dict_exists_int(cell d, int kl, int k)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = idict_get?(d, kl, k); + return ok; + `); + }); + }); + + ctx.fun("__tact_dict_exists_uint", () => { + ctx.signature(`int __tact_dict_exists_uint(cell d, int kl, int k)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = udict_get?(d, kl, k); + return ok; + `); + }); + }); + + ctx.fun("__tact_dict_exists_slice", () => { + ctx.signature(`int __tact_dict_exists_slice(cell d, int kl, slice k)`); + ctx.flag("inline"); + ctx.context("stdlib"); + ctx.body(() => { + ctx.write(` + var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); + return ok; + `); + }); + }); } From 2419b1637ed4a724ee79d74b5d750b5c9fabb144 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 11 Sep 2024 12:34:44 +0000 Subject: [PATCH 149/162] chore(syntaxConstructors): Set `if` instead of `ifnot` by default --- src/func/syntaxConstructors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 1a79d47e3..44c9f6251 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -410,7 +410,7 @@ export function condition( elseStmts?: FuncAstStatement[], params: Partial<{ positive: boolean }> = {}, ): FuncAstStatementCondition { - const { positive = false } = params; + const { positive = true } = params; return { kind: "statement_condition_if", condition, From a89bd0b64afbeaec4482f0a880e9edaf21be908b Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 11 Sep 2024 12:53:15 +0000 Subject: [PATCH 150/162] feat(test): Improve readability --- src/test/new-codegen/codegen.spec.ts | 41 +++++++++++++++------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/test/new-codegen/codegen.spec.ts b/src/test/new-codegen/codegen.spec.ts index 908c30c7b..8fbf88f3e 100644 --- a/src/test/new-codegen/codegen.spec.ts +++ b/src/test/new-codegen/codegen.spec.ts @@ -68,10 +68,13 @@ async function compileContract( ); } -function compareCompilationOutputs( +/** + * @returns True iff compilation outputs are the same. + */ +function compilationOutputsEq( newOut: CompilationOutput, oldOut: CompilationOutput, -): void { +): boolean { const errors: string[] = []; if (newOut === undefined || oldOut === undefined) { @@ -131,8 +134,10 @@ function compareCompilationOutputs( } if (errors.length > 0) { - throw new Error(errors.join("\n")); + console.error(errors.join("\n")); + return false; } + return true; } describe("codegen", () => { @@ -150,22 +155,20 @@ describe("codegen", () => { Promise.all([ compileContract("new", contractName), compileContract("old", contractName), - ]) - .then(([resultsNew, resultsOld]) => { - if (resultsNew.length !== resultsOld.length) { - throw new Error("Not all contracts have been compiled"); - } - const zipped = resultsNew.map((value, idx) => [ - value, - resultsOld[idx], - ]); - zipped.forEach(([newRes, oldRes]) => { - expect(() => compareCompilationOutputs( - newRes!.output, - oldRes!.output, - )).not.toThrow(); - }); - }) + ]).then(([resultsNew, resultsOld]) => { + if (resultsNew.length !== resultsOld.length) { + throw new Error("Not all contracts have been compiled"); + } + const zipped = resultsNew.map((value, idx) => [ + value, + resultsOld[idx], + ]); + zipped.forEach(([newRes, oldRes]) => { + expect( + compilationOutputsEq(newRes!.output, oldRes!.output), + ).toBe(true); + }); + }); }); }); }); From 6d4b1794657d439774a6ee183ef9974bea291bc8 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 11 Sep 2024 13:20:07 +0000 Subject: [PATCH 151/162] feat(test): Don't add extra .tact to paths in the generated config --- src/test/new-codegen/codegen.spec.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/new-codegen/codegen.spec.ts b/src/test/new-codegen/codegen.spec.ts index 8fbf88f3e..e9172d8a1 100644 --- a/src/test/new-codegen/codegen.spec.ts +++ b/src/test/new-codegen/codegen.spec.ts @@ -17,6 +17,7 @@ function capitalize(str: string): string { /** * Generates a Tact configuration file for the given contract (imported from Misti). + * @returns Path to entrypoint */ export function generateConfig(contractName: string): string { const config = { @@ -34,7 +35,7 @@ export function generateConfig(contractName: string): string { encoding: "utf8", flag: "w", }); - return configPath; + return config.projects[0]!.path; } /** @@ -44,7 +45,7 @@ async function compileContract( backend: "new" | "old", contractName: string, ): Promise { - generateConfig(contractName); + const entrypointPath = generateConfig(contractName); // see: pipeline/build.ts const project = createNodeFileSystem(CONTRACTS_DIR, false); @@ -53,7 +54,7 @@ async function compileContract( false, ); let ctx: CompilerContext = new CompilerContext(); - ctx = precompile(ctx, project, stdlib, contractName); + ctx = precompile(ctx, project, stdlib, entrypointPath); return await Promise.all( getContracts(ctx).map(async (contract) => { @@ -149,7 +150,7 @@ describe("codegen", () => { if (!file.endsWith(".tact")) { return; } - const contractName = capitalize(file); + const contractName = capitalize(file).replace(/\.[^/.]+$/, ""); // Differential tests with the old backend it(`Should compile the ${file} contract`, async () => { Promise.all([ From e140b358603ff629325c0dd63b94edf30cc70375 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 11 Sep 2024 13:20:38 +0000 Subject: [PATCH 152/162] feat(test): Don't consider newlines in differential testing Both backends generated some extra garbage. --- src/test/new-codegen/codegen.spec.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/new-codegen/codegen.spec.ts b/src/test/new-codegen/codegen.spec.ts index e9172d8a1..0a17d69f8 100644 --- a/src/test/new-codegen/codegen.spec.ts +++ b/src/test/new-codegen/codegen.spec.ts @@ -69,8 +69,15 @@ async function compileContract( ); } +function stripEmptyLines(code: string): string { + return code + .split("\n") + .filter((line) => line.trim() !== "") + .join("\n"); +} + /** - * @returns True iff compilation outputs are the same. + * @returns True iff compilation outputs are the same, ignoring empty lines. */ function compilationOutputsEq( newOut: CompilationOutput, @@ -110,7 +117,9 @@ function compilationOutputsEq( if (oldFile) { unmatchedFiles.delete(oldFile.name); try { - expect(newFile.code).toBe(oldFile.code); + expect(stripEmptyLines(newFile.code)).toBe( + stripEmptyLines(oldFile.code), + ); } catch (error) { if (error instanceof Error) { errors.push( From 6909f93874a8fa95f01c946a212c211ca64fc378 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 11 Sep 2024 13:21:20 +0000 Subject: [PATCH 153/162] fix(pp): Don't add extra crs --- src/func/prettyPrinter.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index 99bf68208..c8ee4dc85 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -667,7 +667,11 @@ export class FuncPrettyPrinter { } private prettyPrintCR(node: FuncAstCR): string { - return "\n".repeat(node.lines); + // Remove an extra newline, since PrettyPrinter adds newlines between AST entries + if (node.lines === 1) { + return ""; + } + return "\n".repeat(node.lines - 1); } private prettyPrintIndentedBlock(content: string): string { From 6397c853f3fbab5b09a13a3359e662ec26b136c2 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Wed, 11 Sep 2024 13:21:42 +0000 Subject: [PATCH 154/162] feat(codegen): Port `writeRouter` --- src/generatorNew/Writer.ts | 7 + .../writers/resolveFuncTypeNew.ts | 93 +++ src/generatorNew/writers/writeRouter.ts | 574 +++++++++++------- 3 files changed, 442 insertions(+), 232 deletions(-) create mode 100644 src/generatorNew/writers/resolveFuncTypeNew.ts diff --git a/src/generatorNew/Writer.ts b/src/generatorNew/Writer.ts index 85bc9d93d..dd6f9eca0 100644 --- a/src/generatorNew/Writer.ts +++ b/src/generatorNew/Writer.ts @@ -7,6 +7,7 @@ import { FuncAstFunctionDefinition, FuncAstAsmFunctionDefinition, FuncAstModule, + FuncAstNode, funcBuiltinFunctions, parse, } from "../func/grammar"; @@ -166,6 +167,12 @@ export class WriterContext { return fundef; } + // The same as `append`, but adds AST entries. + appendNode(node: FuncAstNode) { + const pp = new FuncPrettyPrinter(); + this.pendingWriter!.append(pp.prettyPrint(node) + "\n"); + } + // // Rendering // diff --git a/src/generatorNew/writers/resolveFuncTypeNew.ts b/src/generatorNew/writers/resolveFuncTypeNew.ts new file mode 100644 index 000000000..b79f06f7e --- /dev/null +++ b/src/generatorNew/writers/resolveFuncTypeNew.ts @@ -0,0 +1,93 @@ +import { WriterContext } from "../Writer"; +import { TypeDescription, TypeRef } from "../../types/types"; +import { getType } from "../../types/resolveDescriptors"; +import { FuncAstType } from "../../func/grammar"; +import { Type, unit } from "../../func/syntaxConstructors"; + +/** + * Generates Func type from the Tact type. + */ +export function resolveFuncType( + descriptor: TypeRef | TypeDescription | string, + optional: boolean = false, + usePartialFields: boolean = false, + ctx: WriterContext, +): FuncAstType { + // String + if (typeof descriptor === "string") { + return resolveFuncType( + getType(ctx.ctx, descriptor), + false, + usePartialFields, + ctx, + ); + } + + // TypeRef + if (descriptor.kind === "ref") { + return resolveFuncType( + getType(ctx.ctx, descriptor.name), + descriptor.optional, + usePartialFields, + ctx, + ); + } + if (descriptor.kind === "map") { + return Type.cell(); + } + if (descriptor.kind === "ref_bounced") { + return resolveFuncType(getType(ctx.ctx, descriptor.name), false, true, ctx); + } + if (descriptor.kind === "void") { + return unit(); + } + + // TypeDescription + if (descriptor.kind === "primitive_type_decl") { + if (descriptor.name === "Int") { + return Type.int(); + } else if (descriptor.name === "Bool") { + return Type.int(); + } else if (descriptor.name === "Slice") { + return Type.slice(); + } else if (descriptor.name === "Cell") { + return Type.cell(); + } else if (descriptor.name === "Builder") { + return Type.builder(); + } else if (descriptor.name === "Address") { + return Type.slice(); + } else if (descriptor.name === "String") { + return Type.slice(); + } else if (descriptor.name === "StringBuilder") { + return Type.tuple(); + } else { + throw Error(`Unknown primitive type: ${descriptor.name}`); + } + } else if (descriptor.kind === "struct") { + const fieldsToUse = usePartialFields + ? descriptor.fields.slice(0, descriptor.partialFieldCount) + : descriptor.fields; + if (optional || fieldsToUse.length === 0) { + return Type.tuple(); + } else { + return Type.tensor( + ...fieldsToUse.map((v) => + resolveFuncType(v.type, false, usePartialFields, ctx), + ), + ); + } + } else if (descriptor.kind === "contract") { + if (optional || descriptor.fields.length === 0) { + return Type.tuple(); + } else { + return Type.tensor( + ...descriptor.fields.map((v) => + resolveFuncType(v.type, false, usePartialFields, ctx), + ), + ); + } + } + + // Unreachable + throw Error(`Unknown type: ${descriptor.kind}`); +} diff --git a/src/generatorNew/writers/writeRouter.ts b/src/generatorNew/writers/writeRouter.ts index 82f2e3861..13136c12f 100644 --- a/src/generatorNew/writers/writeRouter.ts +++ b/src/generatorNew/writers/writeRouter.ts @@ -4,10 +4,30 @@ import { ReceiverDescription, TypeDescription } from "../../types/types"; import { WriterContext } from "../Writer"; import { funcIdOf } from "./id"; import { ops } from "./ops"; -import { resolveFuncType } from "./resolveFuncType"; +import { resolveFuncType } from "./resolveFuncTypeNew"; import { resolveFuncTypeUnpack } from "./resolveFuncTypeUnpack"; import { writeStatement } from "./writeFunction"; import { AstNumber } from "../../grammar/ast"; +import { + cr, + comment, + assign, + expr, + call, + binop, + bool, + int, + hex, +fun, + ret, + tensor, + Type, + FunAttr, + vardef, + condition, + id, +} from "../../func/syntaxConstructors"; +import {FuncAstFunctionAttribute, FuncAstType, FuncAstStatement} from "../../func/grammar"; export function commentPseudoOpcode(comment: string): string { return beginCell() @@ -22,257 +42,347 @@ export function writeRouter( type: TypeDescription, kind: "internal" | "external", ctx: WriterContext, -) { +): void { const internal = kind === "internal"; + const attrs: FuncAstFunctionAttribute[] = [ + FunAttr.impure(), + FunAttr.inline_ref(), + ]; + const name = ops.contractRouter(type.name, kind); + const returnTy = Type.tensor( + resolveFuncType(type, false, false, ctx), + Type.int(), + ); + const paramValues: [string, FuncAstType][] = internal + ? [ + ["self", resolveFuncType(type, false, false, ctx)], + ["msg_bounced", Type.int()], + ["in_msg", Type.slice()], + ] + : [ + ["self", resolveFuncType(type, false, false, ctx)], + ["in_msg", Type.slice()], + ]; + const functionBody: FuncAstStatement[] = []; + + // ;; Handle bounced messages + // if (msg_bounced) { + // ... + // } if (internal) { - ctx.append( - `(${resolveFuncType(type, ctx)}, int) ${ops.contractRouter(type.name, kind)}(${resolveFuncType(type, ctx)} self, int msg_bounced, slice in_msg) impure inline_ref {`, - ); - } else { - ctx.append( - `(${resolveFuncType(type, ctx)}, int) ${ops.contractRouter(type.name, kind)}(${resolveFuncType(type, ctx)} self, slice in_msg) impure inline_ref {`, - ); - } - ctx.inIndent(() => { - // Handle bounced - if (internal) { - ctx.append(`;; Handle bounced messages`); - ctx.append(`if (msg_bounced) {`); - ctx.inIndent(() => { - const bounceReceivers = type.receivers.filter((r) => { - return r.selector.kind === "bounce-binary"; - }); - - const fallbackReceiver = type.receivers.find((r) => { - return r.selector.kind === "bounce-fallback"; - }); - - if (fallbackReceiver ?? bounceReceivers.length > 0) { - ctx.append(); - ctx.append(`;; Skip 0xFFFFFFFF`); - ctx.append(`in_msg~skip_bits(32);`); - ctx.append(); - } - - if (bounceReceivers.length > 0) { - ctx.append(`;; Parse op`); - ctx.append(`int op = 0;`); - ctx.append(`if (slice_bits(in_msg) >= 32) {`); - ctx.inIndent(() => { - ctx.append(`op = in_msg.preload_uint(32);`); - }); - ctx.append(`}`); - ctx.append(); - } - - for (const r of bounceReceivers) { - const selector = r.selector; - if (selector.kind !== "bounce-binary") - throw Error("Invalid selector type: " + selector.kind); // Should not happen - const allocation = getType(ctx.ctx, selector.type); - ctx.append( - `;; Bounced handler for ${selector.type} message`, - ); - ctx.append( - `if (op == ${messageOpcode(allocation.header!)}) {`, - ); - ctx.inIndent(() => { - // Read message - ctx.append( - `var msg = in_msg~${selector.bounced ? ops.readerBounced(selector.type, ctx) : ops.reader(selector.type, ctx)}();`, - ); - - // Execute function - ctx.append( - `self~${ops.receiveTypeBounce(type.name, selector.type)}(msg);`, - ); - - // Exit - ctx.append("return (self, true);"); - }); - ctx.append(`}`); - ctx.append(); - } - - if (fallbackReceiver) { - const selector = fallbackReceiver.selector; - if (selector.kind !== "bounce-fallback") - throw Error("Invalid selector type: " + selector.kind); + functionBody.push(comment("Handle bounced messages")); + const body: FuncAstStatement[] = []; + const bounceReceivers = type.receivers.filter((r) => { + return r.selector.kind === "bounce-binary"; + }); - // Execute function - ctx.append(`;; Fallback bounce receiver`); - ctx.append( - `self~${ops.receiveBounceAny(type.name)}(in_msg);`, - ); - ctx.append(); + const fallbackReceiver = type.receivers.find((r) => { + return r.selector.kind === "bounce-fallback"; + }); - // Exit - ctx.append("return (self, true);"); - } else { - ctx.append(`return (self, true);`); - } - }); - ctx.append(`}`); + const condBody: FuncAstStatement[] = []; + if (fallbackReceiver ?? bounceReceivers.length > 0) { + // ;; Skip 0xFFFFFFFF + // in_msg~skip_bits(32); + condBody.push(comment("Skip 0xFFFFFFFF")); + condBody.push(expr(call("in_msg~skip_bits", [int(32)]))); } - // Parse incoming message - ctx.append(); - ctx.append(`;; Parse incoming message`); - ctx.append(`int op = 0;`); - ctx.append(`if (slice_bits(in_msg) >= 32) {`); - ctx.inIndent(() => { - ctx.append(`op = in_msg.preload_uint(32);`); - }); - ctx.append(`}`); - ctx.append(); - - // Non-empty receivers - for (const f of type.receivers) { - const selector = f.selector; + if (bounceReceivers.length > 0) { + // ;; Parse op + // int op = 0; + // if (slice_bits(in_msg) >= 32) { + // op = in_msg.preload_uint(32); + // } + condBody.push(comment("Parse op")); + condBody.push(vardef(Type.int(), "op", int(0))); + condBody.push( + condition( + binop( + call("slice_bits", [id("in_msg")]), + ">=", + int(30), + ), + [ + expr( + assign( + id("op"), + call(id("in_msg.preload_uint"), [int(32)]), + ), + ), + ], + ), + ); + } - // Generic receiver - if ( - selector.kind === - (internal ? "internal-binary" : "external-binary") - ) { - const allocation = getType(ctx.ctx, selector.type); - if (!allocation.header) { - throw Error("Invalid allocation: " + selector.type); - } - ctx.append(); - ctx.append(`;; Receive ${selector.type} message`); - ctx.append(`if (op == ${messageOpcode(allocation.header)}) {`); - ctx.inIndent(() => { - // Read message - ctx.append( - `var msg = in_msg~${ops.reader(selector.type, ctx)}();`, - ); + for (const r of bounceReceivers) { + const selector = r.selector; + if (selector.kind !== "bounce-binary") + throw Error(`Invalid selector type: ${selector.kind}`); // Should not happen + body.push( + comment(`Bounced handler for ${selector.type} message`), + ); + // XXX: We assert `header` to be non-null only in the new backend; otherwise it could be a compiler bug + body.push( + condition( + binop( + id("op"), + "==", + int(getType(ctx.ctx, selector.type).header!.value), + ), + [ + vardef( + "_", + "msg", + call( + id( + `in_msg~${selector.bounced ? ops.readerBounced(selector.type, ctx) : ops.reader(selector.type, ctx)}`, + ), + [], + ), + ), + expr( + call( + id( + `self~${ops.receiveTypeBounce(type.name, selector.type)}`, + ), + [id("msg")], + ), + ), + ret(tensor(id("self"), bool(true))), + ], + ), + ); + } - // Execute function - ctx.append( - `self~${ops.receiveType(type.name, kind, selector.type)}(msg);`, - ); + if (fallbackReceiver) { + const selector = fallbackReceiver.selector; + if (selector.kind !== "bounce-fallback") + throw Error("Invalid selector type: " + selector.kind); + body.push(comment("Fallback bounce receiver")); + body.push( + expr( + call(id(`self~${ops.receiveBounceAny(type.name)}`), [ + id("in_msg"), + ]), + ), + ); + body.push(ret(tensor(id("self"), bool(true)))); + } else { + body.push(ret(tensor(id("self"), bool(true)))); + } + const cond = condition(id("msg_bounced"), body); + functionBody.push(cond); + functionBody.push(cr()); + } - // Exit - ctx.append("return (self, true);"); - }); - ctx.append(`}`); + // ;; Parse incoming message + // int op = 0; + // if (slice_bits(in_msg) >= 32) { + // op = in_msg.preload_uint(32); + // } + functionBody.push(comment("Parse incoming message")); + functionBody.push(vardef(Type.int(), "op", int(0))); + functionBody.push( + condition( + binop(call(id("slice_bits"), [id("in_msg")]), ">=", int(32)), + [ + expr( + assign( + id("op"), + call("in_msg.preload_uint", [int(32)]), + ), + ), + ], + ), + ); + functionBody.push(cr()); + + // Non-empty receivers + for (const f of type.receivers) { + const selector = f.selector; + + // Generic receiver + if ( + selector.kind === + (internal ? "internal-binary" : "external-binary") + ) { + const allocation = getType(ctx.ctx, selector.type); + if (!allocation.header) { + throw Error(`Invalid allocation: ${selector.type}`); } + functionBody.push(comment(`Receive ${selector.type} message`)); + functionBody.push( + condition(binop(id("op"), "==", int(allocation.header.value)), [ + vardef( + "_", + "msg", + call(`in_msg~${ops.reader(selector.type, ctx)}`, []), + ), + expr( + call( + `self~${ops.receiveType(type.name, kind, selector.type)}`, + [id("msg")], + ), + ), + ]), + ); + } - if ( - selector.kind === - (internal ? "internal-empty" : "external-empty") - ) { - ctx.append(); - ctx.append(`;; Receive empty message`); - ctx.append(`if ((op == 0) & (slice_bits(in_msg) <= 32)) {`); - ctx.inIndent(() => { - // Execute function - ctx.append(`self~${ops.receiveEmpty(type.name, kind)}();`); - - // Exit - ctx.append("return (self, true);"); - }); - ctx.append(`}`); - } + if ( + selector.kind === + (internal ? "internal-empty" : "external-empty") + ) { + // ;; Receive empty message + // if ((op == 0) & (slice_bits(in_msg) <= 32)) { + // self~${ops.receiveEmpty(type.name, kind)}(); + // return (self, true); + // } + functionBody.push(comment("Receive empty message")); + functionBody.push( + condition( + binop( + binop(id("op"), "==", int(0)), + "&", + binop( + call("slice_bits", [id("in_msg")]), + "<=", + int(32), + ), + ), + [ + expr( + call( + `self~${ops.receiveEmpty(type.name, kind)}`, + [], + ), + ), + ret(tensor(id("self"), bool(true))), + ], + ), + ); + functionBody.push(cr()); } + } - // Text resolvers - const hasComments = !!type.receivers.find((v) => - internal - ? v.selector.kind === "internal-comment" || - v.selector.kind === "internal-comment-fallback" - : v.selector.kind === "external-comment" || - v.selector.kind === "external-comment-fallback", - ); - if (hasComments) { - ctx.append(); - ctx.append(`;; Text Receivers`); - ctx.append(`if (op == 0) {`); - ctx.inIndent(() => { + // Text resolvers + const hasComments = !!type.receivers.find((v) => + internal + ? v.selector.kind === "internal-comment" || + v.selector.kind === "internal-comment-fallback" + : v.selector.kind === "external-comment" || + v.selector.kind === "external-comment-fallback", + ); + if (hasComments) { + // ;; Text Receivers + // if (op == 0) { + // ... + // } + functionBody.push(comment("Text Receivers")); + const cond = binop(id("op"), "==", int(0)); + const condBody: FuncAstStatement[] = []; + if ( + type.receivers.find( + (v) => + v.selector.kind === + (internal ? "internal-comment" : "external-comment"), + ) + ) { + // var text_op = slice_hash(in_msg); + condBody.push( + vardef("_", "text_op", call("slice_hash", [id("in_msg")])), + ); + for (const r of type.receivers) { if ( - type.receivers.find( - (v) => - v.selector.kind === - (internal - ? "internal-comment" - : "external-comment"), - ) + r.selector.kind === + (internal ? "internal-comment" : "external-comment") ) { - ctx.append(`var text_op = slice_hash(in_msg);`); - for (const r of type.receivers) { - const selector = r.selector; - if ( - selector.kind === - (internal ? "internal-comment" : "external-comment") - ) { - const hash = commentPseudoOpcode(selector.comment); - ctx.append(); - ctx.append( - `;; Receive "${selector.comment}" message`, - ); - ctx.append(`if (text_op == 0x${hash}) {`); - ctx.inIndent(() => { - // Execute function - ctx.append( - `self~${ops.receiveText(type.name, kind, hash)}();`, - ); - - // Exit - ctx.append("return (self, true);"); - }); - ctx.append(`}`); - } - } - } - - // Comment fallback resolver - const fallback = type.receivers.find( - (v) => - v.selector.kind === - (internal - ? "internal-comment-fallback" - : "external-comment-fallback"), - ); - if (fallback) { - ctx.append(`if (slice_bits(in_msg) >= 32) {`); - ctx.inIndent(() => { - // Execute function - ctx.append( - `self~${ops.receiveAnyText(type.name, kind)}(in_msg.skip_bits(32));`, - ); - - // Exit - ctx.append("return (self, true);"); - }); - - ctx.append(`}`); + // ;; Receive "increment" message + // if (text_op == 0xc4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae) { + // self~$A$_internal_text_c4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae(); + // return (self, true); + // } + const hash = commentPseudoOpcode( + r.selector.comment, + ); + condBody.push( + comment(`Receive "${r.selector.comment}" message`), + ); + condBody.push( + condition(binop(id("text_op"), "==", hex(hash)), [ + expr( + call( + `self~${ops.receiveText(type.name, kind, hash)}`, + [], + ), + ), + ret(tensor(id("self"), bool(true))), + ]), + ); } - }); - ctx.append(`}`); + } } - // Fallback - const fallbackReceiver = type.receivers.find( + // Comment fallback resolver + const fallback = type.receivers.find( (v) => v.selector.kind === - (internal ? "internal-fallback" : "external-fallback"), + (internal + ? "internal-comment-fallback" + : "external-comment-fallback"), ); - if (fallbackReceiver) { - ctx.append(); - ctx.append(`;; Receiver fallback`); + if (fallback) { + condBody.push( + condition( + binop( + call("slice_bits", [id("in_msg")]), + ">=", + int(32), + ), + [ + expr( + call( + id( + `self~${ops.receiveAnyText(type.name, kind)}`, + ), + [call("in_msg.skip_bits", [int(32)])], + ), + ), + ret(tensor(id("self"), bool(true))), + ], + ), + ); + } + functionBody.push(condition(cond, condBody)); + functionBody.push(cr()); + } - // Execute function - ctx.append(`self~${ops.receiveAny(type.name, kind)}(in_msg);`); + // Fallback + const fallbackReceiver = type.receivers.find( + (v) => + v.selector.kind === + (internal ? "internal-fallback" : "external-fallback"), + ); + if (fallbackReceiver) { + // ;; Receiver fallback + // self~${ops.receiveAny(type.name, kind)}(in_msg); + // return (self, true); + functionBody.push(comment("Receiver fallback")); + functionBody.push( + expr( + call(`self~${ops.receiveAny(type.name, kind)}`, [ + id("in_msg"), + ]), + ), + ); + functionBody.push(ret(tensor(id("self"), bool(true)))); + } else { + // return (self, false); + functionBody.push(ret(tensor(id("self"), bool(false)))); + } - ctx.append("return (self, true);"); - } else { - ctx.append(); - ctx.append("return (self, false);"); - } - }); - ctx.append(`}`); - ctx.append(); + const receiver = fun(name, paramValues, attrs, returnTy, functionBody); + ctx.appendNode(receiver); } function messageOpcode(n: AstNumber): string { @@ -294,7 +404,7 @@ export function writeReceiver( ) { const selector = f.selector; const selfRes = resolveFuncTypeUnpack(self, funcIdOf("self"), ctx); - const selfType = resolveFuncType(self, ctx); + const selfType = resolveFuncType(self, false, false, ctx); const selfUnpack = `var ${resolveFuncTypeUnpack(self, funcIdOf("self"), ctx)} = ${funcIdOf("self")};`; // Binary receiver @@ -304,7 +414,7 @@ export function writeReceiver( ) { const args = [ selfType + " " + funcIdOf("self"), - resolveFuncType(selector.type, ctx) + " " + funcIdOf(selector.name), + resolveFuncType(selector.type, false, false, ctx) + " " + funcIdOf(selector.name), ]; ctx.append( `((${selfType}), ()) ${ops.receiveType(self.name, selector.kind === "internal-binary" ? "internal" : "external", selector.type)}(${args.join(", ")}) impure inline {`, @@ -470,7 +580,7 @@ export function writeReceiver( if (selector.kind === "bounce-binary") { const args = [ selfType + " " + funcIdOf("self"), - resolveFuncType(selector.type, ctx, false, selector.bounced) + + resolveFuncType(selector.type,false, selector.bounced, ctx) + " " + funcIdOf(selector.name), ]; From 236a5186c561fe83d635762eed5359b8d191f200 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:29:24 +0200 Subject: [PATCH 155/162] feat: support `catch(_)` clauses --- src/func/grammar-test/statements.fc | 1 + src/func/grammar.ohm | 6 +++++- src/func/grammar.ts | 31 +++++++++++++++++++---------- src/func/syntaxConstructors.ts | 4 ++-- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/func/grammar-test/statements.fc b/src/func/grammar-test/statements.fc index 0ff788109..9cbe3a5b9 100644 --- a/src/func/grammar-test/statements.fc +++ b/src/func/grammar-test/statements.fc @@ -78,6 +78,7 @@ int return_stmt'() { return 42; } { } } + try { } catch (_) { } try { } catch (exception, exit_code) { } } diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index 02a1aa1fc..d200f4d1a 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -137,9 +137,13 @@ FunC { StatementTryCatch = "try" "{" Statement* "}" - "catch" "(" (unusedId | id) "," (unusedId | id) ")" + "catch" "(" CatchClauseContents ")" "{" Statement* "}" + // (not a separate thing, added purely for convenience) + CatchClauseContents = (unusedId | id) "," (unusedId | id) --both + | unusedId --unused + StatementExpression = Expression ";" // diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 2d53ce3b4..18c51bdd7 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -884,7 +884,7 @@ export type FuncAstStatementWhile = { }; /** (id, id) */ -export type FuncCatchDefintions = { +export type FuncCatchDefinitions = { exceptionName: FuncAstId; exitCodeName: FuncAstId; }; @@ -896,7 +896,7 @@ export type FuncCatchDefintions = { export type FuncAstStatementTryCatch = { kind: "statement_try_catch"; statementsTry: FuncAstStatement[]; - catchDefinitions: FuncCatchDefintions | "_"; + catchDefinitions: FuncCatchDefinitions | "_"; statementsCatch: FuncAstStatement[]; loc: FuncSrcInfo; }; @@ -1730,9 +1730,7 @@ semantics.addOperation("astOfStatement", { _rbrace, _catchKwd, _lparen, - exceptionName, - _comma, - exitCodeName, + catchClauseContents, _rparen, _lbrace2, stmtsCatch, @@ -1741,10 +1739,7 @@ semantics.addOperation("astOfStatement", { return { kind: "statement_try_catch", statementsTry: stmtsTry.children.map((x) => x.astOfStatement()), - catchDefinitions: { - exceptionName: exceptionName.astOfExpression(), - exitCodeName: exitCodeName.astOfExpression(), - }, + catchDefinitions: catchClauseContents.astOfCatchClauseContents(), statementsCatch: stmtsCatch.children.map((x) => x.astOfStatement()), loc: createSrcInfo(this), }; @@ -2444,7 +2439,7 @@ semantics.addOperation("astOfParameter", { loc: createSrcInfo(this), }; }, - Parameter_hole(node) { + Parameter_hole(_node) { return { kind: "parameter", ty: { @@ -2757,6 +2752,22 @@ semantics.addOperation("astOfElseBlock", { }, }); +// Not a standalone statement +semantics.addOperation("astOfCatchClauseContents", { + CatchClauseContents(node) { + return node.astOfCatchClauseContents(); + }, + CatchClauseContents_unused(_underscore) { + return "_"; + }, + CatchClauseContents_both(exceptionName, _comma, exitCodeName) { + return { + exceptionName: exceptionName.astOfExpression(), + exitCodeName: exitCodeName.astOfExpression(), + }; + }, +}); + // // Utility parsing functions // diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index 44c9f6251..e2d5139fc 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -52,7 +52,7 @@ import { FuncAstModuleItem, FuncAstModule, FuncAstGlobalVariablesDeclaration, - FuncCatchDefintions, + FuncCatchDefinitions, dummySrcInfo, } from "./grammar"; import { dummySrcInfo as tactDummySrcInfo } from "../grammar/grammar"; @@ -491,7 +491,7 @@ export function try_( export function tryCatch( statementsTry: FuncAstStatement[], - catchDefinitions: "_" | FuncCatchDefintions, + catchDefinitions: "_" | FuncCatchDefinitions, statementsCatch: FuncAstStatement[], ): FuncAstStatementTryCatch { return { From 9cfa662093df968adc8be7f74ae0d31545d991f1 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:41:07 +0200 Subject: [PATCH 156/162] fix(tests): Hack for FunC parser Still idk, why things went wrong with that identifier there, as identifiers elsewhere work just fine --- src/func/grammar-test/mathlib.fc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/func/grammar-test/mathlib.fc b/src/func/grammar-test/mathlib.fc index f2dfd73f5..5935bf1fd 100644 --- a/src/func/grammar-test/mathlib.fc +++ b/src/func/grammar-test/mathlib.fc @@ -574,9 +574,9 @@ int atanh_f261(int x, int n) inline_ref { s -= 1; } x += t; - int 2x = 2 * x; - int y = lshift256divr(2x, (x >> 1) - t); - ;; y = 2x - (mulrshiftr256(2x, y) ~>> 2); ;; this line could improve precision on very rare occasions + int xx = 2 * x; + int y = lshift256divr(xx, (x >> 1) - t); + ;; y = xx - (mulrshiftr256(xx, y) ~>> 2); ;; this line could improve precision on very rare occasions return (atanh_f258(y, 36), s); } From deaa61784e29e7511ba85d5f29d7624ab916ff4e Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:43:19 +0200 Subject: [PATCH 157/162] fix(func-parser): Correct recognition of function and method calls And semantically accurate function arguments (just tensors), albeit at the cost of some expressiveness of FunC --- src/func/grammar.ohm | 11 ++----- src/func/grammar.ts | 24 +++++----------- src/func/iterators.ts | 2 +- src/func/prettyPrinter.ts | 8 ++---- src/func/syntaxConstructors.ts | 4 +-- src/generatorNew/writers/writeRouter.ts | 38 ++++++++++++------------- 6 files changed, 34 insertions(+), 53 deletions(-) diff --git a/src/func/grammar.ohm b/src/func/grammar.ohm index d200f4d1a..9586f188b 100644 --- a/src/func/grammar.ohm +++ b/src/func/grammar.ohm @@ -201,7 +201,7 @@ FunC { | ExpressionMethod // parse_expr80 - ExpressionMethod = ExpressionVarFun (methodId &("(" | "[" | functionId) ExpressionArgument)+ --calls + ExpressionMethod = ExpressionVarFun (methodId ExpressionTensor)+ --calls | ExpressionVarFun // parse_expr90 @@ -222,14 +222,7 @@ FunC { IdOrUnusedId = id | unusedId // Function calls - ExpressionFunCall = &("(" | functionId) ExpressionPrimary ExpressionArgument+ - - // (not a separate expression, added purely for convenience) - ExpressionArgument = functionId - | unit - | ExpressionTensor - | tupleEmpty - | ExpressionTuple + ExpressionFunCall = &("(" | functionId) ExpressionPrimary ExpressionTensor // parse_expr100 ExpressionPrimary = unit diff --git a/src/func/grammar.ts b/src/func/grammar.ts index 18c51bdd7..c665657a4 100644 --- a/src/func/grammar.ts +++ b/src/func/grammar.ts @@ -1077,16 +1077,9 @@ export type FuncAstExpressionMethod = { export type FuncExpressionMethodCall = { name: FuncAstMethodId; - argument: FuncAstExpressionPrimary; + argument: FuncAstExpressionTensor; }; -export type FuncArgument = - | FuncAstId - | FuncAstUnit - | FuncAstExpression - | FuncAstExpressionTensor - | FuncAstExpressionTuple; - /** * parse_expr90 */ @@ -1135,12 +1128,12 @@ export type FuncAstExpressionTupleVarDecl = { /** * Function call * - * (functionId | functionCallReturningFunction) Argument+ + * (functionId | functionCallReturningFunction) ExpressionTensor */ export type FuncAstExpressionFunCall = { kind: "expression_fun_call"; object: FuncAstExpressionPrimary; - arguments: FuncArgument[]; + argument: FuncAstExpressionTensor; loc: FuncSrcInfo; }; @@ -1914,12 +1907,12 @@ semantics.addOperation("astOfExpression", { ExpressionMethod(expr) { return expr.astOfExpression(); }, - ExpressionMethod_calls(exprLeft, methodIds, _lookahead, exprs) { + ExpressionMethod_calls(exprLeft, methodIds, exprs) { const resolvedIds = methodIds.children.map( (x) => x.astOfExpression() as FuncAstMethodId, ); const resolvedExprs = exprs.children.map( - (x) => x.astOfExpression() as FuncArgument, + (x) => x.astOfExpression() as FuncAstExpressionTensor, ); const zipped = resolvedIds.map((resId, i) => { return { name: resId, argument: resolvedExprs[i]! }; @@ -1983,17 +1976,14 @@ semantics.addOperation("astOfExpression", { ExpressionVarDeclPart(expr) { return expr.astOfExpression(); }, - ExpressionFunCall(_lookahead, expr, args) { + ExpressionFunCall(_lookahead, expr, arg) { return { kind: "expression_fun_call", object: expr.astOfExpression(), - arguments: args.children.map((x) => x.astOfExpression()), + argument: arg.astOfExpression(), loc: createSrcInfo(this), }; }, - ExpressionArgument(expr) { - return expr.astOfExpression(); - }, // parse_expr100, and some inner things ExpressionPrimary(expr) { diff --git a/src/func/iterators.ts b/src/func/iterators.ts index 2a0dc7a38..3130fa857 100644 --- a/src/func/iterators.ts +++ b/src/func/iterators.ts @@ -62,7 +62,7 @@ export function forEachExpression( case "expression_fun_call": callback(node); forEachExpression(node.object, callback); - node.arguments.forEach((arg) => forEachExpression(arg, callback)); + forEachExpression(node.argument, callback); break; case "expression_tensor": case "expression_tuple": diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index c8ee4dc85..3c0273036 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -575,7 +575,7 @@ export class FuncPrettyPrinter { const calls = node.calls .map( (call) => - `.${this.prettyPrint(call.name)}(${this.prettyPrint(call.argument)})`, + `.${this.prettyPrint(call.name)}${this.prettyPrint(call.argument)}`, ) .join(""); return `${object}${calls}`; @@ -618,10 +618,8 @@ export class FuncPrettyPrinter { node: FuncAstExpressionFunCall, ): string { const object = this.prettyPrint(node.object); - const args = node.arguments - .map((arg) => this.prettyPrint(arg)) - .join(", "); - return `${object}(${args})`; + const tensor = this.prettyPrint(node.argument); + return `${object}${tensor}`; } private prettyPrintExpressionTensor(node: FuncAstExpressionTensor): string { diff --git a/src/func/syntaxConstructors.ts b/src/func/syntaxConstructors.ts index e2d5139fc..3d518ec3b 100644 --- a/src/func/syntaxConstructors.ts +++ b/src/func/syntaxConstructors.ts @@ -205,14 +205,14 @@ export function id(value: string): FuncAstId { export function call( fun: FuncAstExpression | string, - args: FuncAstExpression[], + arg: FuncAstExpressionTensor, // TODO: doesn't support method calls params: Partial<{ receiver: FuncAstExpression }> = {}, ): FuncAstExpressionFunCall { return { kind: "expression_fun_call", object: wrapToId(fun) as FuncAstId, - arguments: args, + argument: arg, loc: dummySrcInfo, }; } diff --git a/src/generatorNew/writers/writeRouter.ts b/src/generatorNew/writers/writeRouter.ts index 13136c12f..5a3650a30 100644 --- a/src/generatorNew/writers/writeRouter.ts +++ b/src/generatorNew/writers/writeRouter.ts @@ -85,7 +85,7 @@ export function writeRouter( // ;; Skip 0xFFFFFFFF // in_msg~skip_bits(32); condBody.push(comment("Skip 0xFFFFFFFF")); - condBody.push(expr(call("in_msg~skip_bits", [int(32)]))); + condBody.push(expr(call("in_msg~skip_bits", tensor(int(32))))); } if (bounceReceivers.length > 0) { @@ -99,7 +99,7 @@ export function writeRouter( condBody.push( condition( binop( - call("slice_bits", [id("in_msg")]), + call("slice_bits", tensor(id("in_msg"))), ">=", int(30), ), @@ -107,7 +107,7 @@ export function writeRouter( expr( assign( id("op"), - call(id("in_msg.preload_uint"), [int(32)]), + call(id("in_msg.preload_uint"), tensor(int(32))), ), ), ], @@ -138,7 +138,7 @@ export function writeRouter( id( `in_msg~${selector.bounced ? ops.readerBounced(selector.type, ctx) : ops.reader(selector.type, ctx)}`, ), - [], + tensor(), ), ), expr( @@ -146,7 +146,7 @@ export function writeRouter( id( `self~${ops.receiveTypeBounce(type.name, selector.type)}`, ), - [id("msg")], + tensor(id("msg")), ), ), ret(tensor(id("self"), bool(true))), @@ -162,9 +162,9 @@ export function writeRouter( body.push(comment("Fallback bounce receiver")); body.push( expr( - call(id(`self~${ops.receiveBounceAny(type.name)}`), [ + call(id(`self~${ops.receiveBounceAny(type.name)}`), tensor( id("in_msg"), - ]), + )), ), ); body.push(ret(tensor(id("self"), bool(true)))); @@ -185,12 +185,12 @@ export function writeRouter( functionBody.push(vardef(Type.int(), "op", int(0))); functionBody.push( condition( - binop(call(id("slice_bits"), [id("in_msg")]), ">=", int(32)), + binop(call(id("slice_bits"), tensor(id("in_msg"))), ">=", int(32)), [ expr( assign( id("op"), - call("in_msg.preload_uint", [int(32)]), + call("in_msg.preload_uint", tensor(int(32))), ), ), ], @@ -217,12 +217,12 @@ export function writeRouter( vardef( "_", "msg", - call(`in_msg~${ops.reader(selector.type, ctx)}`, []), + call(`in_msg~${ops.reader(selector.type, ctx)}`, tensor()), ), expr( call( `self~${ops.receiveType(type.name, kind, selector.type)}`, - [id("msg")], + tensor(id("msg")), ), ), ]), @@ -245,7 +245,7 @@ export function writeRouter( binop(id("op"), "==", int(0)), "&", binop( - call("slice_bits", [id("in_msg")]), + call("slice_bits", tensor(id("in_msg"))), "<=", int(32), ), @@ -254,7 +254,7 @@ export function writeRouter( expr( call( `self~${ops.receiveEmpty(type.name, kind)}`, - [], + tensor(), ), ), ret(tensor(id("self"), bool(true))), @@ -290,7 +290,7 @@ export function writeRouter( ) { // var text_op = slice_hash(in_msg); condBody.push( - vardef("_", "text_op", call("slice_hash", [id("in_msg")])), + vardef("_", "text_op", call("slice_hash", tensor(id("in_msg")))), ); for (const r of type.receivers) { if ( @@ -313,7 +313,7 @@ export function writeRouter( expr( call( `self~${ops.receiveText(type.name, kind, hash)}`, - [], + tensor(), ), ), ret(tensor(id("self"), bool(true))), @@ -335,7 +335,7 @@ export function writeRouter( condBody.push( condition( binop( - call("slice_bits", [id("in_msg")]), + call("slice_bits", tensor(id("in_msg"))), ">=", int(32), ), @@ -345,7 +345,7 @@ export function writeRouter( id( `self~${ops.receiveAnyText(type.name, kind)}`, ), - [call("in_msg.skip_bits", [int(32)])], + tensor(call("in_msg.skip_bits", tensor(int(32)))), ), ), ret(tensor(id("self"), bool(true))), @@ -370,9 +370,9 @@ export function writeRouter( functionBody.push(comment("Receiver fallback")); functionBody.push( expr( - call(`self~${ops.receiveAny(type.name, kind)}`, [ + call(`self~${ops.receiveAny(type.name, kind)}`, tensor( id("in_msg"), - ]), + )), ), ); functionBody.push(ret(tensor(id("self"), bool(true)))); From 59f8936c1e9f63bd08888bc8abbfab9a40fbf412 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 12 Sep 2024 05:56:04 +0000 Subject: [PATCH 158/162] feat(test): Allow lowercase test names --- src/test/new-codegen/codegen.spec.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/new-codegen/codegen.spec.ts b/src/test/new-codegen/codegen.spec.ts index 0a17d69f8..68d577c16 100644 --- a/src/test/new-codegen/codegen.spec.ts +++ b/src/test/new-codegen/codegen.spec.ts @@ -19,12 +19,12 @@ function capitalize(str: string): string { * Generates a Tact configuration file for the given contract (imported from Misti). * @returns Path to entrypoint */ -export function generateConfig(contractName: string): string { +export function generateConfig(contractPath: string, contractName: string): string { const config = { projects: [ { name: `${contractName}`, - path: `./${contractName}.tact`, + path: contractPath, output: `./output`, options: {}, }, @@ -43,9 +43,10 @@ export function generateConfig(contractName: string): string { */ async function compileContract( backend: "new" | "old", + contractPath: string, contractName: string, ): Promise { - const entrypointPath = generateConfig(contractName); + const entrypointPath = generateConfig(contractPath, contractName); // see: pipeline/build.ts const project = createNodeFileSystem(CONTRACTS_DIR, false); @@ -163,8 +164,8 @@ describe("codegen", () => { // Differential tests with the old backend it(`Should compile the ${file} contract`, async () => { Promise.all([ - compileContract("new", contractName), - compileContract("old", contractName), + compileContract("new", file, contractName), + compileContract("old", file, contractName), ]).then(([resultsNew, resultsOld]) => { if (resultsNew.length !== resultsOld.length) { throw new Error("Not all contracts have been compiled"); From 80cc2cf770851b49ba6ce55898f9bd70217ea697 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 12 Sep 2024 05:56:40 +0000 Subject: [PATCH 159/162] fix(pp): Extra dots in new function calls --- src/func/prettyPrinter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index 3c0273036..a5852830d 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -575,7 +575,7 @@ export class FuncPrettyPrinter { const calls = node.calls .map( (call) => - `.${this.prettyPrint(call.name)}${this.prettyPrint(call.argument)}`, + `${this.prettyPrint(call.name)}${this.prettyPrint(call.argument)}`, ) .join(""); return `${object}${calls}`; From deb369f66db7e46378edf8fab0a4fa65edd4e0ef Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 12 Sep 2024 06:24:54 +0000 Subject: [PATCH 160/162] feat(pp): Add pp functions --- src/func/prettyPrinter.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/func/prettyPrinter.ts b/src/func/prettyPrinter.ts index a5852830d..cce4662b0 100644 --- a/src/func/prettyPrinter.ts +++ b/src/func/prettyPrinter.ts @@ -720,3 +720,11 @@ export class FuncPrettyPrinter { return node.value; } } + +export function prettyPrint(node: FuncAstNode): string | never { + return (new FuncPrettyPrinter()).prettyPrint(node); +} + +export function prettyPrintType(ty: FuncAstType): string | never { + return (new FuncPrettyPrinter()).prettyPrintType(ty); +} From 98c6fb99cc4d1c20199583fd43668c59d62eb007 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 12 Sep 2024 06:27:09 +0000 Subject: [PATCH 161/162] fix(writeRouter): Make old `writeReceiver` work with new API functions --- src/generatorNew/writers/writeRouter.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/generatorNew/writers/writeRouter.ts b/src/generatorNew/writers/writeRouter.ts index 5a3650a30..99ab2d585 100644 --- a/src/generatorNew/writers/writeRouter.ts +++ b/src/generatorNew/writers/writeRouter.ts @@ -8,6 +8,7 @@ import { resolveFuncType } from "./resolveFuncTypeNew"; import { resolveFuncTypeUnpack } from "./resolveFuncTypeUnpack"; import { writeStatement } from "./writeFunction"; import { AstNumber } from "../../grammar/ast"; +import { prettyPrintType } from "../../func/prettyPrinter"; import { cr, comment, @@ -404,7 +405,7 @@ export function writeReceiver( ) { const selector = f.selector; const selfRes = resolveFuncTypeUnpack(self, funcIdOf("self"), ctx); - const selfType = resolveFuncType(self, false, false, ctx); + const selfType = prettyPrintType(resolveFuncType(self, false, false, ctx)); const selfUnpack = `var ${resolveFuncTypeUnpack(self, funcIdOf("self"), ctx)} = ${funcIdOf("self")};`; // Binary receiver @@ -414,7 +415,7 @@ export function writeReceiver( ) { const args = [ selfType + " " + funcIdOf("self"), - resolveFuncType(selector.type, false, false, ctx) + " " + funcIdOf(selector.name), + prettyPrintType(resolveFuncType(selector.type, false, false, ctx)) + " " + funcIdOf(selector.name), ]; ctx.append( `((${selfType}), ()) ${ops.receiveType(self.name, selector.kind === "internal-binary" ? "internal" : "external", selector.type)}(${args.join(", ")}) impure inline {`, @@ -580,7 +581,7 @@ export function writeReceiver( if (selector.kind === "bounce-binary") { const args = [ selfType + " " + funcIdOf("self"), - resolveFuncType(selector.type,false, selector.bounced, ctx) + + prettyPrintType(resolveFuncType(selector.type,false, selector.bounced, ctx)) + " " + funcIdOf(selector.name), ]; From dcca629f328f7f6d46999e2272a978e9fa5619fd Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 12 Sep 2024 06:27:33 +0000 Subject: [PATCH 162/162] feat(codegen): Port `writeStdlib` --- src/generatorNew/writers/writeStdlib.ts | 3014 +++++++++-------------- 1 file changed, 1115 insertions(+), 1899 deletions(-) diff --git a/src/generatorNew/writers/writeStdlib.ts b/src/generatorNew/writers/writeStdlib.ts index 8872dbcd3..7d563f8c6 100644 --- a/src/generatorNew/writers/writeStdlib.ts +++ b/src/generatorNew/writers/writeStdlib.ts @@ -1,13 +1,15 @@ +import { WriterContext } from "../Writer"; import { contractErrors } from "../../abi/errors"; -import { maxTupleSize } from "../../bindings/typescript/writeStruct"; import { enabledMasterchain } from "../../config/features"; -import { WriterContext } from "../Writer"; -export function writeStdlib(ctx: WriterContext) { +export function writeStdlib(ctx: WriterContext): void { + const parse = (code: string) => + ctx.parse(code, { context: "stdlib" }); + // // stdlib extension functions // - + // ctx.skip("__tact_set"); ctx.skip("__tact_nop"); ctx.skip("__tact_str_to_slice"); @@ -18,1993 +20,1207 @@ export function writeStdlib(ctx: WriterContext) { // Addresses // - ctx.fun("__tact_verify_address", () => { - ctx.signature(`slice __tact_verify_address(slice address)`); - ctx.flag("impure"); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - throw_unless(${contractErrors.invalidAddress.id}, address.slice_bits() == 267); - var h = address.preload_uint(11); - `); - - if (enabledMasterchain(ctx.ctx)) { - ctx.write(` - throw_unless(${contractErrors.invalidAddress.id}, (h == 1024) | (h == 1279)); - `); - } else { - ctx.write(` - throw_if(${contractErrors.masterchainNotEnabled.id}, h == 1279); - throw_unless(${contractErrors.invalidAddress.id}, h == 1024); - `); - } - ctx.write(` - return address; - `); - }); - }); - - ctx.fun("__tact_load_address", () => { - ctx.signature(`(slice, slice) __tact_load_address(slice cs)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - slice raw = cs~load_msg_addr(); - return (cs, ${ctx.used(`__tact_verify_address`)}(raw)); - `); - }); - }); - - ctx.fun("__tact_load_address_opt", () => { - ctx.signature(`(slice, slice) __tact_load_address_opt(slice cs)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (cs.preload_uint(2) != 0) { - slice raw = cs~load_msg_addr(); - return (cs, ${ctx.used(`__tact_verify_address`)}(raw)); - } else { - cs~skip_bits(2); - return (cs, null()); - } - `); - }); - }); - - ctx.fun("__tact_store_address", () => { - ctx.signature(`builder __tact_store_address(builder b, slice address)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return b.store_slice(${ctx.used(`__tact_verify_address`)}(address)); - `); - }); - }); - - ctx.fun("__tact_store_address_opt", () => { - ctx.signature( - `builder __tact_store_address_opt(builder b, slice address)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(address)) { - b = b.store_uint(0, 2); - return b; - } else { - return ${ctx.used(`__tact_store_address`)}(b, address); - } - `); - }); - }); - - ctx.fun("__tact_create_address", () => { - ctx.signature(`slice __tact_create_address(int chain, int hash)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var b = begin_cell(); - b = b.store_uint(2, 2); - b = b.store_uint(0, 1); - b = b.store_int(chain, 8); - b = b.store_uint(hash, 256); - var addr = b.end_cell().begin_parse(); - return ${ctx.used(`__tact_verify_address`)}(addr); - `); - }); - }); - - ctx.fun("__tact_compute_contract_address", () => { - ctx.signature( - `slice __tact_compute_contract_address(int chain, cell code, cell data)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var b = begin_cell(); - b = b.store_uint(0, 2); - b = b.store_uint(3, 2); - b = b.store_uint(0, 1); - b = b.store_ref(code); - b = b.store_ref(data); - var hash = cell_hash(b.end_cell()); - return ${ctx.used(`__tact_create_address`)}(chain, hash); - `); - }); - }); - - ctx.fun("__tact_not_null", () => { - ctx.signature(`forall X -> X __tact_not_null(X x)`); - ctx.flag("impure"); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write( - `throw_if(${contractErrors.null.id}, null?(x)); return x;`, - ); - }); - }); - - ctx.fun("__tact_dict_delete", () => { - ctx.signature( - `(cell, int) __tact_dict_delete(cell dict, int key_len, slice index)`, - ); - ctx.context("stdlib"); - ctx.asm("(index dict key_len)", "DICTDEL"); - }); - - ctx.fun("__tact_dict_delete_int", () => { - ctx.signature( - `(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index)`, - ); - ctx.context("stdlib"); - ctx.asm("(index dict key_len)", "DICTIDEL"); - }); - - ctx.fun("__tact_dict_delete_uint", () => { - ctx.signature( - `(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index)`, - ); - ctx.context("stdlib"); - ctx.asm("(index dict key_len)", "DICTUDEL"); - }); - - ctx.fun("__tact_dict_set_ref", () => { - ctx.signature( - `((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value)`, - ); - ctx.context("stdlib"); - ctx.asm("(value index dict key_len)", "DICTSETREF"); - }); - - ctx.fun("__tact_dict_get", () => { - ctx.signature( - `(slice, int) __tact_dict_get(cell dict, int key_len, slice index)`, - ); - ctx.context("stdlib"); - ctx.asm("(index dict key_len)", "DICTGET NULLSWAPIFNOT"); - }); - - ctx.fun("__tact_dict_delete_get", () => { - ctx.signature( - `(cell, (slice, int)) __tact_dict_delete_get(cell dict, int key_len, slice index)`, - ); - ctx.context("stdlib"); - ctx.asm("(index dict key_len)", "DICTDELGET NULLSWAPIFNOT2"); - }); - - ctx.fun("__tact_dict_get_ref", () => { - ctx.signature( - `(cell, int) __tact_dict_get_ref(cell dict, int key_len, slice index)`, - ); - ctx.context("stdlib"); - ctx.asm("(index dict key_len)", "DICTGETREF NULLSWAPIFNOT"); - }); - - ctx.fun("__tact_dict_min", () => { - ctx.signature( - `(slice, slice, int) __tact_dict_min(cell dict, int key_len)`, - ); - ctx.context("stdlib"); - ctx.asm("(dict key_len -> 1 0 2)", "DICTMIN NULLSWAPIFNOT2"); - }); - - ctx.fun("__tact_dict_min_ref", () => { - ctx.signature( - `(slice, cell, int) __tact_dict_min_ref(cell dict, int key_len)`, - ); - ctx.context("stdlib"); - ctx.asm("(dict key_len -> 1 0 2)", "DICTMINREF NULLSWAPIFNOT2"); - }); - - ctx.fun("__tact_dict_next", () => { - ctx.signature( - `(slice, slice, int) __tact_dict_next(cell dict, int key_len, slice pivot)`, - ); - ctx.context("stdlib"); - ctx.asm("(pivot dict key_len -> 1 0 2)", "DICTGETNEXT NULLSWAPIFNOT2"); - }); - - ctx.fun("__tact_dict_next_ref", () => { - ctx.signature( - `(slice, cell, int) __tact_dict_next_ref(cell dict, int key_len, slice pivot)`, - ); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = ${ctx.used("__tact_dict_next")}(dict, key_len, pivot); - if (flag) { - return (key, value~load_ref(), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_debug", () => { - ctx.signature( - `forall X -> () __tact_debug(X value, slice debug_print_1, slice debug_print_2)`, - ); - ctx.flag("impure"); - ctx.context("stdlib"); - ctx.asm("", "STRDUMP DROP STRDUMP DROP s0 DUMP DROP"); - }); - - ctx.fun("__tact_debug_str", () => { - ctx.signature( - `() __tact_debug_str(slice value, slice debug_print_1, slice debug_print_2)`, - ); - ctx.flag("impure"); - ctx.context("stdlib"); - ctx.asm("", "STRDUMP DROP STRDUMP DROP STRDUMP DROP"); - }); - - ctx.fun("__tact_debug_bool", () => { - ctx.signature( - `() __tact_debug_bool(int value, slice debug_print_1, slice debug_print_2)`, - ); - ctx.flag("impure"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (value) { - ${ctx.used("__tact_debug_str")}("true", debug_print_1, debug_print_2); - } else { - ${ctx.used("__tact_debug_str")}("false", debug_print_1, debug_print_2); - } - `); - }); - }); - - ctx.fun("__tact_preload_offset", () => { - ctx.signature( - `(slice) __tact_preload_offset(slice s, int offset, int bits)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.asm("", "SDSUBSTR"); - }); - - ctx.fun("__tact_crc16", () => { - ctx.signature(`(slice) __tact_crc16(slice data)`); - ctx.flag("inline_ref"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - slice new_data = begin_cell() - .store_slice(data) - .store_slice("0000"s) - .end_cell().begin_parse(); - int reg = 0; - while (~ new_data.slice_data_empty?()) { - int byte = new_data~load_uint(8); - int mask = 0x80; - while (mask > 0) { - reg <<= 1; - if (byte & mask) { - reg += 1; - } - mask >>= 1; - if (reg > 0xffff) { - reg &= 0xffff; - reg ^= 0x1021; - } - } - } - (int q, int r) = divmod(reg, 256); - return begin_cell() - .store_uint(q, 8) - .store_uint(r, 8) - .end_cell().begin_parse(); - `); - }); - }); - - ctx.fun("__tact_base64_encode", () => { - ctx.signature(`(slice) __tact_base64_encode(slice data)`); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; - builder res = begin_cell(); - - while (data.slice_bits() >= 24) { - (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); - - int n = (bs1 << 16) | (bs2 << 8) | bs3; - - res = res - .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 18) & 63) * 8, 8)) - .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 12) & 63) * 8, 8)) - .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n >> 6) & 63) * 8, 8)) - .store_slice(${ctx.used("__tact_preload_offset")}(chars, ((n ) & 63) * 8, 8)); - } - - return res.end_cell().begin_parse(); - `); - }); - }); - - ctx.fun("__tact_address_to_user_friendly", () => { - ctx.signature(`(slice) __tact_address_to_user_friendly(slice address)`); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - (int wc, int hash) = address.parse_std_addr(); - - slice user_friendly_address = begin_cell() - .store_slice("11"s) - .store_uint((wc + 0x100) % 0x100, 8) - .store_uint(hash, 256) - .end_cell().begin_parse(); - - slice checksum = ${ctx.used("__tact_crc16")}(user_friendly_address); - slice user_friendly_address_with_checksum = begin_cell() - .store_slice(user_friendly_address) - .store_slice(checksum) - .end_cell().begin_parse(); - - return ${ctx.used("__tact_base64_encode")}(user_friendly_address_with_checksum); - `); - }); - }); - - ctx.fun("__tact_debug_address", () => { - ctx.signature( - `() __tact_debug_address(slice address, slice debug_print_1, slice debug_print_2)`, - ); - ctx.flag("impure"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - ${ctx.used("__tact_debug_str")}(${ctx.used("__tact_address_to_user_friendly")}(address), debug_print_1, debug_print_2); - `); - }); - }); - - ctx.fun("__tact_debug_stack", () => { - ctx.signature( - `() __tact_debug_stack(slice debug_print_1, slice debug_print_2)`, - ); - ctx.flag("impure"); - ctx.context("stdlib"); - ctx.asm("", "STRDUMP DROP STRDUMP DROP DUMPSTK"); - }); - - ctx.fun("__tact_context_get", () => { - ctx.signature(`(int, slice, int, slice) __tact_context_get()`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(`return __tact_context;`); - }); - }); - - ctx.fun("__tact_context_get_sender", () => { - ctx.signature(`slice __tact_context_get_sender()`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(`return __tact_context_sender;`); - }); - }); - - ctx.fun("__tact_prepare_random", () => { - ctx.signature(`() __tact_prepare_random()`); - ctx.flag("impure"); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(__tact_randomized)) { - randomize_lt(); - __tact_randomized = true; - } - `); - }); - }); - - ctx.fun("__tact_store_bool", () => { - ctx.signature(`builder __tact_store_bool(builder b, int v)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return b.store_int(v, 1); - `); - }); - }); - - ctx.fun("__tact_to_tuple", () => { - ctx.signature(`forall X -> tuple __tact_to_tuple(X x)`); - ctx.context("stdlib"); - ctx.asm("", "NOP"); - }); - - ctx.fun("__tact_from_tuple", () => { - ctx.signature(`forall X -> X __tact_from_tuple(tuple x)`); - ctx.context("stdlib"); - ctx.asm("", "NOP"); - }); - - // - // Dict Int -> Int - // - - ctx.fun("__tact_dict_set_int_int", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = idict_delete?(d, kl, k); - return (r, ()); - } else { - return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_int_int", () => { - ctx.signature( - `int __tact_dict_get_int_int(cell d, int kl, int k, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = idict_get?(d, kl, k); - if (ok) { - return r~load_int(vl); - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_int_int", () => { - ctx.signature( - `(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = idict_get_min?(d, kl); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); + parse( + `slice __tact_verify_address(slice address) impure inline { + throw_unless(${contractErrors.invalidAddress.id}, address.slice_bits() == 267); + var h = address.preload_uint(11); + + ${ + enabledMasterchain(ctx.ctx) + ? ` + throw_unless(${contractErrors.invalidAddress.id}, (h == 1024) | (h == 1279)); + ` + : ` + throw_if(${contractErrors.masterchainNotEnabled.id}, h == 1279); + throw_unless(${contractErrors.invalidAddress.id}, h == 1024); + ` + } + + return address; + }`, + ); + + parse(`(slice, int) __tact_load_bool(slice s) asm(s -> 1 0) "1 LDI";`); + + parse( + `(slice, slice) __tact_load_address(slice cs) inline { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); + }`, + ); + + parse( + `(slice, slice) __tact_load_address_opt(slice cs) inline { + if (cs.preload_uint(2) != 0) { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); + } else { + cs~skip_bits(2); + return (cs, null()); + } + }`, + ); + + parse( + `builder __tact_store_address(builder b, slice address) inline { + return b.store_slice(__tact_verify_address(address)); + }`, + ); + + parse( + `builder __tact_store_address_opt(builder b, slice address) inline { + if (null?(address)) { + b = b.store_uint(0, 2); + return b; + } else { + return __tact_store_address(b, address); + } + }`, + ); + + parse( + `slice __tact_create_address(int chain, int hash) inline { + var b = begin_cell(); + b = b.store_uint(2, 2); + b = b.store_uint(0, 1); + b = b.store_int(chain, 8); + b = b.store_uint(hash, 256); + var addr = b.end_cell().begin_parse(); + return __tact_verify_address(addr); + }`, + ); + + parse( + `slice __tact_compute_contract_address(int chain, cell code, cell data) inline { + var b = begin_cell(); + b = b.store_uint(0, 2); + b = b.store_uint(3, 2); + b = b.store_uint(0, 1); + b = b.store_ref(code); + b = b.store_ref(data); + var hash = cell_hash(b.end_cell()); + return __tact_create_address(chain, hash); + }`, + ); + + parse( + `int __tact_my_balance() inline { + return pair_first(get_balance()); + }`, + ); + + parse( + `forall X -> X __tact_not_null(X x) inline { + throw_if(${contractErrors.null.id}, null?(x)); + return x; + }`, + ); + + parse( + `(cell, int) __tact_dict_delete(cell dict, int key_len, slice index) asm(index dict key_len) "DICTDEL";`, + ); + + parse( + `(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL";`, + ); + + parse( + `(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL";`, + ); + + parse( + `((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value) asm(value index dict key_len) "DICTSETREF";`, + ); + + parse( + `(slice, int) __tact_dict_get(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGET" "NULLSWAPIFNOT";`, + ); + + parse( + `(cell, int) __tact_dict_get_ref(cell dict, int key_len, slice index) asm(index dict key_len) "DICTGETREF" "NULLSWAPIFNOT";`, + ); + + parse( + `(slice, slice, int) __tact_dict_min(cell dict, int key_len) asm(dict key_len -> 1 0 2) "DICTMIN" "NULLSWAPIFNOT2";`, + ); + + parse( + `(slice, cell, int) __tact_dict_min_ref(cell dict, int key_len) asm(dict key_len -> 1 0 2) "DICTMINREF" "NULLSWAPIFNOT2";`, + ); + + parse( + `(slice, slice, int) __tact_dict_next(cell dict, int key_len, slice pivot) asm(pivot dict key_len -> 1 0 2) "DICTGETNEXT" "NULLSWAPIFNOT2";`, + ); + + parse( + `(slice, cell, int) __tact_dict_next_ref(cell dict, int key_len, slice pivot) inline { + var (key, value, flag) = __tact_dict_next(dict, key_len, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `forall X -> () __tact_debug(X value, slice debug_print) impure asm "STRDUMP" "DROP" "s0 DUMP" "DROP";`, + ); + + parse( + `() __tact_debug_str(slice value, slice debug_print) impure asm "STRDUMP" "DROP" "STRDUMP" "DROP";`, + ); + + parse( + `() __tact_debug_bool(int value, slice debug_print) impure { + if (value) { + __tact_debug_str("true", debug_print); + } else { + __tact_debug_str("false", debug_print); + } + }`, + ); + + parse( + `(slice) __tact_preload_offset(slice s, int offset, int bits) inline asm "SDSUBSTR";`, + ); + + parse( + `(slice) __tact_crc16(slice data) inline_ref { + slice new_data = begin_cell() + .store_slice(data) + .store_slice("0000"s) + .end_cell().begin_parse(); + int reg = 0; + while (~new_data.slice_data_empty?()) { + int byte = new_data~load_uint(8); + int mask = 0x80; + while (mask > 0) { + reg <<= 1; + if (byte & mask) { + reg += 1; + } + mask >>= 1; + if (reg > 0xffff) { + reg &= 0xffff; + reg ^= 0x1021; } - `); - }); - }); - - ctx.fun("__tact_dict_next_int_int", () => { - ctx.signature( - `(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = idict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + } + } + (int q, int r) = divmod(reg, 256); + return begin_cell() + .store_uint(q, 8) + .store_uint(r, 8) + .end_cell().begin_parse(); + }`, + ); + + parse( + `(slice) __tact_base64_encode(slice data) inline { + slice chars = "4142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392D5F"s; + builder res = begin_cell(); + + while (data.slice_bits() >= 24) { + (int bs1, int bs2, int bs3) = (data~load_uint(8), data~load_uint(8), data~load_uint(8)); + + int n = (bs1 << 16) | (bs2 << 8) | bs3; + + res = res + .store_slice(__tact_preload_offset(chars, ((n >> 18) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 12) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n >> 6) & 63) * 8, 8)) + .store_slice(__tact_preload_offset(chars, ((n ) & 63) * 8, 8)); + } + + return res.end_cell().begin_parse(); + }`, + ); + + parse( + `(slice) __tact_address_to_user_friendly(slice address) inline { + (int wc, int hash) = address.parse_std_addr(); + + slice user_friendly_address = begin_cell() + .store_slice("11"s) + .store_uint((wc + 0x100) % 0x100, 8) + .store_uint(hash, 256) + .end_cell().begin_parse(); + + slice checksum = __tact_crc16(user_friendly_address); + slice user_friendly_address_with_checksum = begin_cell() + .store_slice(user_friendly_address) + .store_slice(checksum) + .end_cell().begin_parse(); + + return __tact_base64_encode(user_friendly_address_with_checksum); + }`, + ); + + parse( + `() __tact_debug_address(slice address, slice debug_print) impure { + __tact_debug_str(__tact_address_to_user_friendly(address), debug_print); + }`, + ); + + parse( + `() __tact_debug_stack(slice debug_print) impure asm "STRDUMP" "DROP" "DUMPSTK";`, + ); + + parse( + `(int, slice, int, slice) __tact_context_get() inline { + return __tact_context; + }`, + ); + + parse( + `slice __tact_context_get_sender() inline { + return __tact_context_sender; + }`, + ); + + parse( + `() __tact_prepare_random() impure inline { + if (null?(__tact_randomized)) { + randomize_lt(); + __tact_randomized = true; + } + }`, + ); + + parse( + `builder __tact_store_bool(builder b, int v) inline { + return b.store_int(v, 1); + }`, + ); + + parse(`forall X -> tuple __tact_to_tuple(X x) asm "NOP";`); + + parse(`forall X -> X __tact_from_tuple(tuple x) asm "NOP";`); // // Dict Int -> Int // - ctx.fun("__tact_dict_set_int_uint", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_int_uint(cell d, int kl, int k, int v, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = idict_delete?(d, kl, k); - return (r, ()); - } else { - return (idict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_int_uint", () => { - ctx.signature( - `int __tact_dict_get_int_uint(cell d, int kl, int k, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = idict_get?(d, kl, k); - if (ok) { - return r~load_uint(vl); - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_int_uint", () => { - ctx.signature( - `(int, int, int) __tact_dict_min_int_uint(cell d, int kl, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = idict_get_min?(d, kl); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_dict_next_int_uint", () => { - ctx.signature( - `(int, int, int) __tact_dict_next_int_uint(cell d, int kl, int pivot, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = idict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_int_int(cell d, int kl, int k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + } + }`, + ); + + parse( + `int __tact_dict_get_int_int(cell d, int kl, int k, int vl) inline { + var (r, ok) = idict_get?(d, kl, k); + if (ok) { + return r~load_int(vl); + } else { + return null(); + } + }`, + ); + + parse( + `(int, int, int) __tact_dict_min_int_int(cell d, int kl, int vl) inline { + var (key, value, flag) = idict_get_min?(d, kl); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(int, int, int) __tact_dict_next_int_int(cell d, int kl, int pivot, int vl) inline { + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); // - // Dict Uint -> Int + // Dict Int -> Uint // - ctx.fun("__tact_dict_set_uint_int", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = udict_delete?(d, kl, k); - return (r, ()); - } else { - return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_uint_int", () => { - ctx.signature( - `int __tact_dict_get_uint_int(cell d, int kl, int k, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = udict_get?(d, kl, k); - if (ok) { - return r~load_int(vl); - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_uint_int", () => { - ctx.signature( - `(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = udict_get_min?(d, kl); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_dict_next_uint_int", () => { - ctx.signature( - `(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = udict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_uint_int(cell d, int kl, int k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + } + }`, + ); + + parse( + `int __tact_dict_get_uint_int(cell d, int kl, int k, int vl) inline { + var (r, ok) = udict_get?(d, kl, k); + if (ok) { + return r~load_int(vl); + } else { + return null(); + } + }`, + ); + + parse( + `(int, int, int) __tact_dict_min_uint_int(cell d, int kl, int vl) inline { + var (key, value, flag) = udict_get_min?(d, kl); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(int, int, int) __tact_dict_next_uint_int(cell d, int kl, int pivot, int vl) inline { + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); // // Dict Uint -> Uint // - ctx.fun("__tact_dict_set_uint_uint", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = udict_delete?(d, kl, k); - return (r, ()); - } else { - return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_uint_uint", () => { - ctx.signature( - `int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = udict_get?(d, kl, k); - if (ok) { - return r~load_uint(vl); - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_uint_uint", () => { - ctx.signature( - `(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = udict_get_min?(d, kl); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_dict_next_uint_uint", () => { - ctx.signature( - `(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = udict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_uint_uint(cell d, int kl, int k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + } + }`, + ); + + parse( + `int __tact_dict_get_uint_uint(cell d, int kl, int k, int vl) inline { + var (r, ok) = udict_get?(d, kl, k); + if (ok) { + return r~load_uint(vl); + } else { + return null(); + } + }`, + ); + + parse( + `(int, int, int) __tact_dict_min_uint_uint(cell d, int kl, int vl) inline { + var (key, value, flag) = udict_get_min?(d, kl); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(int, int, int) __tact_dict_next_uint_uint(cell d, int kl, int pivot, int vl) inline { + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); // // Dict Int -> Cell // - ctx.fun("__tact_dict_set_int_cell", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = idict_delete?(d, kl, k); - return (r, ()); - } else { - return (idict_set_ref(d, kl, k, v), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_int_cell", () => { - ctx.signature(`cell __tact_dict_get_int_cell(cell d, int kl, int k)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = idict_get_ref?(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_int_cell", () => { - ctx.signature( - `(int, cell, int) __tact_dict_min_int_cell(cell d, int kl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = idict_get_min_ref?(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_dict_next_int_cell", () => { - ctx.signature( - `(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = idict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_ref(), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_int_cell(cell d, int kl, int k, cell v) inline { + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set_ref(d, kl, k, v), ()); + } + }`, + ); + + parse( + `cell __tact_dict_get_int_cell(cell d, int kl, int k) inline { + var (r, ok) = idict_get_ref?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + ); + + parse( + `(int, cell, int) __tact_dict_min_int_cell(cell d, int kl) inline { + var (key, value, flag) = idict_get_min_ref?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(int, cell, int) __tact_dict_next_int_cell(cell d, int kl, int pivot) inline { + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + }`, + ); // // Dict Uint -> Cell // - ctx.fun("__tact_dict_set_uint_cell", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = udict_delete?(d, kl, k); - return (r, ()); - } else { - return (udict_set_ref(d, kl, k, v), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_uint_cell", () => { - ctx.signature(`cell __tact_dict_get_uint_cell(cell d, int kl, int k)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = udict_get_ref?(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_uint_cell", () => { - ctx.signature( - `(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = udict_get_min_ref?(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_dict_next_uint_cell", () => { - ctx.signature( - `(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = udict_get_next?(d, kl, pivot); - if (flag) { - return (key, value~load_ref(), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_uint_cell(cell d, int kl, int k, cell v) inline { + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set_ref(d, kl, k, v), ()); + } + }`, + ); + + parse( + `cell __tact_dict_get_uint_cell(cell d, int kl, int k) inline { + var (r, ok) = udict_get_ref?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + ); + + parse( + `(int, cell, int) __tact_dict_min_uint_cell(cell d, int kl) inline { + var (key, value, flag) = udict_get_min_ref?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(int, cell, int) __tact_dict_next_uint_cell(cell d, int kl, int pivot) inline { + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + }`, + ); // // Dict Int -> Slice // - ctx.fun("__tact_dict_set_int_slice", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = idict_delete?(d, kl, k); - return (r, ()); - } else { - return (idict_set(d, kl, k, v), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_int_slice", () => { - ctx.signature(`slice __tact_dict_get_int_slice(cell d, int kl, int k)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = idict_get?(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_int_slice", () => { - ctx.signature( - `(int, slice, int) __tact_dict_min_int_slice(cell d, int kl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = idict_get_min?(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_dict_next_int_slice", () => { - ctx.signature( - `(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = idict_get_next?(d, kl, pivot); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_int_slice(cell d, int kl, int k, slice v) inline { + if (null?(v)) { + var (r, ok) = idict_delete?(d, kl, k); + return (r, ()); + } else { + return (idict_set(d, kl, k, v), ()); + } + }`, + ); + + parse( + `slice __tact_dict_get_int_slice(cell d, int kl, int k) inline { + var (r, ok) = idict_get?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + ); + + parse( + `(int, slice, int) __tact_dict_min_int_slice(cell d, int kl) inline { + var (key, value, flag) = idict_get_min?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(int, slice, int) __tact_dict_next_int_slice(cell d, int kl, int pivot) inline { + var (key, value, flag) = idict_get_next?(d, kl, pivot); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + ); // // Dict Uint -> Slice // - ctx.fun("__tact_dict_set_uint_slice", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = udict_delete?(d, kl, k); - return (r, ()); - } else { - return (udict_set(d, kl, k, v), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_uint_slice", () => { - ctx.signature( - `slice __tact_dict_get_uint_slice(cell d, int kl, int k)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = udict_get?(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_uint_slice", () => { - ctx.signature( - `(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = udict_get_min?(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_dict_next_uint_slice", () => { - ctx.signature( - `(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = udict_get_next?(d, kl, pivot); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_uint_slice(cell d, int kl, int k, slice v) inline { + if (null?(v)) { + var (r, ok) = udict_delete?(d, kl, k); + return (r, ()); + } else { + return (udict_set(d, kl, k, v), ()); + } + }`, + ); + + parse( + `slice __tact_dict_get_uint_slice(cell d, int kl, int k) inline { + var (r, ok) = udict_get?(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + ); + + parse( + `(int, slice, int) __tact_dict_min_uint_slice(cell d, int kl) inline { + var (key, value, flag) = udict_get_min?(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(int, slice, int) __tact_dict_next_uint_slice(cell d, int kl, int pivot) inline { + var (key, value, flag) = udict_get_next?(d, kl, pivot); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + ); // // Dict Slice -> Int // - ctx.fun("__tact_dict_set_slice_int", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); - return (r, ()); - } else { - return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_slice_int", () => { - ctx.signature( - `int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); - if (ok) { - return r~load_int(vl); - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_slice_int", () => { - ctx.signature( - `(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_dict_next_slice_int", () => { - ctx.signature( - `(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); - if (flag) { - return (key, value~load_int(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_slice_int(cell d, int kl, slice k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); + } else { + return (dict_set_builder(d, kl, k, begin_cell().store_int(v, vl)), ()); + } + }`, + ); + + parse( + `int __tact_dict_get_slice_int(cell d, int kl, slice k, int vl) inline { + var (r, ok) = __tact_dict_get(d, kl, k); + if (ok) { + return r~load_int(vl); + } else { + return null(); + } + }`, + ); + + parse( + `(slice, int, int) __tact_dict_min_slice_int(cell d, int kl, int vl) inline { + var (key, value, flag) = __tact_dict_min(d, kl); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(slice, int, int) __tact_dict_next_slice_int(cell d, int kl, slice pivot, int vl) inline { + var (key, value, flag) = __tact_dict_next(d, kl, pivot); + if (flag) { + return (key, value~load_int(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); // // Dict Slice -> UInt // - ctx.fun("__tact_dict_set_slice_uint", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); - return (r, ()); - } else { - return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); - } - `); - }); - }); - - ctx.fun("__tact_dict_get_slice_uint", () => { - ctx.signature( - `int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); - if (ok) { - return r~load_uint(vl); - } else { - return null(); - } - `); - }); - }); - - ctx.fun("__tact_dict_min_slice_uint", () => { - ctx.signature( - `(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun("__tact_dict_next_slice_uint", () => { - ctx.signature( - `(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); - if (flag) { - return (key, value~load_uint(vl), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_slice_uint(cell d, int kl, slice k, int v, int vl) inline { + if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); + } else { + return (dict_set_builder(d, kl, k, begin_cell().store_uint(v, vl)), ()); + } + }`, + ); + + parse( + `int __tact_dict_get_slice_uint(cell d, int kl, slice k, int vl) inline { + var (r, ok) = __tact_dict_get(d, kl, k); + if (ok) { + return r~load_uint(vl); + } else { + return null(); + } + }`, + ); + + parse( + `(slice, int, int) __tact_dict_min_slice_uint(cell d, int kl, int vl) inline { + var (key, value, flag) = __tact_dict_min(d, kl); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(slice, int, int) __tact_dict_next_slice_uint(cell d, int kl, slice pivot, int vl) inline { + var (key, value, flag) = __tact_dict_next(d, kl, pivot); + if (flag) { + return (key, value~load_uint(vl), flag); + } else { + return (null(), null(), flag); + } + }`, + ); // // Dict Slice -> Cell // - ctx.fun("__tact_dict_set_slice_cell", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); - return (r, ()); - } else { - return ${ctx.used(`__tact_dict_set_ref`)}(d, kl, k, v); - } - `); - }); - }); - - ctx.fun(`__tact_dict_get_slice_cell`, () => { - ctx.signature( - `cell __tact_dict_get_slice_cell(cell d, int kl, slice k)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = ${ctx.used(`__tact_dict_get_ref`)}(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - `); - }); - }); - - ctx.fun(`__tact_dict_min_slice_cell`, () => { - ctx.signature( - `(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = ${ctx.used(`__tact_dict_min_ref`)}(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun(`__tact_dict_next_slice_cell`, () => { - ctx.signature( - `(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); - if (flag) { - return (key, value~load_ref(), flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_slice_cell(cell d, int kl, slice k, cell v) inline { + if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); + } else { + return __tact_dict_set_ref(d, kl, k, v); + } + }`, + ); + + parse( + `cell __tact_dict_get_slice_cell(cell d, int kl, slice k) inline { + var (r, ok) = __tact_dict_get_ref(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + ); + + parse( + `(slice, cell, int) __tact_dict_min_slice_cell(cell d, int kl) inline { + var (key, value, flag) = __tact_dict_min_ref(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(slice, cell, int) __tact_dict_next_slice_cell(cell d, int kl, slice pivot) inline { + var (key, value, flag) = __tact_dict_next(d, kl, pivot); + if (flag) { + return (key, value~load_ref(), flag); + } else { + return (null(), null(), flag); + } + }`, + ); // // Dict Slice -> Slice // - ctx.fun("__tact_dict_set_slice_slice", () => { - ctx.signature( - `(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - if (null?(v)) { - var (r, ok) = ${ctx.used(`__tact_dict_delete`)}(d, kl, k); - return (r, ()); - } else { - return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); - } - `); - }); - }); - - ctx.fun(`__tact_dict_get_slice_slice`, () => { - ctx.signature( - `slice __tact_dict_get_slice_slice(cell d, int kl, slice k)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); - if (ok) { - return r; - } else { - return null(); - } - `); - }); - }); - - ctx.fun(`__tact_dict_min_slice_slice`, () => { - ctx.signature( - `(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (key, value, flag) = ${ctx.used(`__tact_dict_min`)}(d, kl); - if (flag) { - return (key, value, flag); - } else { - return (null(), null(), flag); - } - `); - }); - }); - - ctx.fun(`__tact_dict_next_slice_slice`, () => { - ctx.signature( - `(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return ${ctx.used(`__tact_dict_next`)}(d, kl, pivot); - `); - }); - }); + parse( + `(cell, ()) __tact_dict_set_slice_slice(cell d, int kl, slice k, slice v) inline { + if (null?(v)) { + var (r, ok) = __tact_dict_delete(d, kl, k); + return (r, ()); + } else { + return (dict_set_builder(d, kl, k, begin_cell().store_slice(v)), ()); + } + }`, + ); + + parse( + `slice __tact_dict_get_slice_slice(cell d, int kl, slice k) inline { + var (r, ok) = __tact_dict_get(d, kl, k); + if (ok) { + return r; + } else { + return null(); + } + }`, + ); + + parse( + `(slice, slice, int) __tact_dict_min_slice_slice(cell d, int kl) inline { + var (key, value, flag) = __tact_dict_min(d, kl); + if (flag) { + return (key, value, flag); + } else { + return (null(), null(), flag); + } + }`, + ); + + parse( + `(slice, slice, int) __tact_dict_next_slice_slice(cell d, int kl, slice pivot) inline { + return __tact_dict_next(d, kl, pivot); + }`, + ); // // Address // - ctx.fun(`__tact_slice_eq_bits`, () => { - ctx.signature(`int __tact_slice_eq_bits(slice a, slice b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return equal_slices_bits(a, b); - `); - }); - }); - - ctx.fun(`__tact_slice_eq_bits_nullable_one`, () => { - ctx.signature( - `int __tact_slice_eq_bits_nullable_one(slice a, slice b)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (null?(a)) ? (false) : (equal_slices_bits(a, b)); - `); - }); - }); - - ctx.fun(`__tact_slice_eq_bits_nullable`, () => { - ctx.signature(`int __tact_slice_eq_bits_nullable(slice a, slice b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var a_is_null = null?(a); - var b_is_null = null?(b); - return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( equal_slices_bits(a, b) ) : ( false ) ); - `); - }); - }); - - // - // Dictionary deep equality - // - - ctx.fun(`__tact_dict_eq`, () => { - ctx.signature(`int __tact_dict_eq(cell a, cell b, int kl)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - (slice key, slice value, int flag) = ${ctx.used("__tact_dict_min")}(a, kl); - while (flag) { - (slice value_b, int flag_b) = b~${ctx.used("__tact_dict_delete_get")}(kl, key); - ifnot (flag_b) { - return 0; - } - ifnot (value.slice_hash() == value_b.slice_hash()) { - return 0; - } - (key, value, flag) = ${ctx.used("__tact_dict_next")}(a, kl, key); - } - return null?(b); - `); - }); - }); + parse( + `int __tact_slice_eq_bits(slice a, slice b) inline { + return equal_slice_bits(a, b); + }`, + ); + + parse( + `int __tact_slice_eq_bits_nullable_one(slice a, slice b) inline { + return (null?(a)) ? (false) : (equal_slice_bits(a, b)); + }`, + ); + + parse( + `int __tact_slice_eq_bits_nullable(slice a, slice b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (equal_slice_bits(a, b)) : (false); + }`, + ); // // Int Eq // - ctx.fun(`__tact_int_eq_nullable_one`, () => { - ctx.signature(`int __tact_int_eq_nullable_one(int a, int b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (null?(a)) ? (false) : (a == b); - `); - }); - }); - - ctx.fun(`__tact_int_neq_nullable_one`, () => { - ctx.signature(`int __tact_int_neq_nullable_one(int a, int b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (null?(a)) ? (true) : (a != b); - `); - }); - }); - - ctx.fun(`__tact_int_eq_nullable`, () => { - ctx.signature(`int __tact_int_eq_nullable(int a, int b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var a_is_null = null?(a); - var b_is_null = null?(b); - return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a == b ) : ( false ) ); - `); - }); - }); - - ctx.fun(`__tact_int_neq_nullable`, () => { - ctx.signature(`int __tact_int_neq_nullable(int a, int b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var a_is_null = null?(a); - var b_is_null = null?(b); - return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a != b ) : ( true ) ); - `); - }); - }); + parse( + `int __tact_int_eq_nullable_one(int a, int b) inline { + return (null?(a)) ? (false) : (a == b); + }`, + ); + + parse( + `int __tact_int_neq_nullable_one(int a, int b) inline { + return (null?(a)) ? (true) : (a != b); + }`, + ); + + parse( + `int __tact_int_eq_nullable(int a, int b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a == b) : (false); + }`, + ); + + parse( + `int __tact_int_neq_nullable(int a, int b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a != b) : (true); + }`, + ); // // Cell Eq // - ctx.fun(`__tact_cell_eq`, () => { - ctx.signature(`int __tact_cell_eq(cell a, cell b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (a.cell_hash() == b.cell_hash()); - `); - }); - }); - - ctx.fun(`__tact_cell_neq`, () => { - ctx.signature(`int __tact_cell_neq(cell a, cell b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (a.cell_hash() != b.cell_hash()); - `); - }); - }); - - ctx.fun(`__tact_cell_eq_nullable_one`, () => { - ctx.signature(`int __tact_cell_eq_nullable_one(cell a, cell b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash()); - `); - }); - }); - - ctx.fun(`__tact_cell_neq_nullable_one`, () => { - ctx.signature(`int __tact_cell_neq_nullable_one(cell a, cell b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash()); - `); - }); - }); - - ctx.fun(`__tact_cell_eq_nullable`, () => { - ctx.signature(`int __tact_cell_eq_nullable(cell a, cell b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var a_is_null = null?(a); - var b_is_null = null?(b); - return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() == b.cell_hash() ) : ( false ) ); - `); - }); - }); - - ctx.fun(`__tact_cell_neq_nullable`, () => { - ctx.signature(`int __tact_cell_neq_nullable(cell a, cell b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var a_is_null = null?(a); - var b_is_null = null?(b); - return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.cell_hash() != b.cell_hash() ) : ( true ) ); - `); - }); - }); + parse( + `int __tact_cell_eq(cell a, cell b) inline { + return (a.cell_hash() == b.cell_hash()); + }`, + ); + + parse( + `int __tact_cell_neq(cell a, cell b) inline { + return (a.cell_hash() != b.cell_hash()); + }`, + ); + + parse( + `int __tact_cell_eq_nullable_one(cell a, cell b) inline { + return (null?(a)) ? (false) : (a.cell_hash() == b.cell_hash()); + }`, + ); + + parse( + `int __tact_cell_neq_nullable_one(cell a, cell b) inline { + return (null?(a)) ? (true) : (a.cell_hash() != b.cell_hash()); + }`, + ); + + parse( + `int __tact_cell_eq_nullable(cell a, cell b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a.cell_hash() == b.cell_hash()) : (false); + }`, + ); + + parse( + `int __tact_cell_neq_nullable(cell a, cell b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a.cell_hash() != b.cell_hash()) : (true); + }`, + ); // // Slice Eq // - ctx.fun(`__tact_slice_eq`, () => { - ctx.signature(`int __tact_slice_eq(slice a, slice b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (a.slice_hash() == b.slice_hash()); - `); - }); - }); - - ctx.fun(`__tact_slice_neq`, () => { - ctx.signature(`int __tact_slice_neq(slice a, slice b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (a.slice_hash() != b.slice_hash()); - `); - }); - }); - - ctx.fun(`__tact_slice_eq_nullable_one`, () => { - ctx.signature(`int __tact_slice_eq_nullable_one(slice a, slice b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash()); - `); - }); - }); - - ctx.fun(`__tact_slice_neq_nullable_one`, () => { - ctx.signature(`int __tact_slice_neq_nullable_one(slice a, slice b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash()); - `); - }); - }); - - ctx.fun(`__tact_slice_eq_nullable`, () => { - ctx.signature(`int __tact_slice_eq_nullable(slice a, slice b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var a_is_null = null?(a); - var b_is_null = null?(b); - return ( a_is_null & b_is_null ) ? ( true ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() == b.slice_hash() ) : ( false ) ); - `); - }); - }); - - ctx.fun(`__tact_slice_neq_nullable`, () => { - ctx.signature(`int __tact_slice_neq_nullable(slice a, slice b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var a_is_null = null?(a); - var b_is_null = null?(b); - return ( a_is_null & b_is_null ) ? ( false ) : ( ( ( ~ a_is_null ) & ( ~ b_is_null ) ) ? ( a.slice_hash() != b.slice_hash() ) : ( true ) ); - `); - }); - }); + parse( + `int __tact_slice_eq(slice a, slice b) inline { + return (a.slice_hash() == b.slice_hash()); + }`, + ); + + parse( + `int __tact_slice_neq(slice a, slice b) inline { + return (a.slice_hash() != b.slice_hash()); + }`, + ); + + parse( + `int __tact_slice_eq_nullable_one(slice a, slice b) inline { + return (null?(a)) ? (false) : (a.slice_hash() == b.slice_hash()); + }`, + ); + + parse( + `int __tact_slice_neq_nullable_one(slice a, slice b) inline { + return (null?(a)) ? (true) : (a.slice_hash() != b.slice_hash()); + }`, + ); + + parse( + `int __tact_slice_eq_nullable(slice a, slice b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (true) : ((~a_is_null) & (~b_is_null)) ? (a.slice_hash() == b.slice_hash()) : (false); + }`, + ); + + parse( + `int __tact_slice_neq_nullable(slice a, slice b) inline { + var a_is_null = null?(a); + var b_is_null = null?(b); + return (a_is_null & b_is_null) ? (false) : ((~a_is_null) & (~b_is_null)) ? (a.slice_hash() != b.slice_hash()) : (true); + }`, + ); // // Sys Dict // - ctx.fun(`__tact_dict_set_code`, () => { - ctx.signature( - `cell __tact_dict_set_code(cell dict, int id, cell code)`, - ); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return udict_set_ref(dict, 16, id, code); - `); - }); - }); - - ctx.fun(`__tact_dict_get_code`, () => { - ctx.signature(`cell __tact_dict_get_code(cell dict, int id)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (data, ok) = udict_get_ref?(dict, 16, id); - throw_unless(${contractErrors.codeNotFound.id}, ok); - return data; - `); - }); - }); + parse( + `cell __tact_dict_set_code(cell dict, int id, cell code) inline { + return udict_set_ref(dict, 16, id, code); + }`, + ); + + parse( + `cell __tact_dict_get_code(cell dict, int id) inline { + var (data, ok) = udict_get_ref?(dict, 16, id); + throw_unless(${contractErrors.codeNotFound.id}, ok); + return data; + }`, + ); // // Tuples // - ctx.fun(`__tact_tuple_create_0`, () => { - ctx.signature(`tuple __tact_tuple_create_0()`); - ctx.context("stdlib"); - ctx.asm("", "NIL"); - }); - ctx.fun(`__tact_tuple_destroy_0`, () => { - ctx.signature(`() __tact_tuple_destroy_0()`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.append(`return ();`); - }); - }); - - for (let i = 1; i <= maxTupleSize; i++) { - ctx.fun(`__tact_tuple_create_${i}`, () => { - const args: string[] = []; - for (let j = 0; j < i; j++) { - args.push(`X${j}`); - } - ctx.signature( - `forall ${args.join(", ")} -> tuple __tact_tuple_create_${i}((${args.join(", ")}) v)`, - ); - ctx.context("stdlib"); - ctx.asm("", `${i} TUPLE`); - }); - ctx.fun(`__tact_tuple_destroy_${i}`, () => { - const args: string[] = []; - for (let j = 0; j < i; j++) { - args.push(`X${j}`); - } - ctx.signature( - `forall ${args.join(", ")} -> (${args.join(", ")}) __tact_tuple_destroy_${i}(tuple v)`, - ); - ctx.context("stdlib"); - ctx.asm("", `${i} UNTUPLE`); - }); - } + parse(`tuple __tact_tuple_create_0() asm "NIL";`); - // - // Strings - // + parse( + `() __tact_tuple_destroy_0() inline { + return (); + }`, + ); - ctx.fun(`__tact_string_builder_start_comment`, () => { - ctx.signature(`tuple __tact_string_builder_start_comment()`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return ${ctx.used("__tact_string_builder_start")}(begin_cell().store_uint(0, 32)); - `); - }); - }); - - ctx.fun(`__tact_string_builder_start_tail_string`, () => { - ctx.signature(`tuple __tact_string_builder_start_tail_string()`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return ${ctx.used("__tact_string_builder_start")}(begin_cell().store_uint(0, 8)); - `); - }); - }); - - ctx.fun(`__tact_string_builder_start_string`, () => { - ctx.signature(`tuple __tact_string_builder_start_string()`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return ${ctx.used("__tact_string_builder_start")}(begin_cell()); - `); - }); - }); - - ctx.fun(`__tact_string_builder_start`, () => { - ctx.signature(`tuple __tact_string_builder_start(builder b)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return tpush(tpush(empty_tuple(), b), null()); - `); - }); - }); - - ctx.fun(`__tact_string_builder_end`, () => { - ctx.signature(`cell __tact_string_builder_end(tuple builders)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - (builder b, tuple tail) = uncons(builders); - cell c = b.end_cell(); - while(~ null?(tail)) { - (b, tail) = uncons(tail); - c = b.store_ref(c).end_cell(); - } - return c; - `); - }); - }); - - ctx.fun(`__tact_string_builder_end_slice`, () => { - ctx.signature(`slice __tact_string_builder_end_slice(tuple builders)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - return ${ctx.used("__tact_string_builder_end")}(builders).begin_parse(); - `); - }); - }); - - ctx.fun(`__tact_string_builder_append`, () => { - ctx.signature( - `((tuple), ()) __tact_string_builder_append(tuple builders, slice sc)`, - ); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - int sliceRefs = slice_refs(sc); - int sliceBits = slice_bits(sc); - - while((sliceBits > 0) | (sliceRefs > 0)) { - - ;; Load the current builder - (builder b, tuple tail) = uncons(builders); - int remBytes = 127 - (builder_bits(b) / 8); - int exBytes = sliceBits / 8; - - ;; Append bits - int amount = min(remBytes, exBytes); - if (amount > 0) { - slice read = sc~load_bits(amount * 8); - b = b.store_slice(read); - } - - ;; Update builders - builders = cons(b, tail); - - ;; Check if we need to add a new cell and continue - if (exBytes - amount > 0) { - var bb = begin_cell(); - builders = cons(bb, builders); - sliceBits = (exBytes - amount) * 8; - } elseif (sliceRefs > 0) { - sc = sc~load_ref().begin_parse(); - sliceRefs = slice_refs(sc); - sliceBits = slice_bits(sc); - } else { - sliceBits = 0; - sliceRefs = 0; - } - } - - return ((builders), ()); - `); - }); - }); + for (let i = 1; i < 64; i++) { + const args: string[] = []; + for (let j = 0; j < i; j++) { + args.push(`X${j}`); + } - ctx.fun(`__tact_string_builder_append_not_mut`, () => { - ctx.signature( - `(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc)`, + parse( + `forall ${args.join(", ")} -> tuple __tact_tuple_create_${i}((${args.join(", ")}) v) asm "${i} TUPLE";`, ); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - builders~${ctx.used("__tact_string_builder_append")}(sc); - return builders; - `); - }); - }); - - ctx.fun(`__tact_int_to_string`, () => { - ctx.signature(`slice __tact_int_to_string(int src)`); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var b = begin_cell(); - if (src < 0) { - b = b.store_uint(45, 8); - src = - src; - } - - if (src < ${(10n ** 30n).toString(10)}) { - int len = 0; - int value = 0; - int mult = 1; - do { - (src, int res) = src.divmod(10); - value = value + (res + 48) * mult; - mult = mult * 256; - len = len + 1; - } until (src == 0); - - b = b.store_uint(value, len * 8); - } else { - tuple t = empty_tuple(); - int len = 0; - do { - int digit = src % 10; - t~tpush(digit); - len = len + 1; - src = src / 10; - } until (src == 0); - - int c = len - 1; - repeat(len) { - int v = t.at(c); - b = b.store_uint(v + 48, 8); - c = c - 1; - } - } - return b.end_cell().begin_parse(); - `); - }); - }); - - ctx.fun(`__tact_float_to_string`, () => { - ctx.signature(`slice __tact_float_to_string(int src, int digits)`); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - throw_if(${contractErrors.invalidArgument.id}, (digits <= 0) | (digits > 77)); - builder b = begin_cell(); - - if (src < 0) { - b = b.store_uint(45, 8); - src = - src; - } - - ;; Process rem part - int skip = true; - int len = 0; - int rem = 0; - tuple t = empty_tuple(); - repeat(digits) { - (src, rem) = src.divmod(10); - if ( ~ ( skip & ( rem == 0 ) ) ) { - skip = false; - t~tpush(rem + 48); - len = len + 1; - } - } - - ;; Process dot - if (~ skip) { - t~tpush(46); - len = len + 1; - } - - ;; Main - do { - (src, rem) = src.divmod(10); - t~tpush(rem + 48); - len = len + 1; - } until (src == 0); - - ;; Assemble - int c = len - 1; - repeat(len) { - int v = t.at(c); - b = b.store_uint(v, 8); - c = c - 1; - } - ;; Result - return b.end_cell().begin_parse(); - `); - }); - }); - - ctx.fun(`__tact_log`, () => { - ctx.signature(`int __tact_log(int num, int base)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - throw_unless(5, num > 0); - throw_unless(5, base > 1); - if (num < base) { - return 0; - } - int result = 0; - while (num >= base) { - num /= base; - result += 1; - } - return result; - `); - }); - }); - - ctx.fun(`__tact_pow`, () => { - ctx.signature(`int __tact_pow(int base, int exp)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - throw_unless(5, exp >= 0); - int result = 1; - repeat (exp) { - result *= base; - } - return result; - `); - }); - }); + parse( + `forall ${args.join(", ")} -> (${args.join(", ")}) __tact_tuple_destroy_${i}(tuple v) asm "${i} UNTUPLE";`, + ); + } // - // Dict Exists + // Strings // - ctx.fun("__tact_dict_exists_int", () => { - ctx.signature(`int __tact_dict_exists_int(cell d, int kl, int k)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = idict_get?(d, kl, k); - return ok; - `); - }); - }); - - ctx.fun("__tact_dict_exists_uint", () => { - ctx.signature(`int __tact_dict_exists_uint(cell d, int kl, int k)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = udict_get?(d, kl, k); - return ok; - `); - }); - }); - - ctx.fun("__tact_dict_exists_slice", () => { - ctx.signature(`int __tact_dict_exists_slice(cell d, int kl, slice k)`); - ctx.flag("inline"); - ctx.context("stdlib"); - ctx.body(() => { - ctx.write(` - var (r, ok) = ${ctx.used(`__tact_dict_get`)}(d, kl, k); - return ok; - `); - }); - }); + parse( + `tuple __tact_string_builder_start_comment() inline { + return __tact_string_builder_start(begin_cell().store_uint(0, 32)); + }`, + ); + + parse( + `tuple __tact_string_builder_start_tail_string() inline { + return __tact_string_builder_start(begin_cell().store_uint(0, 8)); + }`, + ); + + parse( + `tuple __tact_string_builder_start_string() inline { + return __tact_string_builder_start(begin_cell()); + }`, + ); + + parse( + `tuple __tact_string_builder_start(builder b) inline { + return tpush(tpush(empty_tuple(), b), null()); + }`, + ); + + parse( + `cell __tact_string_builder_end(tuple builders) inline { + (builder b, tuple tail) = uncons(builders); + cell c = b.end_cell(); + while (~null?(tail)) { + (b, tail) = uncons(tail); + c = b.store_ref(c).end_cell(); + } + return c; + }`, + ); + + parse( + `slice __tact_string_builder_end_slice(tuple builders) inline { + return __tact_string_builder_end(builders).begin_parse(); + }`, + ); + + parse( + `((tuple), ()) __tact_string_builder_append(tuple builders, slice sc) { + int sliceRefs = slice_refs(sc); + int sliceBits = slice_bits(sc); + + while ((sliceBits > 0) | (sliceRefs > 0)) { + ;; Load the current builder + (builder b, tuple tail) = uncons(builders); + int remBytes = 127 - (builder_bits(b) / 8); + int exBytes = sliceBits / 8; + + ;; Append bits + int amount = min(remBytes, exBytes); + if (amount > 0) { + slice read = sc~load_bits(amount * 8); + b = b.store_slice(read); + } + + ;; Update builders + builders = cons(b, tail); + + ;; Check if we need to add a new cell and continue + if (exBytes - amount > 0) { + var bb = begin_cell(); + builders = cons(bb, builders); + sliceBits = (exBytes - amount) * 8; + } elseif (sliceRefs > 0) { + sc = sc~load_ref().begin_parse(); + sliceRefs = slice_refs(sc); + sliceBits = slice_bits(sc); + } else { + sliceBits = 0; + sliceRefs = 0; + } + } + + return ((builders), ()); + }`, + ); + + parse( + `(tuple) __tact_string_builder_append_not_mut(tuple builders, slice sc) { + builders~__tact_string_builder_append(sc); + return builders; + }`, + ); + + parse( + `slice __tact_int_to_string(int src) { + var b = begin_cell(); + if (src < 0) { + b = b.store_uint(45, 8); + src = -src; + } + + if (src < ${(10n ** 30n).toString(10)}) { + int len = 0; + int value = 0; + int mult = 1; + do { + (src, int res) = src.divmod(10); + value = value + (res + 48) * mult; + mult = mult * 256; + len = len + 1; + } until (src == 0); + + b = b.store_uint(value, len * 8); + } else { + tuple t = empty_tuple(); + int len = 0; + do { + int digit = src % 10; + t~tpush(digit); + len = len + 1; + src = src / 10; + } until (src == 0); + + int c = len - 1; + repeat(len) { + int v = t.at(c); + b = b.store_uint(v + 48, 8); + c = c - 1; + } + } + return b.end_cell().begin_parse(); + }`, + ); + + parse( + `slice __tact_float_to_string(int src, int digits) { + throw_if(${contractErrors.invalidArgument.id}, (digits <= 0) | (digits > 77)); + builder b = begin_cell(); + + if (src < 0) { + b = b.store_uint(45, 8); + src = -src; + } + + ;; Process rem part + int skip = true; + int len = 0; + int rem = 0; + tuple t = empty_tuple(); + repeat(digits) { + (src, rem) = src.divmod(10); + if (~ (skip & (rem == 0))) { + skip = false; + t~tpush(rem + 48); + len = len + 1; + } + } + + ;; Process dot + if (~skip) { + t~tpush(46); + len = len + 1; + } + + ;; Main + do { + (src, rem) = src.divmod(10); + t~tpush(rem + 48); + len = len + 1; + } until (src == 0); + + ;; Assemble + int c = len - 1; + repeat(len) { + int v = t.at(c); + b = b.store_uint(v, 8); + c = c - 1; + } + + ;; Result + return b.end_cell().begin_parse(); + }`, + ); + + parse(`int __tact_log2(int num) asm "DUP 5 THROWIFNOT UBITSIZE DEC";`); + + parse( + `int __tact_log(int num, int base) { + throw_unless(5, num > 0); + throw_unless(5, base > 1); + if (num < base) { + return 0; + } + int result = 0; + while (num >= base) { + num /= base; + result += 1; + } + return result; + }`, + ); + + parse( + `int __tact_pow(int base, int exp) { + throw_unless(5, exp >= 0); + int result = 1; + repeat(exp) { + result *= base; + } + return result; + }`, + ); + + parse(`int __tact_pow2(int exp) asm "POW2";`); }