Trait miri::ValueVisitor

source ·
pub trait ValueVisitor<'mir, 'tcx, M>: Sizedwhere
    'tcx: 'mir,
    M: Machine<'mir, 'tcx>,{
    type V: Projectable<'tcx, <M as Machine<'mir, 'tcx>>::Provenance> + From<MPlaceTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>>;

    // Required method
    fn ecx(&self) -> &InterpCx<'mir, 'tcx, M>;

    // Provided methods
    fn read_discriminant(
        &mut self,
        v: &Self::V
    ) -> Result<VariantIdx, InterpErrorInfo<'tcx>> { ... }
    fn aggregate_field_order(
        _memory_index: &IndexVec<FieldIdx, u32>,
        idx: usize
    ) -> usize { ... }
    fn visit_value(&mut self, v: &Self::V) -> Result<(), InterpErrorInfo<'tcx>> { ... }
    fn visit_union(
        &mut self,
        _v: &Self::V,
        _fields: NonZeroUsize
    ) -> Result<(), InterpErrorInfo<'tcx>> { ... }
    fn visit_box(&mut self, _v: &Self::V) -> Result<(), InterpErrorInfo<'tcx>> { ... }
    fn visit_field(
        &mut self,
        _old_val: &Self::V,
        _field: usize,
        new_val: &Self::V
    ) -> Result<(), InterpErrorInfo<'tcx>> { ... }
    fn visit_variant(
        &mut self,
        _old_val: &Self::V,
        _variant: VariantIdx,
        new_val: &Self::V
    ) -> Result<(), InterpErrorInfo<'tcx>> { ... }
    fn walk_value(&mut self, v: &Self::V) -> Result<(), InterpErrorInfo<'tcx>> { ... }
}
Expand description

How to traverse a value and what to do when we are at the leaves.

Required Associated Types§

source

type V: Projectable<'tcx, <M as Machine<'mir, 'tcx>>::Provenance> + From<MPlaceTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>>

Required Methods§

source

fn ecx(&self) -> &InterpCx<'mir, 'tcx, M>

The visitor must have an InterpCx in it.

Provided Methods§

source

fn read_discriminant( &mut self, v: &Self::V ) -> Result<VariantIdx, InterpErrorInfo<'tcx>>

read_discriminant can be hooked for better error messages.

source

fn aggregate_field_order( _memory_index: &IndexVec<FieldIdx, u32>, idx: usize ) -> usize

This function provides the chance to reorder the order in which fields are visited for FieldsShape::Aggregate: The order of fields will be (0..num_fields).map(aggregate_field_order).

The default means we iterate in source declaration order; alternative this can do an inverse lookup in memory_index to use memory field order instead.

source

fn visit_value(&mut self, v: &Self::V) -> Result<(), InterpErrorInfo<'tcx>>

Visits the given value, dispatching as appropriate to more specialized visitors.

source

fn visit_union( &mut self, _v: &Self::V, _fields: NonZeroUsize ) -> Result<(), InterpErrorInfo<'tcx>>

Visits the given value as a union. No automatic recursion can happen here.

source

fn visit_box(&mut self, _v: &Self::V) -> Result<(), InterpErrorInfo<'tcx>>

Visits the given value as the pointer of a Box. There is nothing to recurse into. The type of v will be a raw pointer, but this is a field of Box<T> and the pointee type is the actual T.

source

fn visit_field( &mut self, _old_val: &Self::V, _field: usize, new_val: &Self::V ) -> Result<(), InterpErrorInfo<'tcx>>

Called each time we recurse down to a field of a “product-like” aggregate (structs, tuples, arrays and the like, but not enums), passing in old (outer) and new (inner) value. This gives the visitor the chance to track the stack of nested fields that we are descending through.

source

fn visit_variant( &mut self, _old_val: &Self::V, _variant: VariantIdx, new_val: &Self::V ) -> Result<(), InterpErrorInfo<'tcx>>

Called when recursing into an enum variant. This gives the visitor the chance to track the stack of nested fields that we are descending through.

source

fn walk_value(&mut self, v: &Self::V) -> Result<(), InterpErrorInfo<'tcx>>

Implementors§