Skip to main content

luaur_code_gen/functions/
get_negated_condition_ir_utils.rs

1use crate::enums::ir_condition::IrCondition;
2use crate::macros::codegen_assert::CODEGEN_ASSERT;
3
4pub fn get_negated_condition_ir_condition(cond: IrCondition) -> IrCondition {
5    match cond {
6        IrCondition::Equal => IrCondition::NotEqual,
7        IrCondition::NotEqual => IrCondition::Equal,
8        IrCondition::Less => IrCondition::NotLess,
9        IrCondition::NotLess => IrCondition::Less,
10        IrCondition::LessEqual => IrCondition::NotLessEqual,
11        IrCondition::NotLessEqual => IrCondition::LessEqual,
12        IrCondition::Greater => IrCondition::NotGreater,
13        IrCondition::NotGreater => IrCondition::Greater,
14        IrCondition::GreaterEqual => IrCondition::NotGreaterEqual,
15        IrCondition::NotGreaterEqual => IrCondition::GreaterEqual,
16        IrCondition::UnsignedLess => IrCondition::UnsignedGreaterEqual,
17        IrCondition::UnsignedLessEqual => IrCondition::UnsignedGreater,
18        IrCondition::UnsignedGreater => IrCondition::UnsignedLessEqual,
19        IrCondition::UnsignedGreaterEqual => IrCondition::UnsignedLess,
20        _ => {
21            CODEGEN_ASSERT!(false, "Unsupported condition");
22            IrCondition::Count
23        }
24    }
25}