Binaryen.TS
    Preparing search index...

    Class Relooper

    Index

    Constructors

    Methods

    • Adds a new block to the CFG, containing the provided code as its body.

      Parameters

      • code: number

        the block expression

      Returns number

      a reference to the block

    • Adds a new block, which ends with a switch/br_table, with provided code and condition (that determines where we go in the switch).

      Parameters

      • code: number

        the block expression

      • condition: number

        contition to determine the jump destination

      Returns number

    • Adds a branch from a block to another block, with a condition (or nothing, if this is the default branch to take from the origin — each block must have one such branch), and optional code to execute on the branch (useful for phis).

      Parameters

      • from: number

        source block

      • to: number

        destination block

      • condition: number

        contition to evaluate: if true, jumps to the given block; else does nothing

      • code: number

        code to evaluate in between block jumps

      Returns void

    • Adds a branch from a block ending in a switch, to another block, using an array of indexes that determine where to go, and optional code to execute on the branch.

      Parameters

      • from: number

        source block

      • to: number

        destination block

      • indexes: readonly number[]

        array containing corresponding indices for destination blocks

      • code: number

        code to evaluate in between block jumps

      Returns void

    • Renders and cleans up the Relooper instance. Call this after you have created all the blocks and branches, giving it the entry block (where control flow begins), a label helper variable (an index of a local we can use, necessary for irreducible control flow), and the module. This returns an expression — normal WebAssembly code — that you can use normally anywhere.

      Parameters

      • entry: number
      • labelHelper: number

      Returns number