luaur_compiler/methods/
compiler_compile_expr_if_else_and_or.rs1use crate::records::compiler::Compiler;
2use luaur_ast::records::ast_expr::AstExpr;
3use luaur_common::enums::luau_opcode::LuauOpcode;
4
5impl Compiler {
6 pub fn compile_expr_if_else_and_or(
7 &mut self,
8 and_: bool,
9 creg: u8,
10 other: *mut AstExpr,
11 target: u8,
12 ) {
13 let cid = self.get_constant_index(other);
14 unsafe {
15 if cid >= 0 && cid <= 255 {
16 (*self.bytecode).emit_abc(
17 if and_ {
18 LuauOpcode::LOP_ANDK
19 } else {
20 LuauOpcode::LOP_ORK
21 },
22 target,
23 creg,
24 cid as u8,
25 );
26 } else {
27 let mut rs = self.reg_scope_compiler();
28 let oreg = self.compile_expr_auto(other, &mut rs);
29 (*self.bytecode).emit_abc(
30 if and_ {
31 LuauOpcode::LOP_AND
32 } else {
33 LuauOpcode::LOP_OR
34 },
35 target,
36 creg,
37 oreg,
38 );
39 }
40 }
41 }
42}