pub struct Program {
pub includes: Vec<Include>,
pub unions: Vec<UnionDef>,
pub words: Vec<WordDef>,
}Fields§
§includes: Vec<Include>§unions: Vec<UnionDef>§words: Vec<WordDef>Implementations§
Source§impl Program
impl Program
Sourcepub const MAX_VARIANT_FIELDS: usize = 4usize
pub const MAX_VARIANT_FIELDS: usize = 4usize
Generate constructor words for all union definitions
Maximum number of fields a variant can have (limited by runtime support)
pub fn new() -> Self
Sourcepub fn find_union(&self, name: &str) -> Option<&UnionDef>
pub fn find_union(&self, name: &str) -> Option<&UnionDef>
Find a union definition by name
pub fn find_word(&self, name: &str) -> Option<&WordDef>
Sourcepub fn validate_word_calls(&self) -> Result<(), String>
pub fn validate_word_calls(&self) -> Result<(), String>
Validate that all word calls reference either a defined word or a built-in
Sourcepub fn validate_word_calls_with_externals(
&self,
external_words: &[&str],
) -> Result<(), String>
pub fn validate_word_calls_with_externals( &self, external_words: &[&str], ) -> Result<(), String>
Validate that all word calls reference a defined word, built-in, or external word.
The external_words parameter should contain names of words available from
external sources (e.g., included modules) that should be considered valid.
Sourcepub fn generate_constructors(&mut self) -> Result<(), String>
pub fn generate_constructors(&mut self) -> Result<(), String>
For each union variant, generates a Make-VariantName word that:
- Takes the variant’s field values from the stack
- Pushes the variant tag (index)
- Calls the appropriate
variant.make-Nbuiltin
Example: For union Message { Get { chan: Int } }
Generates: : Make-Get ( Int -- Message ) 0 variant.make-1 ;
Returns an error if any variant exceeds the maximum field count.
Trait Implementations§
impl StructuralPartialEq for Program
Auto Trait Implementations§
impl Freeze for Program
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnwindSafe for Program
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more