Provides access to AST elements defined within a single Tact project.

The generated AST entries includes all the dependent elements, including imported code which is included in the project AST in C/C++ style.

Constructors

  • Constructs a TactASTStore with mappings to all major AST components accessible by their unique AST identifiers.

    Parameters

    • stdlibIds: Set<number> = ...

      Identifiers of AST elements defined in stdlib.

    • contractConstants: Set<number> = ...

      Identifiers of constants defined within contracts.

    • programEntries: Set<number>

      Identifiers of AST elements defined on the top-level.

    • functions: Map<number, AstFunctionDef | AstContractInit | AstReceiver>

      Functions and methods including user-defined and special methods.

    • constants: Map<number, AstConstantDef>

      Constants defined across the compilation unit.

    • contracts: Map<number, AstContract>

      Contracts defined within the project.

    • nativeFunctions: Map<number, AstNativeFunctionDecl>

      Functions defined natively (not in user's source code).

    • asmFunctions: Map<number, AstAsmFunctionDef>

      Tact asm functions.

    • primitives: Map<number, AstPrimitiveTypeDecl>

      Primitive types defined in the project.

    • structs: Map<number, AstStructDecl>

      Structs defined in the project.

    • messages: Map<number, AstMessageDecl>

      Messages defined in the project.

    • traits: Map<number, AstTrait>

      Traits defined in the project.

    • statements: Map<number, AstStatement>

      All executable statements within all functions of the project.

    Returns TactASTStore

Methods

  • Retrieves an asm function by its ID.

    Parameters

    • id: number

      The unique identifier of the asm function.

    Returns undefined | AstAsmFunctionDef

    The asm function if found, otherwise undefined.

  • Retrieves a constant by its ID.

    Parameters

    • id: number

      The unique identifier of the constant.

    Returns undefined | AstConstantDef

    The constant if found, otherwise undefined.

  • Returns all the constants defined within the program, including top-level constants and contract constants.

    Parameters

    • params: Partial<{
          includeContract: boolean;
          includeStdlib: boolean;
      }> = {}

      Additional parameters:

      • includeStdlib: If true, includes constants defined in stdlib.
      • includeContract: If true, includes constants defined within a contract.

    Returns IterableIterator<AstConstantDef>

  • Retrieves a contract by its ID.

    Parameters

    • id: number

      The unique identifier of the contract.

    Returns undefined | AstContract

    The contract if found, otherwise undefined.

  • Retrieves the IDs of constants associated with a specified contract.

    Parameters

    • contractId: number

      The ID of the contract.

    Returns undefined | number[]

    An array of constant IDs or undefined if no contract is found.

  • Retrieves the fields defined within a specified contract.

    Parameters

    • contractId: number

      The ID of the contract.

    Returns undefined | AstFieldDecl[]

    An array of AstFieldDecl or undefined if no contract is found.

  • Retrieves a function or method by its ID.

    Parameters

    • id: number

      The unique identifier of the function or method.

    Returns
        | undefined
        | AstFunctionDef
        | AstContractInit
        | AstReceiver

    The function or method if found, otherwise undefined.

  • Returns all the functions and methods defined within the program.

    Parameters

    • params: Partial<{
          includeStdlib: boolean;
      }> = {}

      Additional parameters:

      • includeStdlib: If true, includes functions defined in stdlib.

    Returns IterableIterator<AstFunctionDef | AstContractInit | AstReceiver>

  • Retrieves the ID of the initialization function for a specified contract.

    Parameters

    • contractId: number

      The ID of the contract.

    Returns undefined | number

    The ID of the init function or undefined if the contract does not exist.

  • Retrieves a message by its ID.

    Parameters

    • id: number

      The unique identifier of the message.

    Returns undefined | AstMessageDecl

    The message if found, otherwise undefined.

  • Retrieves the IDs of methods for a specified contract which have one of the following types: AstFunctionDef, AstReceiver, AstContractInit.

    Parameters

    • contractId: number

      The ID of the contract.

    Returns undefined | number[]

    An array of method IDs or undefined if no contract is found.

  • Retrieves a native function by its ID.

    Parameters

    • id: number

      The unique identifier of the native function.

    Returns undefined | AstNativeFunctionDecl

    The native function if found, otherwise undefined.

  • Returns IterableIterator<AstNativeFunctionDecl>

  • Retrieves a primitive type by its ID.

    Parameters

    • id: number

      The unique identifier of the primitive type.

    Returns undefined | AstPrimitiveTypeDecl

    The primitive type if found, otherwise undefined.

  • Returns IterableIterator<AstPrimitiveTypeDecl>

  • Returns top-level program entries in order as they defined.

    Parameters

    • includeStdlib: boolean = false

    Returns AstNode[]

  • Retrieves a statement by its ID.

    Parameters

    • id: number

      The unique identifier of the statement.

    Returns undefined | AstStatement

    The statement if found, otherwise undefined.

  • Returns all the statements defined within the program.

    Returns IterableIterator<AstStatement>

  • Retrieves a struct by its ID.

    Parameters

    • id: number

      The unique identifier of the struct.

    Returns undefined | AstStructDecl

    The struct if found, otherwise undefined.

  • Retrieves a trait by its ID.

    Parameters

    • id: number

      The unique identifier of the trait.

    Returns undefined | AstTrait

    The trait if found, otherwise undefined.