- BiAdd => l.checked_add(r).map(Constant::Int),
- BiSub => l.checked_sub(r).map(Constant::Int),
- BiMul => l.checked_mul(r).map(Constant::Int),
- BiDiv => l.checked_div(r).map(Constant::Int),
- BiRem => l.checked_rem(r).map(Constant::Int),
- BiShr => l.checked_shr(r as u32).map(Constant::Int),
- BiShl => l.checked_shl(r as u32).map(Constant::Int),
- BiBitXor => Some(Constant::Int(l ^ r)),
- BiBitOr => Some(Constant::Int(l | r)),
- BiBitAnd => Some(Constant::Int(l & r)),
- BiEq => Some(Constant::Bool(l == r)),
- BiNe => Some(Constant::Bool(l != r)),
- BiLt => Some(Constant::Bool(l < r)),
- BiLe => Some(Constant::Bool(l <= r)),
- BiGe => Some(Constant::Bool(l >= r)),
- BiGt => Some(Constant::Bool(l > r)),
+ BinOpKind::Add => l.checked_add(r).map(Constant::Int),
+ BinOpKind::Sub => l.checked_sub(r).map(Constant::Int),
+ BinOpKind::Mul => l.checked_mul(r).map(Constant::Int),
+ BinOpKind::Div => l.checked_div(r).map(Constant::Int),
+ BinOpKind::Rem => l.checked_rem(r).map(Constant::Int),
+ BinOpKind::Shr => l.checked_shr(
+ r.try_into().expect("shift too large")
+ ).map(Constant::Int),
+ BinOpKind::Shl => l.checked_shl(
+ r.try_into().expect("shift too large")
+ ).map(Constant::Int),
+ BinOpKind::BitXor => Some(Constant::Int(l ^ r)),
+ BinOpKind::BitOr => Some(Constant::Int(l | r)),
+ BinOpKind::BitAnd => Some(Constant::Int(l & r)),
+ BinOpKind::Eq => Some(Constant::Bool(l == r)),
+ BinOpKind::Ne => Some(Constant::Bool(l != r)),
+ BinOpKind::Lt => Some(Constant::Bool(l < r)),
+ BinOpKind::Le => Some(Constant::Bool(l <= r)),
+ BinOpKind::Ge => Some(Constant::Bool(l >= r)),
+ BinOpKind::Gt => Some(Constant::Bool(l > r)),