luaur_code_gen/methods/
function_bytecode_summary_function_bytecode_summary.rs1use crate::records::function_bytecode_summary::FunctionBytecodeSummary;
2use alloc::string::String;
3use alloc::vec::Vec;
4
5impl FunctionBytecodeSummary {
6 pub fn new(source: String, name: String, line: i32, nesting_limit: u32) -> Self {
7 let mut summary = Self {
8 source,
9 name,
10 line,
11 nesting_limit,
12 counts: Vec::new(),
13 };
14
15 let op_limit = summary.get_op_limit() as usize;
16 let mut counts: Vec<Vec<u32>> = Vec::with_capacity((1 + nesting_limit) as usize);
17 for _ in 0..(1 + nesting_limit) {
18 counts.push(vec![0u32; op_limit]);
19 }
20
21 summary.counts = counts;
22 summary
23 }
24}