plotnik_lib/ir/
entrypoint.rs

1//! Named entrypoints for multi-definition queries.
2//!
3//! Entrypoints provide named exports for definitions. The default entrypoint
4//! is always Transition 0; this table enables accessing other definitions by name.
5
6use super::ids::{StringId, TransitionId, TypeId};
7
8/// Named entrypoint into the query graph.
9///
10/// Layout: 12 bytes, align 4.
11#[repr(C)]
12#[derive(Debug, Clone, Copy)]
13pub struct Entrypoint {
14    /// String ID for the entrypoint name.
15    name_id: StringId,
16    _pad: u16,
17    /// Target transition (definition entry point).
18    target: TransitionId,
19    /// Result type of this definition (see ADR-0007).
20    result_type: TypeId,
21    _pad2: u16,
22}
23
24const _: () = assert!(size_of::<Entrypoint>() == 12);
25const _: () = assert!(align_of::<Entrypoint>() == 4);
26
27impl Entrypoint {
28    /// Creates a new entrypoint.
29    pub const fn new(name_id: StringId, target: TransitionId, result_type: TypeId) -> Self {
30        Self {
31            name_id,
32            _pad: 0,
33            target,
34            result_type,
35            _pad2: 0,
36        }
37    }
38
39    /// Returns the string ID of the entrypoint name.
40    #[inline]
41    pub const fn name_id(&self) -> StringId {
42        self.name_id
43    }
44
45    /// Returns the target transition ID.
46    #[inline]
47    pub const fn target(&self) -> TransitionId {
48        self.target
49    }
50
51    /// Returns the result type ID.
52    #[inline]
53    pub const fn result_type(&self) -> TypeId {
54        self.result_type
55    }
56}