Module processing_async

Source
Expand description

The ProcessingAsync pass rewrites async { ... } blocks into standalone async functions. Each block is lifted to a new top-level async function, and the block is replaced with a call to that function.

This involves:

  • Capturing all variable and tuple field accesses used inside the block.
  • Filtering out globals and locals (which are handled differently).
  • Generating fresh function inputs for the captured values.
  • Rewriting the block with replacements for captured expressions.
  • Creating a CallExpression that invokes the synthesized async function.

If any async blocks were rewritten, this pass will rebuild the symbol table and rerun path resolution and type checking to account for the new functions.

ยงExample

async transition foo(x: u32) -> Future {
    return async {
        assert(x == 1);  
    };
}

becomes

async function foo_(x: u32) {
    assert(x == 1);
}

transition foo(x: u32) -> Future {
    return foo_(x);
}

Modulesยง

ast ๐Ÿ”’
program ๐Ÿ”’
visitor ๐Ÿ”’

Structsยง

ProcessingAsync