Skip to content

Commit 3e62ba1

Browse files
committed
Add method to get OpTy for local from arbitrary frame
1 parent ea51e32 commit 3e62ba1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/librustc_mir/interpret/operand.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl<Tag> Operand<Tag> {
291291

292292
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
293293
pub struct OpTy<'tcx, Tag=()> {
294-
pub op: Operand<Tag>, // This is used by [priroda](https://github.com/oli-obk/priroda)
294+
crate op: Operand<Tag>, // ideally we'd make this private, but const_prop needs this
295295
pub layout: TyLayout<'tcx>,
296296
}
297297

@@ -772,4 +772,14 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
772772
})
773773
}
774774

775+
/// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local
776+
pub fn read_local_of_frame(
777+
&self,
778+
frame: &super::Frame,
779+
local: mir::Local
780+
) -> EvalResult<'tcx, OpTy<'tcx>> {
781+
let op = frame.locals[local].access()?;
782+
let layout = self.layout_of_local(frame, local)?;
783+
OpTy { op, layout }
784+
}
775785
}

0 commit comments

Comments
 (0)