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 assemble;
43pub mod callgraph;
44pub mod check;
45pub mod defined_real;
46pub mod dimension_check;
47mod discovery;
48pub mod escape;
49pub(crate) mod absence;
50pub(crate) mod exactness;
51pub mod import_hygiene;
52pub mod known_calls;
53pub mod liveness;
54pub(crate) mod numbers;
55pub mod ownership;
56pub mod pipes;
57pub mod readonly;
58pub mod relay;
59pub mod tower;
60pub mod types;
61pub mod unify;
62
63pub use assemble::{
64    assemble_project, assemble_project_with_deps, check_scopes, AssembledProgram, DefKind, DefSite,
65    Located, Provenance, ScopeInfo, Segment, SourceMap,
66};
67pub use check::{
68    check_program, check_program_collect, check_program_located, infer_instantiations,
69    root_binding_types, CallInstance, IndexedTypeError, Instantiations, LocatedTypeError, Site,
70};
71pub use dimension_check::{DimensionChecker, DimensionError};
72pub use discovery::discover_with_imports;
73pub use escape::{EscapeChecker, EscapeError, EscapeErrorKind};
74pub use import_hygiene::{
75    lint_imports, lint_imports_with_deps, ImportLint, ImportLintKind, LintSeverity,
76};
77pub use known_calls::{
78    check_unknown_calls, check_unknown_calls_with_exports, proven_module_exports,
79    refuse_retired_calls,
80};
81pub use ownership::{
82    MaybeGivenIn, OwnershipChecker, OwnershipError, OwnershipErrorKind, OwnershipFinding, VarState,
83};
84pub use types::{FnSig, LogosType, RustNames, TypeEnv};
85
86// Re-export language analysis types with submodule aliases
87pub mod registry {
88    pub use logicaffeine_language::analysis::registry::*;
89}
90
91pub mod policy {
92    pub use logicaffeine_language::analysis::policy::*;
93}
94
95pub mod dependencies {
96    pub use logicaffeine_language::analysis::dependencies::*;
97}
98
99pub use logicaffeine_language::analysis::{
100    first_section_header, misplaced_imports, scan_dependencies, CapabilityDef, Dependency,
101    DiscoveryPass, DiscoveryResult, FieldDef, FieldType, PolicyCondition, PolicyRegistry,
102    PredicateDef, TypeDef, TypeRegistry, VariantDef,
103};