1pub mod build_hir;2pub mod find_context_identifiers;3pub mod hir_builder;4pub mod identifier_loc_index;56use react_compiler_ast::expressions::ArrowFunctionExpression;7use react_compiler_ast::expressions::FunctionExpression;8use react_compiler_ast::statements::FunctionDeclaration;9use react_compiler_hir::BindingKind;1011/// Convert AST binding kind to HIR binding kind.12pub 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}2425/// Represents a reference to a function AST node for lowering.26/// Analogous to TS's `NodePath<t.Function>` / `BabelFn`.27pub enum FunctionNode<'a> {28 FunctionDeclaration(&'a FunctionDeclaration),29 FunctionExpression(&'a FunctionExpression),30 ArrowFunctionExpression(&'a ArrowFunctionExpression),31}3233impl<'a> FunctionNode<'a> {34 /// Get the node_id of the function node. Panics if not set.35 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}4344// The main lower() function - delegates to build_hir45pub use build_hir::lower;46// Re-export post-build helper functions used by optimization passes47pub 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;
Findings
✓ No findings reported for this file.