pub fn codegen_program(
stmts: &[Stmt<'_>],
registry: &TypeRegistry,
policies: &PolicyRegistry,
interner: &Interner,
) -> StringAvailable on crate feature
codegen only.Expand description
Generate a complete Rust program from LOGOS statements.
This is the main entry point for code generation. It produces a complete, compilable Rust program including:
- Prelude imports (
logicaffeine_data,logicaffeine_system) - User-defined types in
mod user_types - Policy impl blocks with predicate/capability methods
- Function definitions
fn main()with the program logic
§Arguments
stmts- The parsed LOGOS statementsregistry- Type registry containing struct/enum definitionspolicies- Policy registry containing security predicates and capabilitiesinterner- Symbol interner for name resolution
§Returns
A complete Rust source code string ready to compile.
§Generated Features
- Wraps user types in
mod user_typesfor visibility control - Emits function definitions before main
- Handles CRDT field mutations with proper
.set()calls - Generates policy predicate and capability methods
- Adds
#[tokio::main]async when needed - Injects VFS when file operations detected
- Uses
Distributed<T>when both Mount and Sync detected - Boxes recursive enum fields Generates a complete Rust program from LOGOS statements.
This is the main entry point for code generation. It produces a full Rust program including:
- Prelude imports (
use logicaffeine_data::*;) - Type definitions (structs, enums, inductive types)
- Policy structs with capability methods
- Main function with async runtime if needed
- VFS initialization for file operations
§Arguments
stmts- The parsed LOGOS statements to compileregistry- Type definitions discovered during parsingpolicies- Policy definitions for access controlinterner- Symbol interner for resolving names
§Returns
A complete Rust source code string ready for compilation.