Skip to main content

luaur_bytecode/methods/
call_inliner_call_inliner.rs

1use crate::records::bc_call_fb::BcCallFB;
2use crate::records::bc_function::BcFunction;
3use crate::records::bc_op::BcOp;
4use crate::records::call_inliner::CallInliner;
5use crate::type_aliases::reg::Reg;
6use luaur_common::records::dense_hash_map::DenseHashMap;
7use luaur_common::records::dense_hash_set::DenseHashSet;
8
9impl<'a> CallInliner<'a> {
10    pub fn call_inliner(
11        caller: &'a mut BcFunction,
12        target: &'a mut BcFunction,
13        call_op: BcOp,
14    ) -> Self {
15        let caller_ptr: *mut BcFunction = caller;
16        let call_ref = unsafe { (&*caller_ptr).inst(call_op) };
17        let call = BcCallFB::from(caller_ptr, call_ref);
18        let call_params = call.params();
19        let target_reg = call.base.get_out_reg();
20
21        CallInliner {
22            caller,
23            target,
24            call,
25            call_params,
26            target_reg,
27            caller_blocks_size_before_inline: 0,
28            caller_inst_size_before_inline: 0,
29            caller_vm_const_size_before_inline: 0,
30            caller_proto_size_before_inline: 0,
31            caller_up_val_size_before_inline: 0,
32            return_ops: Vec::new(),
33            call_projections: DenseHashSet::new(BcOp::new()),
34            var_arg_moves: DenseHashMap::new(BcOp::new()),
35        }
36    }
37}