Multi-frontend IR (conceptual)
Multiple source languages can feed the same hybrid pipeline by lowering to textual SIL that hybrid_sil already parses (sil @…, bbN:, function_ref @…, unique SSA ids across the merged module).
Textual SIL merge behavior (hybrid_sil)
parse_textual_sil keeps the legacy top-level function_id as whichever sil @name line appeared last in the input, and still exposes flattened block / instruction vectors for existing callers. It also records explicit per-function entries in SilArtifact::functions, each with its own blocks and instructions. extract_call_graph prefers those per-function records, then falls back to instruction_callers, then to the legacy function_id behavior for old artifacts. Emitters still typically place sil @main last so single-function views line up with main. For full detail see in-language.md.
UnifiedModule (current schema)
Rust type: in_cli::core_ir::UnifiedModule.
| Field | Meaning |
|---|---|
decls: Vec<Decl> | Top-level declarations in source order (before lowering sorts functions for SIL). |
.in also has a parser-side surface fact helper for import, capability, and extern declarations. Local relative .in imports merge imported declarations into the current UnifiedModule; std.io / std.fs / std.http / std.json / std.process / std.cli imports synthesize bounded extern-style declarations; imports and capabilities are exposed through in agent JSON, and extern requires contracts produce agent diagnostics when required capabilities are missing. Extern bindings lower into empty Function declarations today so call graph extraction can observe explicit .in calls without expanding the Core IR schema.
Decl variants
| Variant | Fields | Notes |
|---|---|---|
Struct | name, fields: Vec<(String, Typ)> | .in v0.2 supports multiline field blocks; Tree-sitter and dedicated fronts fill fields where their current extractor supports them. |
Function | name, params, ret, body | .in, icoreVersion: 2, dedicated Rust/Go/V fronts, and selected Tree-sitter fronts fill bounded statement lists; lowering follows lower_core. |
Typ: Int, String, Bool, Void, Named(String).
Boundary IR (icoreVersion: 3)
Rust types: in_cli::boundary_ir::BoundaryModule, CompileArtifact.
| Field | Meaning |
|---|---|
abi_version | Must match IN_ABI_VERSION in shared/abi/in_abi.h. |
module | Stable boundary module id (for example sample.person). |
layouts | Struct/enum layouts with C repr, size, align, stride, and per-field transfer mode. |
symbols | Exported ABI symbols with ownership and calling convention metadata. |
allocators | Allocator ids (host_arena, module heap) used by buffers and borrow tokens. |
layout_hash | Canonical blake3-… hash over layouts + symbols; empty means compute on ingest. |
compiler::icore::parse_icore_artifact verifies boundary modules before lowering. Level-5 language fronts may attach the same BoundaryModule through dedicated extractors (Nim/Odin comment JSON today; Rust/Zig extractors planned) without expanding Core IR statement forms.
ParserId (extensible)
| Id | Source | Entry |
|---|---|---|
In | .in files (and #!in parser=in) | in_lang_parse → UnifiedModule → compiler::driver / lower_core; parser-side surface facts feed agent effects / capabilities |
Icore | .icore files (and #!in parser=icore) | compiler::icore v1 declarations, v2 bounded body JSON, or v3 Boundary IR (boundary section + optional semantic decls) → CompileArtifact → same lowering |
swift, go, ocaml, haskell, c, cpp, java, python, … | Known extensions or #!in parser=<slug> | Tree-sitter polyglot — compiler::tree_front grammar-backed AST → UnifiedModule. All 37 languages share the same pipeline. |
Resolution order for in build
See in-cli/src/parser_registry.rs (resolve_parser_id) and parser-surface.md. In short:
--parser in/--parser icore— force the.inor.icorefront.- Magic first line —
#!in parser=in|auto|<slug>. IN_PARSER=in/IN_PARSER=icore.- Extension map —
.in,.icore,.java,.cpp, … → Core IR path (full parsers for.in/.icore; Tree-sitter for other wired extensions). - Unknown extensions: fail closed with an
.icorehint.
All 37 languages now route through Core IR. Swift was unified into the Tree-sitter pipeline (the old swift_subset/native_swift_sil/sil_emit modules have been deleted).
Related
-
general-compiler.md — multi-language driver, icore, roadmap.
-
parser-surface.md — extension + magic-line routing, Tree-sitter vs full fronts.
-
in-language.md —
.inv0.2 grammar andhybrid_silnote. -
README · Core Commands — CLI flags and sample commands (no duplicate install steps here).