luaur_repl_cli/records/function_counters.rs
1//! Node: `cxx:Record:Luau.Repl.CLI:CLI/src/Counters.cpp:19:function_counters`
2//! Source: `CLI/src/Counters.cpp`
3//! Graph edges:
4//! - declared_by: source_file CLI/src/Counters.cpp
5//! - source_includes:
6//! - includes -> source_file CLI/include/Luau/Counters.h
7//! - includes -> source_file CodeGen/include/Luau/CodeGenOptions.h
8//! - includes -> source_file Common/include/Luau/DenseHash.h
9//! - includes -> source_file VM/include/lua.h
10//! - incoming:
11//! - declares <- source_file CLI/src/Counters.cpp
12//! - type_ref <- record ModuleCounters (CLI/src/Counters.cpp)
13//! - type_ref <- function countersValueCallback (CLI/src/Counters.cpp)
14//! - type_ref <- function countersDump (CLI/src/Counters.cpp)
15//! - outgoing:
16//! - type_ref -> record DenseHashMap (Common/include/Luau/DenseHash.h)
17//! - type_ref -> record LineCounters (CLI/src/Counters.cpp)
18//! - translates_to -> rust_item FunctionCounters
19
20use alloc::collections::BTreeMap;
21use alloc::string::String;
22
23use crate::records::line_counters::LineCounters;
24
25// Faithful port of Counters.cpp's:
26// struct FunctionCounters {
27// std::string name;
28// Luau::DenseHashMap<int, LineCounters> counters{-1};
29// };
30// The C++ DenseHashMap is keyed by line number and later sorted by line for
31// output; a BTreeMap captures the same line→LineCounters mapping in sorted
32// order, so counters_dump can iterate it directly.
33#[derive(Debug, Clone, Default)]
34pub struct FunctionCounters {
35 pub name: String,
36 pub counters: BTreeMap<i32, LineCounters>,
37}