Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/rpl_context/src/pat/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl fmt::Display for RegionKind {
impl fmt::Debug for IntValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.ty {
IntTy::AnyInt => write!(f, "{}", self.value),
IntTy::Bool => write!(f, "{}", self.value != 0),
IntTy::Int(ty) => write!(f, "{}_{}", self.value, ty.name_str()),
IntTy::NegInt(ty) => write!(f, "-{}_{}", self.value, ty.name_str()),
Expand Down
7 changes: 4 additions & 3 deletions crates/rpl_context/src/pat/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ impl<'pcx> PathWithArgs<'pcx> {

#[derive(PartialEq, Eq, Hash, Clone, Copy)]
pub enum IntTy {
AnyInt,
NegInt(ty::IntTy),
Int(ty::IntTy),
Uint(ty::UintTy),
Expand Down Expand Up @@ -624,7 +625,7 @@ impl IntValue {
let ty = if let Some(ty) = ty {
IntTy::from(ty)
} else {
IntTy::Uint(ty::UintTy::Usize)
IntTy::AnyInt
};
Self { value, ty }
}
Expand All @@ -645,7 +646,7 @@ impl IntValue {

impl IntValue {
pub fn normalize(self, pointer_bytes: u64) -> Pu128 {
use IntTy::{Bool, Int, NegInt, Uint};
use IntTy::{AnyInt, Bool, Int, NegInt, Uint};
use ty::IntTy::{I8, I16, I32, I64, I128, Isize};

let IntValue { ty, value } = self;
Expand All @@ -661,7 +662,7 @@ impl IntValue {
8 => u128::from(u64::MAX),
_ => panic!("unsupported pointer size: {pointer_bytes}"),
},
Int(_) | Uint(_) | Bool => return value,
AnyInt | Int(_) | Uint(_) | Bool => return value,
};
Pu128((value.get() ^ mask).wrapping_add(1) & mask)
}
Expand Down
1 change: 1 addition & 0 deletions crates/rpl_match/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ pub(crate) trait MatchStatement<'pcx, 'tcx> {
(&pat::ConstOperand::ConstVar(const_var), konst) => self.ty().match_mir_const_var(const_var, konst),
(&pat::ConstOperand::ScalarInt(value_pat), mir::Const::Val(mir::ConstValue::Scalar(value), ty)) => {
(match (value_pat.ty, *ty.kind()) {
(pat::IntTy::AnyInt, ty::Int(_) | ty::Uint(_)) => true,
(pat::IntTy::NegInt(ty_pat), ty::Int(ty)) => ty_pat == ty,
(pat::IntTy::Int(ty_pat), ty::Int(ty)) => ty_pat == ty,
(pat::IntTy::Uint(ty_pat), ty::Uint(ty)) => ty_pat == ty,
Expand Down