use crate::definition::{
    AddressDef, AddressPath, ContainerDef, ExternalFnDef, GlobalVarDef, ListDef, ListItemDef,
    ScopeLineTable,
};
use crate::value::ListValue;

/// The top-level compiled story: everything the runtime needs to execute.
#[derive(Debug, Clone, PartialEq)]
pub struct StoryData {
    pub containers: Vec<ContainerDef>,
    /// Per-scope line tables. Each scope (root, knot, stitch) gets one table
    /// shared by all containers within that scope.
    pub line_tables: Vec<ScopeLineTable>,
    pub variables: Vec<GlobalVarDef>,
    pub list_defs: Vec<ListDef>,
    pub list_items: Vec<ListItemDef>,
    pub externals: Vec<ExternalFnDef>,
    /// Address definitions mapping IDs to byte offsets within containers.
    pub addresses: Vec<AddressDef>,
    /// Qualified-path → address-target table. The single source of truth for
    /// [`Program::find_address`](../../brink_runtime/struct.Program.html#method.find_address);
    /// empty for legacy/converter output (the linker then falls back to
    /// deriving scope paths from container names).
    pub address_paths: Vec<AddressPath>,
    /// Interned name strings, indexed by [`NameId`](crate::id::NameId).
    pub name_table: Vec<String>,
    /// List literal values referenced by `PushList(idx)` opcodes.
    pub list_literals: Vec<ListValue>,
    /// CRC-32 checksum from the `.inkb` header, used for locale validation.
    /// Zero for stories not loaded from `.inkb`.
    pub source_checksum: u32,
}
