svlog: value: Add tombstone to const values
@@ -32,23 +32,12 @@ pub struct ValueData<'t> {
pub kind: ValueKind<'t>,
}
-/// The different forms a value can assume.
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub enum ValueKind<'t> {
- /// The `void` value.
- Void,
- /// An arbitrary precision integer.
- ///
- /// The first field contains the value. The second field indicates the
- /// special bits (x or z), and the third indicates the x bits.
- Int(BigInt, BitVec, BitVec),
- /// An arbitrary precision time interval.
- Time(BigRational),
- /// A struct.
- StructOrArray(Vec<Value<'t>>),
+impl<'t> ValueData<'t> {
+ /// Check if the value represents a computation error tombstone.
+ pub fn is_error(&self) -> bool {
+ self.ty.is_error() || self.kind.is_error()
}
-impl<'t> ValueData<'t> {
/// Check if this value evaluates to true.
pub fn is_true(&self) -> bool {
!self.is_false()
@@ -61,6 +50,7 @@ impl<'t> ValueData<'t> {
ValueKind::Int(ref v, ..) => v.is_zero(),
ValueKind::Time(ref v) => v.is_zero(),
ValueKind::StructOrArray(_) => false,
+ ValueKind::Error => true,
}
}
@@ -73,6 +63,34 @@ impl<'t> ValueData<'t> {
}
}
+/// The different forms a value can assume.
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub enum ValueKind<'t> {
+ /// The `void` value.
+ Void,
+ /// An arbitrary precision integer.
+ ///
+ /// The first field contains the value. The second field indicates the
+ /// special bits (x or z), and the third indicates the x bits.
+ Int(BigInt, BitVec, BitVec),
+ /// An arbitrary precision time interval.
+ Time(BigRational),
+ /// A struct.
+ StructOrArray(Vec<Value<'t>>),
+ /// An error occurred during value computation.
+ Error,
+}
+
+impl<'t> ValueKind<'t> {
+ /// Check if the value represents a computation error tombstone.
+ pub fn is_error(&self) -> bool {
+ match self {
+ ValueKind::Error => true,
+ _ => false,
+ }
+ }
+}
+
/// Create a new integer value.
///
/// Panics if `ty` is not an integer type. Truncates the value to `ty`.
