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
//! CompilerPass trait — 优化 pass 的统一接口。
use CompilerContext;
use crateGraph;
use crateMergeStrategy;
use crateWorkflowState;
/// 编译器优化 pass trait。
///
/// 每个 pass 负责一个特定的优化,
/// 例如:内联、死代码消除、Barrier 合并等。
///
/// # 示例
///
/// ```ignore
/// struct MyPass;
///
/// impl<S: WorkflowState, M: MergeStrategy<S>> CompilerPass<S, M> for MyPass {
/// fn name(&self) -> &str {
/// "my_pass"
/// }
///
/// fn run(&self, graph: &mut Graph<S, M>, ctx: &mut CompilerContext<S>) -> bool {
/// // 优化逻辑
/// false
/// }
/// }
/// ```