diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-05-20 23:46:30 +0200 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-05-24 20:47:35 +0200 |
| commit | ef2177cffc66abdffad4b09a093239a8ba22e434 (patch) | |
| tree | 7b6a44abd1c8d91dae2f9fee28052f78f69a21b3 /src/librustc/mir | |
| parent | 1606e137e7de642d7994e201ed54389a4e808e24 (diff) | |
| download | rust-ef2177cffc66abdffad4b09a093239a8ba22e434.tar.gz rust-ef2177cffc66abdffad4b09a093239a8ba22e434.zip | |
Rename ByVal(Pair) to Scalar(Pair)
Diffstat (limited to 'src/librustc/mir')
| -rw-r--r-- | src/librustc/mir/interpret/value.rs | 32 | ||||
| -rw-r--r-- | src/librustc/mir/mod.rs | 20 |
2 files changed, 26 insertions, 26 deletions
diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 1e41c79e27b..497f5397189 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -5,14 +5,14 @@ use ty; use super::{EvalResult, MemoryPointer, PointerArithmetic, Allocation}; -/// Represents a constant value in Rust. ByVal and ByValPair are optimizations which +/// Represents a constant value in Rust. ByVal and ScalarPair are optimizations which /// matches Value's optimizations for easy conversions between these two types #[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash)] pub enum ConstValue<'tcx> { /// Used only for types with layout::abi::Scalar ABI and ZSTs which use Scalar::Undef - ByVal(Scalar), + Scalar(Scalar), /// Used only for types with layout::abi::ScalarPair - ByValPair(Scalar, Scalar), + ScalarPair(Scalar, Scalar), /// Used only for the remaining cases. An allocation + offset into the allocation ByRef(&'tcx Allocation, Size), } @@ -22,8 +22,8 @@ impl<'tcx> ConstValue<'tcx> { pub fn from_byval_value(val: Value) -> Self { match val { Value::ByRef(..) => bug!(), - Value::ByValPair(a, b) => ConstValue::ByValPair(a, b), - Value::ByVal(val) => ConstValue::ByVal(val), + Value::ScalarPair(a, b) => ConstValue::ScalarPair(a, b), + Value::Scalar(val) => ConstValue::Scalar(val), } } @@ -31,22 +31,22 @@ impl<'tcx> ConstValue<'tcx> { pub fn to_byval_value(&self) -> Option<Value> { match *self { ConstValue::ByRef(..) => None, - ConstValue::ByValPair(a, b) => Some(Value::ByValPair(a, b)), - ConstValue::ByVal(val) => Some(Value::ByVal(val)), + ConstValue::ScalarPair(a, b) => Some(Value::ScalarPair(a, b)), + ConstValue::Scalar(val) => Some(Value::Scalar(val)), } } #[inline] pub fn from_primval(val: Scalar) -> Self { - ConstValue::ByVal(val) + ConstValue::Scalar(val) } #[inline] pub fn to_primval(&self) -> Option<Scalar> { match *self { ConstValue::ByRef(..) => None, - ConstValue::ByValPair(..) => None, - ConstValue::ByVal(val) => Some(val), + ConstValue::ScalarPair(..) => None, + ConstValue::Scalar(val) => Some(val), } } @@ -74,13 +74,13 @@ impl<'tcx> ConstValue<'tcx> { /// whether the pointer is supposed to be aligned or not (also see Place). /// /// For optimization of a few very common cases, there is also a representation for a pair of -/// primitive values (`ByValPair`). It allows Miri to avoid making allocations for checked binary +/// primitive values (`ScalarPair`). It allows Miri to avoid making allocations for checked binary /// operations and fat pointers. This idea was taken from rustc's codegen. #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] pub enum Value { ByRef(Pointer, Align), - ByVal(Scalar), - ByValPair(Scalar, Scalar), + Scalar(Scalar), + ScalarPair(Scalar, Scalar), } impl<'tcx> ty::TypeFoldable<'tcx> for Value { @@ -166,15 +166,15 @@ impl<'tcx> Pointer { } pub fn to_value_with_len(self, len: u64) -> Value { - Value::ByValPair(self.primval, Scalar::from_u128(len as u128)) + Value::ScalarPair(self.primval, Scalar::from_u128(len as u128)) } pub fn to_value_with_vtable(self, vtable: MemoryPointer) -> Value { - Value::ByValPair(self.primval, Scalar::Ptr(vtable)) + Value::ScalarPair(self.primval, Scalar::Ptr(vtable)) } pub fn to_value(self) -> Value { - Value::ByVal(self.primval) + Value::Scalar(self.primval) } } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 8077429e526..0dc860d360f 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1153,7 +1153,7 @@ impl<'tcx> TerminatorKind<'tcx> { .map(|&u| { let mut s = String::new(); print_miri_value( - Value::ByVal(Scalar::Bytes(u)), + Value::Scalar(Scalar::Bytes(u)), switch_ty, &mut s, ).unwrap(); @@ -1893,19 +1893,19 @@ pub fn fmt_const_val<W: Write>(fmt: &mut W, const_val: &ty::Const) -> fmt::Resul pub fn print_miri_value<W: Write>(value: Value, ty: Ty, f: &mut W) -> fmt::Result { use ty::TypeVariants::*; match (value, &ty.sty) { - (Value::ByVal(Scalar::Bytes(0)), &TyBool) => write!(f, "false"), - (Value::ByVal(Scalar::Bytes(1)), &TyBool) => write!(f, "true"), - (Value::ByVal(Scalar::Bytes(bits)), &TyFloat(ast::FloatTy::F32)) => + (Value::Scalar(Scalar::Bytes(0)), &TyBool) => write!(f, "false"), + (Value::Scalar(Scalar::Bytes(1)), &TyBool) => write!(f, "true"), + (Value::Scalar(Scalar::Bytes(bits)), &TyFloat(ast::FloatTy::F32)) => write!(f, "{}f32", Single::from_bits(bits)), - (Value::ByVal(Scalar::Bytes(bits)), &TyFloat(ast::FloatTy::F64)) => + (Value::Scalar(Scalar::Bytes(bits)), &TyFloat(ast::FloatTy::F64)) => write!(f, "{}f64", Double::from_bits(bits)), - (Value::ByVal(Scalar::Bytes(n)), &TyUint(ui)) => write!(f, "{:?}{}", n, ui), - (Value::ByVal(Scalar::Bytes(n)), &TyInt(i)) => write!(f, "{:?}{}", n as i128, i), - (Value::ByVal(Scalar::Bytes(n)), &TyChar) => + (Value::Scalar(Scalar::Bytes(n)), &TyUint(ui)) => write!(f, "{:?}{}", n, ui), + (Value::Scalar(Scalar::Bytes(n)), &TyInt(i)) => write!(f, "{:?}{}", n as i128, i), + (Value::Scalar(Scalar::Bytes(n)), &TyChar) => write!(f, "{:?}", ::std::char::from_u32(n as u32).unwrap()), - (Value::ByVal(Scalar::Undef), &TyFnDef(did, _)) => + (Value::Scalar(Scalar::Undef), &TyFnDef(did, _)) => write!(f, "{}", item_path_str(did)), - (Value::ByValPair(Scalar::Ptr(ptr), Scalar::Bytes(len)), + (Value::ScalarPair(Scalar::Ptr(ptr), Scalar::Bytes(len)), &TyRef(_, &ty::TyS { sty: TyStr, .. }, _)) => { ty::tls::with(|tcx| { match tcx.alloc_map.lock().get(ptr.alloc_id) { |
