Skip to content

Commit

Permalink
Unify API of Scalar and ScalarMaybeUndef
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Aug 3, 2018
1 parent 4819094 commit 828aebf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librustc/mir/interpret/value.rs
Expand Up @@ -103,6 +103,10 @@ impl<'tcx> Scalar {
ScalarMaybeUndef::Scalar(self).to_value_with_len(len, cx)
}

pub fn to_value_with_vtable(self, vtable: Pointer) -> Value {
ScalarMaybeUndef::Scalar(self).to_value_with_vtable(vtable)
}

pub fn ptr_signed_offset<C: HasDataLayout>(self, i: i64, cx: C) -> EvalResult<'tcx, Self> {
let layout = cx.data_layout();
match self {
Expand Down Expand Up @@ -207,14 +211,14 @@ impl ScalarMaybeUndef {
}

pub fn to_value_with_len<C: HasDataLayout>(self, len: u64, cx: C) -> Value {
Value::ScalarPair(self.into(), Scalar::Bits {
Value::ScalarPair(self, Scalar::Bits {
bits: len as u128,
size: cx.data_layout().pointer_size.bytes() as u8,
}.into())
}

pub fn to_value_with_vtable(self, vtable: Pointer) -> Value {
Value::ScalarPair(self.into(), Scalar::Ptr(vtable).into())
Value::ScalarPair(self, Scalar::Ptr(vtable).into())
}

pub fn ptr_offset<C: HasDataLayout>(self, i: Size, cx: C) -> EvalResult<'tcx, Self> {
Expand Down

0 comments on commit 828aebf

Please sign in to comment.