Represents a Compilation Unit, encapsulating the information necessary for analyzing a single Tact project.

Constructors

  • Creates an instance of CompilationUnit.

    Parameters

    • projectName: string

      The name of the project this Compilation Unit belongs to.

    • ast: TactASTStore

      The AST of the project.

    • functions: Map<number, CFG>

      A mapping from unique IDs of free functions to their CFGs.

    • contracts: Map<number, Contract>

      A mapping from unique IDs of contract entries to contracts.

    Returns CompilationUnit

Properties

The AST of the project.

contracts: Map<number, Contract>

A mapping from unique IDs of contract entries to contracts.

functions: Map<number, CFG>

A mapping from unique IDs of free functions to their CFGs.

projectName: string

The name of the project this Compilation Unit belongs to.

Methods

  • Looks for a CFG with a specific index.

    Parameters

    • idx: number

    Returns undefined | CFG

    Found CFG or undefined if not found.

  • Looks for a CFG for a function node with a specific name.

    Parameters

    • name: string

    Returns undefined | CFG

    Found CFG or undefined if not found.

  • Looks for a CFG for a method node with a specific name.

    Parameters

    • contractName: string
    • methodName: string

    Returns undefined | CFG

    Found CFG or undefined if not found.

  • Iterates over all CFGs in a Compilation Unit, and applies a callback to each basic block in every CFG.

    Parameters

    • astStore: TactASTStore

      The store containing the AST nodes.

    • callback: ((cfg: CFG, node: BasicBlock, stmt: AstStatement) => void)

      The function to apply to each BB within each CFG.

        • (cfg, node, stmt): void
        • Parameters

          Returns void

    Returns void

  • Iterates over all CFGs in a Compilation Unit, and applies a callback to CFG.

    Parameters

    • astStore: TactASTStore

      The store containing the AST nodes.

    • callback: ((cfg: CFG) => void)

      The function to apply to each CFG.

        • (cfg): void
        • Parameters

          Returns void

    Returns void