Skip to main content

logicaffeine_compile/analysis/
mod.rs

1//! Compile-time analysis passes for the LOGOS compilation pipeline.
2//!
3//! This module provides static analysis that runs after parsing but before
4//! code generation. These passes detect errors that would otherwise manifest
5//! as confusing Rust borrow checker errors.
6//!
7//! # Analysis Passes
8//!
9//! | Pass | Module | Description |
10//! |------|--------|-------------|
11//! | Escape | [`escape`] | Detects zone-local values escaping their scope |
12//! | Ownership | [`ownership`] | Linear type enforcement (use-after-move) |
13//! | Discovery | [`discover_with_imports`] | Multi-file type discovery |
14//!
15//! # Pass Ordering
16//!
17//! ```text
18//! Parser Output (AST)
19//!        │
20//!        ▼
21//! ┌──────────────┐
22//! │ Escape Check │ ← Catches zone violations (fast, simple)
23//! └──────────────┘
24//!        │
25//!        ▼
26//! ┌─────────────────┐
27//! │ Ownership Check │ ← Catches use-after-move (control-flow aware)
28//! └─────────────────┘
29//!        │
30//!        ▼
31//!    Code Generation
32//! ```
33//!
34//! # Re-exports
35//!
36//! This module re-exports types from `logicaffeine_language::analysis` for
37//! convenience, including:
38//! - [`TypeRegistry`], [`TypeDef`], [`FieldDef`] - Type definitions
39//! - [`PolicyRegistry`], [`PredicateDef`], [`CapabilityDef`] - Security policies
40//! - [`DiscoveryPass`] - Token-level type discovery
41
42pub mod callgraph;
43pub mod check;
44pub mod escape;
45pub mod liveness;
46pub mod ownership;
47pub mod readonly;
48pub mod types;
49pub mod unify;
50mod discovery;
51
52pub use escape::{EscapeChecker, EscapeError, EscapeErrorKind};
53pub use ownership::{OwnershipChecker, OwnershipError, OwnershipErrorKind, VarState};
54pub use discovery::discover_with_imports;
55pub use types::{LogosType, TypeEnv, FnSig, RustNames};
56pub use check::check_program;
57
58// Re-export language analysis types with submodule aliases
59pub mod registry {
60    pub use logicaffeine_language::analysis::registry::*;
61}
62
63pub mod policy {
64    pub use logicaffeine_language::analysis::policy::*;
65}
66
67pub mod dependencies {
68    pub use logicaffeine_language::analysis::dependencies::*;
69}
70
71pub use logicaffeine_language::analysis::{
72    TypeRegistry, TypeDef, FieldDef, FieldType, VariantDef,
73    DiscoveryPass, DiscoveryResult,
74    PolicyRegistry, PredicateDef, CapabilityDef, PolicyCondition,
75    scan_dependencies, Dependency,
76};