Skip to main content

airl_ir/
lib.rs

1//! AIRL IR - Core intermediate representation data structures.
2//!
3//! This crate defines the typed IR used throughout the AIRL system. The IR is
4//! designed to be serialized to/from JSON, making it easy for AI agents to
5//! generate and manipulate.
6//!
7//! # Example
8//!
9//! ```
10//! use airl_ir::Module;
11//!
12//! let json = r#"{
13//!     "format_version":"0.1.0",
14//!     "module":{"id":"m","name":"main",
15//!         "metadata":{"version":"1","description":"","author":"","created_at":""},
16//!         "imports":[],"exports":[],"types":[],
17//!         "functions":[]}
18//! }"#;
19//! let module: Module = serde_json::from_str(json).unwrap();
20//! assert_eq!(module.name(), "main");
21//! ```
22//!
23//! # Module organization
24//!
25//! - [`node`] — expression and statement nodes (16 variants)
26//! - [`types`] — the type system
27//! - [`effects`] — the effect system
28//! - [`module`] — top-level module, function, and parameter definitions
29//! - [`ids`] — strongly-typed identifiers
30//! - [`version`] — content-addressable module versions
31//! - [`graph`] — high-level graph container with validation
32//! - [`display`] — pretty-printing for debugging
33//! - [`symbol`] — symbol interning helpers
34
35#![deny(missing_docs)]
36
37/// Pretty-printers and `Display` impls for IR nodes.
38pub mod display;
39/// Effect system: `Pure`, `IO`, `Fail`, `Read`, `Write`, `Allocate`, `Diverge`.
40pub mod effects;
41/// High-level IR graph container with JSON (de)serialization.
42pub mod graph;
43/// Strongly-typed identifiers: [`NodeId`], [`FuncId`], [`ModuleId`], [`TypeId`], [`Symbol`].
44pub mod ids;
45/// Top-level module structure: [`Module`], [`FuncDef`], [`ParamDef`], imports, exports.
46pub mod module;
47/// Core IR node types (expressions, statements, control flow, patterns).
48pub mod node;
49/// Lightweight symbol (string) wrapper used for names and identifiers.
50pub mod symbol;
51/// The AIRL type system: primitives, arrays, tuples, structs, enums, generics.
52pub mod types;
53/// Content-addressable versioning for modules (SHA-256 based).
54pub mod version;
55
56// Re-export key types for convenience.
57pub use effects::Effect;
58pub use graph::{IRGraph, IRGraphError};
59pub use ids::{FuncId, ModuleId, NodeId, Symbol, TypeId};
60pub use module::{Export, FuncDef, Import, Module, ModuleInner, ModuleMetadata, ParamDef, TypeDef};
61pub use node::{BinOpKind, LiteralValue, MatchArm, Node, Pattern, UnaryOpKind};
62pub use types::{Type, Variant};
63pub use version::VersionId;