pub trait Value<'mir, 'tcx, M>where
M: Machine<'mir, 'tcx>,{
fn layout(&self) -> TyAndLayout<'tcx, Ty<'tcx>>;
fn to_op_for_read(
&self,
ecx: &InterpCx<'mir, 'tcx, M>
) -> Result<OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>, InterpErrorInfo<'tcx>>;
fn from_op(op: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>) -> Self;
fn project_downcast(
&self,
ecx: &InterpCx<'mir, 'tcx, M>,
variant: VariantIdx
) -> Result<Self, InterpErrorInfo<'tcx>>;
fn project_field(
&self,
ecx: &InterpCx<'mir, 'tcx, M>,
field: usize
) -> Result<Self, InterpErrorInfo<'tcx>>;
fn to_op_for_proj(
&self,
ecx: &InterpCx<'mir, 'tcx, M>
) -> Result<OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>, InterpErrorInfo<'tcx>> { ... }
}
Expand description
A thing that we can project into, and that has a layout.
This wouldn’t have to depend on Machine
but with the current type inference,
that’s just more convenient to work with (avoids repeating all the Machine
bounds).
Required Methods
sourcefn layout(&self) -> TyAndLayout<'tcx, Ty<'tcx>>
fn layout(&self) -> TyAndLayout<'tcx, Ty<'tcx>>
Gets this value’s layout.
sourcefn to_op_for_read(
&self,
ecx: &InterpCx<'mir, 'tcx, M>
) -> Result<OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>, InterpErrorInfo<'tcx>>
fn to_op_for_read(
&self,
ecx: &InterpCx<'mir, 'tcx, M>
) -> Result<OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>, InterpErrorInfo<'tcx>>
Makes this into an OpTy
, in a cheap way that is good for reading.
sourcefn from_op(op: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>) -> Self
fn from_op(op: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>) -> Self
Creates this from an OpTy
.
If to_op_for_proj
only ever produces Indirect
operands, then this one is definitely Indirect
.
sourcefn project_downcast(
&self,
ecx: &InterpCx<'mir, 'tcx, M>,
variant: VariantIdx
) -> Result<Self, InterpErrorInfo<'tcx>>
fn project_downcast(
&self,
ecx: &InterpCx<'mir, 'tcx, M>,
variant: VariantIdx
) -> Result<Self, InterpErrorInfo<'tcx>>
Projects to the given enum variant.
sourcefn project_field(
&self,
ecx: &InterpCx<'mir, 'tcx, M>,
field: usize
) -> Result<Self, InterpErrorInfo<'tcx>>
fn project_field(
&self,
ecx: &InterpCx<'mir, 'tcx, M>,
field: usize
) -> Result<Self, InterpErrorInfo<'tcx>>
Projects to the n-th field.
Provided Methods
sourcefn to_op_for_proj(
&self,
ecx: &InterpCx<'mir, 'tcx, M>
) -> Result<OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>, InterpErrorInfo<'tcx>>
fn to_op_for_proj(
&self,
ecx: &InterpCx<'mir, 'tcx, M>
) -> Result<OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>, InterpErrorInfo<'tcx>>
Makes this into an OpTy
, in a potentially more expensive way that is good for projections.