From 3e62ba1af6df5bd14fe210b9f20977e97bbae370 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 19 Oct 2018 14:12:42 +0200 Subject: [PATCH] Add method to get OpTy for local from arbitrary frame --- src/librustc_mir/interpret/operand.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 83b5831f3ad..8d2190d22c0 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -291,7 +291,7 @@ impl Operand { #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct OpTy<'tcx, Tag=()> { - pub op: Operand, // This is used by [priroda](https://github.com/oli-obk/priroda) + crate op: Operand, // ideally we'd make this private, but const_prop needs this pub layout: TyLayout<'tcx>, } @@ -772,4 +772,14 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> }) } + /// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local + pub fn read_local_of_frame( + &self, + frame: &super::Frame, + local: mir::Local + ) -> EvalResult<'tcx, OpTy<'tcx>> { + let op = frame.locals[local].access()?; + let layout = self.layout_of_local(frame, local)?; + OpTy { op, layout } + } }