luaur_bytecode/methods/
bytecode_builder_add_child_function.rs1use crate::records::bytecode_builder::BytecodeBuilder;
2
3impl BytecodeBuilder {
4 pub fn add_child_function(&mut self, fid: u32) -> i16 {
5 if let Some(cache) = self.proto_map.find(&fid) {
6 return *cache;
7 }
8
9 let id = self.protos.len() as u32;
10
11 const K_MAX_CLOSURE_COUNT: u32 = 0x7fff;
12 if id >= K_MAX_CLOSURE_COUNT {
13 return -1;
14 }
15
16 self.proto_map.try_insert(fid, id as i16);
17 self.protos.push(fid);
18
19 id as i16
20 }
21}