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
mod context;
pub(crate) use context::LoweringCtxt;
mod dec;
mod expr;
mod pat;
mod token;
mod ty;
mod infix;
mod util;
#[cfg(test)]
mod tests;
use pomelo_parse::AstNode;
use crate::arena::Idx;
use crate::NodeParent;
trait HirLower: Sized {
type AstType: AstNode + Clone;
fn missing(ctx: &mut LoweringCtxt) -> Idx<Self>;
fn lower(ctx: &mut LoweringCtxt, ast: Self::AstType) -> Idx<Self>;
fn lower_opt(ctx: &mut LoweringCtxt, opt_ast: Option<Self::AstType>) -> Idx<Self> {
match opt_ast {
Some(a) => Self::lower(ctx, a),
None => Self::missing(ctx),
}
}
}
trait HirLowerGenerated: HirLower {
type Kind: Clone;
fn generated(ctx: &mut LoweringCtxt, origin: NodeParent, kind: Self::Kind) -> Idx<Self>;
}