react_compiler_lowering/
lib.rs1pub mod build_hir;
2pub mod find_context_identifiers;
3pub mod hir_builder;
4pub mod identifier_loc_index;
5
6use react_compiler_ast::expressions::ArrowFunctionExpression;
7use react_compiler_ast::expressions::FunctionExpression;
8use react_compiler_ast::statements::FunctionDeclaration;
9use react_compiler_hir::BindingKind;
10
11pub fn convert_binding_kind(kind: &react_compiler_ast::scope::BindingKind) -> BindingKind {
13 match kind {
14 react_compiler_ast::scope::BindingKind::Var => BindingKind::Var,
15 react_compiler_ast::scope::BindingKind::Let => BindingKind::Let,
16 react_compiler_ast::scope::BindingKind::Const => BindingKind::Const,
17 react_compiler_ast::scope::BindingKind::Param => BindingKind::Param,
18 react_compiler_ast::scope::BindingKind::Module => BindingKind::Module,
19 react_compiler_ast::scope::BindingKind::Hoisted => BindingKind::Hoisted,
20 react_compiler_ast::scope::BindingKind::Local => BindingKind::Local,
21 react_compiler_ast::scope::BindingKind::Unknown => BindingKind::Unknown,
22 }
23}
24
25pub enum FunctionNode<'a> {
28 FunctionDeclaration(&'a FunctionDeclaration),
29 FunctionExpression(&'a FunctionExpression),
30 ArrowFunctionExpression(&'a ArrowFunctionExpression),
31}
32
33impl<'a> FunctionNode<'a> {
34 pub fn node_id(&self) -> Option<u32> {
36 match self {
37 FunctionNode::FunctionDeclaration(d) => d.base.node_id,
38 FunctionNode::FunctionExpression(e) => e.base.node_id,
39 FunctionNode::ArrowFunctionExpression(a) => a.base.node_id,
40 }
41 }
42}
43
44pub use build_hir::lower;
46pub use hir_builder::{
48 create_temporary_place, get_reverse_postordered_blocks, mark_instruction_ids,
49 mark_predecessors, remove_dead_do_while_statements, remove_unnecessary_try_catch,
50 remove_unreachable_for_updates,
51};
52pub use react_compiler_hir::visitors::each_terminal_successor;
53pub use react_compiler_hir::visitors::terminal_fallthrough;