SplitScript reference / Language / layout

layout

declaration

state { layout { dimension: Type } ... } | state { layout Name { field at address } }

Declares attachment-wide build dimensions or a named state memory shape.

An unnamed layout { ... } declares independent attachment-wide dimensions. When conditional managed fields give every possible combination a unique presence pattern, attachment selects the generated Layout automatically before user onAttach code runs. Otherwise onAttach returns Layout { ... } explicitly after checking the remaining build facts. The read-only layout value is then available to state expressions, managed class conditions, and lifecycle code. A predicate such as layout.edition == Edition.BaseGame refines every state and managed field declared under that same predicate. For a two-variant dimension, the corresponding else branch refines to the other variant. This keeps build facts in one place even when native state and several managed classes vary independently. A named layout Name { ... } instead declares one complete state memory shape. Compatible fields shared by every named shape form the common snapshot interface; other fields become available after a direct match on the generated StateLayout value. await Process.closed represents an unsupported build without repeatedly reattaching.

Examples

Select and refine a supported build

layout Steam {
    level: u32 at 0x1000;
    checkpoint: u8 at 0x1100;
}

Refine managed fields with the shared layout

if layout.edition == Edition.BaseGame {
    print(manager.level else 0)
} else {
    print(manager.scene else 0)
}