From 24be49f7dd927d74af8a5adae672fa35234740e0 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 21 Oct 2016 10:29:56 +0200 Subject: [PATCH] add a 'tcx lifetime to Lvalue in preparation for statics --- src/interpreter/mod.rs | 28 ++++++++++++------------ src/interpreter/terminator/intrinsics.rs | 2 +- src/interpreter/terminator/mod.rs | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index 0b39da9f382..2663ea159dc 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -77,7 +77,7 @@ pub struct Frame<'a, 'tcx: 'a> { pub return_to_block: StackPopCleanup, /// The location where the result of the current stack frame should be written to. - pub return_lvalue: Lvalue, + pub return_lvalue: Lvalue<'tcx>, /// The list of locals for this stack frame, stored in order as /// `[arguments..., variables..., temporaries...]`. The locals are stored as `Value`s, which @@ -99,7 +99,7 @@ pub struct Frame<'a, 'tcx: 'a> { } #[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub enum Lvalue { +pub enum Lvalue<'tcx> { /// An lvalue referring to a value allocated in the `Memory` system. Ptr { ptr: Pointer, @@ -347,7 +347,7 @@ pub fn push_stack_frame( span: codemap::Span, mir: CachedMir<'a, 'tcx>, substs: &'tcx Substs<'tcx>, - return_lvalue: Lvalue, + return_lvalue: Lvalue<'tcx>, return_to_block: StackPopCleanup, ) -> EvalResult<'tcx, ()> { ::log_settings::settings().indentation += 1; @@ -406,7 +406,7 @@ fn intrinsic_with_overflow( op: mir::BinOp, left: &mir::Operand<'tcx>, right: &mir::Operand<'tcx>, - dest: Lvalue, + dest: Lvalue<'tcx>, dest_ty: Ty<'tcx>, ) -> EvalResult<'tcx, ()> { let (val, overflowed) = self.binop_with_overflow(op, left, right)?; @@ -421,7 +421,7 @@ fn intrinsic_overflowing( op: mir::BinOp, left: &mir::Operand<'tcx>, right: &mir::Operand<'tcx>, - dest: Lvalue, + dest: Lvalue<'tcx>, ) -> EvalResult<'tcx, bool> { let (val, overflowed) = self.binop_with_overflow(op, left, right)?; self.write_primval(dest, val)?; @@ -430,7 +430,7 @@ fn intrinsic_overflowing( fn assign_fields>( &mut self, - dest: Lvalue, + dest: Lvalue<'tcx>, offsets: I, operands: &[mir::Operand<'tcx>], ) -> EvalResult<'tcx, ()> { @@ -863,7 +863,7 @@ fn eval_and_read_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult<'tc } } - fn eval_lvalue(&mut self, mir_lvalue: &mir::Lvalue<'tcx>) -> EvalResult<'tcx, Lvalue> { + fn eval_lvalue(&mut self, mir_lvalue: &mir::Lvalue<'tcx>) -> EvalResult<'tcx, Lvalue<'tcx>> { use rustc::mir::repr::Lvalue::*; let lvalue = match *mir_lvalue { Local(mir::RETURN_POINTER) => self.frame().return_lvalue, @@ -900,7 +900,7 @@ fn eval_lvalue(&mut self, mir_lvalue: &mir::Lvalue<'tcx>) -> EvalResult<'tcx, Lv fn eval_lvalue_projection( &mut self, proj: &mir::LvalueProjection<'tcx>, - ) -> EvalResult<'tcx, Lvalue> { + ) -> EvalResult<'tcx, Lvalue<'tcx>> { let base = self.eval_lvalue(&proj.base)?; let base_ty = self.lvalue_ty(&proj.base); let base_layout = self.type_layout(base_ty); @@ -1071,7 +1071,7 @@ fn copy(&mut self, src: Pointer, dest: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx Ok(()) } - fn force_allocation(&mut self, lvalue: Lvalue) -> EvalResult<'tcx, Lvalue> { + fn force_allocation(&mut self, lvalue: Lvalue<'tcx>) -> EvalResult<'tcx, Lvalue<'tcx>> { let new_lvalue = match lvalue { Lvalue::Local { frame, local } => { let ptr = match self.stack[frame].get_local(local) { @@ -1157,7 +1157,7 @@ fn value_to_primval(&mut self, value: Value, ty: Ty<'tcx>) -> EvalResult<'tcx, P fn write_primval( &mut self, - dest: Lvalue, + dest: Lvalue<'tcx>, val: PrimVal, ) -> EvalResult<'tcx, ()> { match dest { @@ -1175,7 +1175,7 @@ fn write_primval( fn write_value( &mut self, src_val: Value, - dest: Lvalue, + dest: Lvalue<'tcx>, dest_ty: Ty<'tcx>, ) -> EvalResult<'tcx, ()> { match dest { @@ -1441,7 +1441,7 @@ fn unsize_into( Ok(()) } - fn dump_local(&self, lvalue: Lvalue) { + fn dump_local(&self, lvalue: Lvalue<'tcx>) { if let Lvalue::Local { frame, local } = lvalue { if let Some(val) = self.stack[frame].get_local(local) { match val { @@ -1473,7 +1473,7 @@ fn set_local(&mut self, local: mir::Local, value: Value) { } } -impl Lvalue { +impl<'tcx> Lvalue<'tcx> { pub fn from_ptr(ptr: Pointer) -> Self { Lvalue::Ptr { ptr: ptr, extra: LvalueExtra::None } } @@ -1492,7 +1492,7 @@ fn to_ptr(self) -> Pointer { ptr } - fn elem_ty_and_len<'tcx>(self, ty: Ty<'tcx>) -> (Ty<'tcx>, u64) { + fn elem_ty_and_len(self, ty: Ty<'tcx>) -> (Ty<'tcx>, u64) { match ty.sty { ty::TyArray(elem, n) => (elem, n as u64), diff --git a/src/interpreter/terminator/intrinsics.rs b/src/interpreter/terminator/intrinsics.rs index c3327dd76f9..c4289375432 100644 --- a/src/interpreter/terminator/intrinsics.rs +++ b/src/interpreter/terminator/intrinsics.rs @@ -15,7 +15,7 @@ pub(super) fn call_intrinsic( def_id: DefId, substs: &'tcx Substs<'tcx>, args: &[mir::Operand<'tcx>], - dest: Lvalue, + dest: Lvalue<'tcx>, dest_ty: Ty<'tcx>, dest_layout: &'tcx Layout, ) -> EvalResult<'tcx, ()> { diff --git a/src/interpreter/terminator/mod.rs b/src/interpreter/terminator/mod.rs index be6147f8b74..e8be90cf91a 100644 --- a/src/interpreter/terminator/mod.rs +++ b/src/interpreter/terminator/mod.rs @@ -150,7 +150,7 @@ fn eval_fn_call( def_id: DefId, substs: &'tcx Substs<'tcx>, fn_ty: &'tcx BareFnTy, - destination: Option<(Lvalue, mir::BasicBlock)>, + destination: Option<(Lvalue<'tcx>, mir::BasicBlock)>, arg_operands: &[mir::Operand<'tcx>], span: Span, ) -> EvalResult<'tcx, ()> { @@ -264,7 +264,7 @@ fn call_c_abi( &mut self, def_id: DefId, args: &[mir::Operand<'tcx>], - dest: Lvalue, + dest: Lvalue<'tcx>, dest_size: usize, ) -> EvalResult<'tcx, ()> { let name = self.tcx.item_name(def_id); -- GitLab