Skip to main content

luaur_code_gen/methods/
ir_builder_check_safe_env.rs

1use crate::enums::ir_cmd::IrCmd;
2use crate::records::ir_block::{kBlockNoStartPc, IrBlock};
3use crate::records::ir_builder::IrBuilder;
4
5impl IrBuilder {
6    pub fn check_safe_env(&mut self, pcpos: i32) {
7        let active_block_idx = self.active_block_idx as usize;
8        let active: &mut IrBlock = &mut self.function.blocks[active_block_idx];
9
10        const k_block_flag_safe_env_check: u8 = 1 << 0;
11        const k_block_flag_safe_env_clear: u8 = 1 << 1;
12
13        if active.startpc != kBlockNoStartPc {
14            if (active.flags & k_block_flag_safe_env_clear) == 0 {
15                active.flags |= k_block_flag_safe_env_check;
16            }
17        }
18
19        let exit_op = self.vm_exit(pcpos as u32);
20        self.inst_ir_cmd_ir_op(IrCmd::CHECK_SAFE_ENV, exit_op);
21    }
22}