Rename PrimVal::from_{u,}int to from_{u,i}64.

This commit is contained in:
Scott Olson 2016-12-16 22:11:44 -08:00
parent f83c45e367
commit 3bad50e114
3 changed files with 17 additions and 17 deletions

View File

@ -172,7 +172,7 @@ pub(super) fn str_to_value(&mut self, s: &str) -> EvalResult<'tcx, Value> {
let ptr = self.memory.allocate(s.len() as u64, 1)?;
self.memory.write_bytes(ptr, s.as_bytes())?;
self.memory.freeze(ptr.alloc_id)?;
Ok(Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::from_uint(s.len() as u64)))
Ok(Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::from_u64(s.len() as u64)))
}
pub(super) fn const_to_value(&mut self, const_val: &ConstVal) -> EvalResult<'tcx, Value> {
@ -465,7 +465,7 @@ pub(super) fn eval_rvalue_into_lvalue(
let operand_ty = self.operand_ty(operand);
assert_eq!(self.type_size(operand_ty)?, Some(0));
}
self.write_primval(dest, PrimVal::from_int(0), dest_ty)?;
self.write_primval(dest, PrimVal::from_i64(0), dest_ty)?;
}
} else {
bug!("tried to assign {:?} to Layout::RawNullablePointer", kind);
@ -557,7 +557,7 @@ pub(super) fn eval_rvalue_into_lvalue(
let src = self.eval_lvalue(lvalue)?;
let ty = self.lvalue_ty(lvalue);
let (_, len) = src.elem_ty_and_len(ty);
self.write_primval(dest, PrimVal::from_uint(len), dest_ty)?;
self.write_primval(dest, PrimVal::from_u64(len), dest_ty)?;
}
Ref(_, _, ref lvalue) => {
@ -567,7 +567,7 @@ pub(super) fn eval_rvalue_into_lvalue(
let val = match extra {
LvalueExtra::None => Value::ByVal(ptr),
LvalueExtra::Length(len) => Value::ByValPair(ptr, PrimVal::from_uint(len)),
LvalueExtra::Length(len) => Value::ByValPair(ptr, PrimVal::from_u64(len)),
LvalueExtra::Vtable(vtable) => Value::ByValPair(ptr, PrimVal::Ptr(vtable)),
LvalueExtra::DowncastVariant(..) =>
bug!("attempted to take a reference to an enum downcast lvalue"),
@ -1132,7 +1132,7 @@ fn try_read_value(&mut self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, Opt
I64 => 8,
Is => self.memory.pointer_size(),
};
PrimVal::from_int(self.memory.read_int(ptr, size)?)
PrimVal::from_i64(self.memory.read_int(ptr, size)?)
}
ty::TyUint(uint_ty) => {
@ -1144,7 +1144,7 @@ fn try_read_value(&mut self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, Opt
U64 => 8,
Us => self.memory.pointer_size(),
};
PrimVal::from_uint(self.memory.read_uint(ptr, size)?)
PrimVal::from_u64(self.memory.read_uint(ptr, size)?)
}
ty::TyFloat(FloatTy::F32) => PrimVal::from_f32(self.memory.read_f32(ptr)?),
@ -1163,7 +1163,7 @@ fn try_read_value(&mut self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, Opt
let extra = match self.tcx.struct_tail(ty).sty {
ty::TyDynamic(..) => PrimVal::Ptr(self.memory.read_ptr(extra)?),
ty::TySlice(..) |
ty::TyStr => PrimVal::from_uint(self.memory.read_usize(extra)?),
ty::TyStr => PrimVal::from_u64(self.memory.read_usize(extra)?),
_ => bug!("unsized primval ptr read from {:?}", ty),
};
return Ok(Some(Value::ByValPair(PrimVal::Ptr(p), extra)));
@ -1175,9 +1175,9 @@ fn try_read_value(&mut self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, Opt
if let CEnum { discr, signed, .. } = *self.type_layout(ty)? {
let size = discr.size().bytes();
if signed {
PrimVal::from_int(self.memory.read_int(ptr, size)?)
PrimVal::from_i64(self.memory.read_int(ptr, size)?)
} else {
PrimVal::from_uint(self.memory.read_uint(ptr, size)?)
PrimVal::from_u64(self.memory.read_uint(ptr, size)?)
}
} else {
return Ok(None);
@ -1224,7 +1224,7 @@ fn unsize_into(
match (&src_pointee_ty.sty, &dest_pointee_ty.sty) {
(&ty::TyArray(_, length), &ty::TySlice(_)) => {
let ptr = src.read_ptr(&self.memory)?;
let len = PrimVal::from_uint(length as u64);
let len = PrimVal::from_u64(length as u64);
let ptr = PrimVal::Ptr(ptr);
self.write_value(Value::ByValPair(ptr, len), dest, dest_ty)?;
}

View File

@ -259,7 +259,7 @@ pub(super) fn call_intrinsic(
"min_align_of" => {
let elem_ty = substs.type_at(0);
let elem_align = self.type_align(elem_ty)?;
let align_val = PrimVal::from_uint(elem_align as u64);
let align_val = PrimVal::from_u64(elem_align as u64);
self.write_primval(dest, align_val, dest_ty)?;
}
@ -267,7 +267,7 @@ pub(super) fn call_intrinsic(
let ty = substs.type_at(0);
let layout = self.type_layout(ty)?;
let align = layout.align(&self.tcx.data_layout).pref();
let align_val = PrimVal::from_uint(align);
let align_val = PrimVal::from_u64(align);
self.write_primval(dest, align_val, dest_ty)?;
}
@ -336,20 +336,20 @@ pub(super) fn call_intrinsic(
// .expect("size_of intrinsic called on unsized value")
// see https://github.com/rust-lang/rust/pull/37708
let size = self.type_size(ty)?.unwrap_or(!0) as u64;
self.write_primval(dest, PrimVal::from_uint(size), dest_ty)?;
self.write_primval(dest, PrimVal::from_u64(size), dest_ty)?;
}
"size_of_val" => {
let ty = substs.type_at(0);
let (size, _) = self.size_and_align_of_dst(ty, arg_vals[0])?;
self.write_primval(dest, PrimVal::from_uint(size), dest_ty)?;
self.write_primval(dest, PrimVal::from_u64(size), dest_ty)?;
}
"min_align_of_val" |
"align_of_val" => {
let ty = substs.type_at(0);
let (_, align) = self.size_and_align_of_dst(ty, arg_vals[0])?;
self.write_primval(dest, PrimVal::from_uint(align), dest_ty)?;
self.write_primval(dest, PrimVal::from_u64(align), dest_ty)?;
}
"type_name" => {

View File

@ -137,11 +137,11 @@ pub fn relocation(self) -> Option<AllocId> {
}
}
pub fn from_uint(n: u64) -> Self {
pub fn from_u64(n: u64) -> Self {
PrimVal::Bytes(n)
}
pub fn from_int(n: i64) -> Self {
pub fn from_i64(n: i64) -> Self {
PrimVal::Bytes(n as u64)
}