Make eval_place iterate instead of recurse
This commit is contained in:
parent
f492693982
commit
e8beea7019
1 changed files with 30 additions and 30 deletions
|
@ -607,42 +607,42 @@ where
|
||||||
/// place; for reading, a more efficient alternative is `eval_place_for_read`.
|
/// place; for reading, a more efficient alternative is `eval_place_for_read`.
|
||||||
pub fn eval_place(
|
pub fn eval_place(
|
||||||
&mut self,
|
&mut self,
|
||||||
mir_place: &mir::Place<'tcx>
|
mir_place: &mir::Place<'tcx>,
|
||||||
) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
|
) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
|
||||||
use rustc::mir::Place::*;
|
|
||||||
use rustc::mir::PlaceBase;
|
use rustc::mir::PlaceBase;
|
||||||
let place = match mir_place {
|
|
||||||
Base(PlaceBase::Local(mir::RETURN_PLACE)) => match self.frame().return_place {
|
mir_place.iterate(|place_base, place_projection| {
|
||||||
Some(return_place) =>
|
let mut place = match place_base {
|
||||||
// We use our layout to verify our assumption; caller will validate
|
PlaceBase::Local(mir::RETURN_PLACE) => match self.frame().return_place {
|
||||||
// their layout on return.
|
Some(return_place) => {
|
||||||
PlaceTy {
|
// We use our layout to verify our assumption; caller will validate
|
||||||
place: *return_place,
|
// their layout on return.
|
||||||
layout: self.layout_of(self.monomorphize(self.frame().mir.return_ty())?)?,
|
PlaceTy {
|
||||||
},
|
place: *return_place,
|
||||||
None => return err!(InvalidNullPointerUsage),
|
layout: self
|
||||||
},
|
.layout_of(self.monomorphize(self.frame().mir.return_ty())?)?,
|
||||||
Base(PlaceBase::Local(local)) => PlaceTy {
|
}
|
||||||
// This works even for dead/uninitialized locals; we check further when writing
|
}
|
||||||
place: Place::Local {
|
None => return err!(InvalidNullPointerUsage),
|
||||||
frame: self.cur_frame(),
|
|
||||||
local: *local,
|
|
||||||
},
|
},
|
||||||
layout: self.layout_of_local(self.frame(), *local, None)?,
|
PlaceBase::Local(local) => PlaceTy {
|
||||||
},
|
// This works even for dead/uninitialized locals; we check further when writing
|
||||||
|
place: Place::Local {
|
||||||
|
frame: self.cur_frame(),
|
||||||
|
local: *local,
|
||||||
|
},
|
||||||
|
layout: self.layout_of_local(self.frame(), *local, None)?,
|
||||||
|
},
|
||||||
|
PlaceBase::Static(place_static) => self.eval_static_to_mplace(place_static)?.into(),
|
||||||
|
};
|
||||||
|
|
||||||
Projection(proj) => {
|
for proj in place_projection {
|
||||||
let place = self.eval_place(&proj.base)?;
|
place = self.place_projection(place, &proj.elem)?
|
||||||
self.place_projection(place, &proj.elem)?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Base(PlaceBase::Static(place_static)) => {
|
self.dump_place(place.place);
|
||||||
self.eval_static_to_mplace(place_static)?.into()
|
Ok(place)
|
||||||
}
|
})
|
||||||
};
|
|
||||||
|
|
||||||
self.dump_place(place.place);
|
|
||||||
Ok(place)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write a scalar to a place
|
/// Write a scalar to a place
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue