1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! # Macro Dispatch and Execution
//!
//! The dispatcher is responsible for routing macro calls to their implementations
//! and handling the execution lifecycle, including:
//!
//! - Looking up macros in the registry (with fallback resolution)
//! - ABI version compatibility checking
//! - Creating the `TsStream` input for macros
//! - Catching panics and converting them to diagnostics
//!
//! ## Dispatch Flow
//!
//! ```text
//! MacroContextIR
//! │
//! ▼
//! ┌─────────────────┐
//! │ Registry Lookup │ (with module fallback)
//! └────────┬────────┘
//! │
//! ▼
//! ┌─────────────────┐
//! │ ABI Version Check│ (reject if mismatch)
//! └────────┬────────┘
//! │
//! ▼
//! ┌─────────────────┐
//! │ Create TsStream │ (parse context)
//! └────────┬────────┘
//! │
//! ▼
//! ┌─────────────────┐
//! │ Execute Macro │ (with panic catching)
//! └────────┬────────┘
//! │
//! ▼
//! MacroResult
//! ```
//!
//! ## Error Handling
//!
//! The dispatcher never panics. All errors are converted to diagnostics:
//! - Macro not found (both module-path and name-only fallback failed) → Error diagnostic
//! - ABI mismatch → Error diagnostic with version info
//! - TsStream creation failure → Error diagnostic with details
//! - Macro panic → Error diagnostic with panic message
pub use MacroDispatcher;