Skip to main content

luaur_bytecode/methods/
bytecode_graph_parser_apply_call.rs

1use crate::records::bc_op::BcOp;
2use crate::records::block_producers::BlockProducers;
3use crate::records::bytecode_graph_parser::BytecodeGraphParser;
4use crate::type_aliases::reg::Reg;
5
6impl<'a> BytecodeGraphParser<'a> {
7    pub fn apply_call(
8        &mut self,
9        producers: &mut BlockProducers,
10        call_op: BcOp,
11        target_reg: Reg,
12        nresults: i32,
13    ) {
14        producers.own.retain(|&reg, _| reg < target_reg);
15        producers.cached.retain(|&reg, _| reg < target_reg);
16
17        if nresults < 0 {
18            producers.multiReturn = call_op;
19            producers.multiReturnStart = target_reg;
20            producers.invalidAfter = 255;
21        } else {
22            producers.invalidAfter = (target_reg as i32) - 1 + nresults;
23        }
24    }
25}