Improve pattern matching MIR lowering

This commit is contained in:
hkalbasi 2023-03-14 23:01:46 +03:30
parent 051dae2221
commit 9564773d5e
9 changed files with 590 additions and 395 deletions

View file

@ -92,6 +92,16 @@ pub enum Literal {
Float(FloatTypeWrapper, Option<BuiltinFloat>),
}
impl Literal {
pub fn negate(self) -> Option<Self> {
if let Literal::Int(i, k) = self {
Some(Literal::Int(-i, k))
} else {
None
}
}
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Expr {
/// This is produced if the syntax tree does not have a required expression piece.