Skip to main content

luaur_analysis/methods/
control_flow_graph_control_flow_graph.rs

1//! Source: `Analysis/include/Luau/ControlFlowGraph.h:259-262` (hand-ported)
2//! C++ `explicit ControlFlowGraph::ControlFlowGraph(NotNull<CFGAllocator> allocator)`.
3use crate::records::cfg_allocator::CfgAllocator;
4use crate::records::control_flow_graph::ControlFlowGraph;
5use luaur_common::records::dense_hash_map::DenseHashMap;
6
7impl ControlFlowGraph {
8    pub fn control_flow_graph(allocator: *mut CfgAllocator) -> Self {
9        Self {
10            // C++ `DenseHashMap<AstExpr*, Definition*> useDefs{nullptr};`
11            use_defs: DenseHashMap::new(core::ptr::null_mut()),
12            // C++ `std::vector<BlockId> blocks;`
13            blocks: alloc::vec::Vec::new(),
14            // C++ `size_t entryIdx = 0;`
15            entry_idx: 0,
16            // C++ member-init `: allocator(allocator)`
17            allocator,
18        }
19    }
20}