Skip to content

Commit ffc6670

Browse files
committed
organize methods a bit better
1 parent 3408713 commit ffc6670

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

src/librustc_mir/interpret/eval_context.rs

+38-36
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,23 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
217217
&mut self.memory
218218
}
219219

220+
#[inline(always)]
221+
pub fn force_ptr(
222+
&self,
223+
scalar: Scalar<M::PointerTag>,
224+
) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
225+
self.memory.force_ptr(scalar)
226+
}
227+
228+
#[inline(always)]
229+
pub fn force_bits(
230+
&self,
231+
scalar: Scalar<M::PointerTag>,
232+
size: Size
233+
) -> InterpResult<'tcx, u128> {
234+
self.memory.force_bits(scalar, size)
235+
}
236+
220237
#[inline(always)]
221238
pub fn tag_static_base_pointer(&self, ptr: Pointer) -> Pointer<M::PointerTag> {
222239
self.memory.tag_static_base_pointer(ptr)
@@ -248,6 +265,27 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
248265
self.frame().body
249266
}
250267

268+
#[inline(always)]
269+
pub fn sign_extend(&self, value: u128, ty: TyLayout<'_>) -> u128 {
270+
assert!(ty.abi.is_signed());
271+
sign_extend(value, ty.size)
272+
}
273+
274+
#[inline(always)]
275+
pub fn truncate(&self, value: u128, ty: TyLayout<'_>) -> u128 {
276+
truncate(value, ty.size)
277+
}
278+
279+
#[inline]
280+
pub fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
281+
ty.is_sized(self.tcx, self.param_env)
282+
}
283+
284+
#[inline]
285+
pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
286+
ty.is_freeze(*self.tcx, self.param_env, DUMMY_SP)
287+
}
288+
251289
pub(super) fn subst_and_normalize_erasing_regions<T: TypeFoldable<'tcx>>(
252290
&self,
253291
substs: T,
@@ -283,14 +321,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
283321
).ok_or_else(|| InterpError::TooGeneric.into())
284322
}
285323

286-
pub fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
287-
ty.is_sized(self.tcx, self.param_env)
288-
}
289-
290-
pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
291-
ty.is_freeze(*self.tcx, self.param_env, DUMMY_SP)
292-
}
293-
294324
pub fn load_mir(
295325
&self,
296326
instance: ty::InstanceDef<'tcx>,
@@ -761,32 +791,4 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
761791
trace!("generate stacktrace: {:#?}, {:?}", frames, explicit_span);
762792
frames
763793
}
764-
765-
#[inline(always)]
766-
pub fn sign_extend(&self, value: u128, ty: TyLayout<'_>) -> u128 {
767-
assert!(ty.abi.is_signed());
768-
sign_extend(value, ty.size)
769-
}
770-
771-
#[inline(always)]
772-
pub fn truncate(&self, value: u128, ty: TyLayout<'_>) -> u128 {
773-
truncate(value, ty.size)
774-
}
775-
776-
#[inline(always)]
777-
pub fn force_ptr(
778-
&self,
779-
scalar: Scalar<M::PointerTag>,
780-
) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
781-
self.memory.force_ptr(scalar)
782-
}
783-
784-
#[inline(always)]
785-
pub fn force_bits(
786-
&self,
787-
scalar: Scalar<M::PointerTag>,
788-
size: Size
789-
) -> InterpResult<'tcx, u128> {
790-
self.memory.force_bits(scalar, size)
791-
}
792794
}

0 commit comments

Comments
 (0)