...
 
Commits (3)
......@@ -1031,6 +1031,16 @@ impl Value {
}
}
pub fn is_const_one(&self) -> bool {
match self.v {
Value_::Constant(Constant::Int(val)) if val == 1 => true,
Value_::Constant(Constant::IntEx(ref vec)) => {
vec[0] == 1 && vec[1..].iter().all(|x| *x == 0)
}
_ => false
}
}
/// disguises a value as another type.
/// This is usually used for treat an integer type as an integer of a different length
/// This method is unsafe
......@@ -1073,6 +1083,13 @@ impl Value {
}
}
pub fn extract_func_const(&self) -> Option<MuID> {
match self.v {
Value_::Constant(Constant::FuncRef(id)) => Some(id),
_ => None
}
}
pub fn extract_int_const(&self) -> Option<u64> {
match self.v {
Value_::Constant(Constant::Int(val)) => Some(val),
......