Skip to main content

DestructurableConstructorOpInterface

Trait DestructurableConstructorOpInterface 

Source
pub trait DestructurableConstructorOpInterface: Op {
    // Required methods
    fn destructurable_values(
        &self,
        ctx: &Context,
    ) -> Vec<DestructurableValueSlot>;
    fn destructure(
        &self,
        ctx: &mut Context,
        value: &DestructurableValueSlot,
        used_indices: &SmallSet<AttrObj, 8>,
        rewriter: &mut PassRewriter,
        new_constructors: &mut Vec<TraitOp<dyn DestructurableConstructorOpInterface>>,
    ) -> HMap<AttrObj, ValueSlot>;
    fn handle_destructuring_complete(
        &self,
        ctx: &mut Context,
        value: &DestructurableValueSlot,
        rewriter: &mut PassRewriter,
    ) -> Option<TraitOp<dyn DestructurableConstructorOpInterface>>;

    // Provided method
    fn verify(_op: &dyn Op, _ctx: &Context) -> Result<()>
       where Self: Sized { ... }
}
Expand description

Describes operations creating values of aggregates that can be destructured into multiple smaller values.

Required Methods§

Source

fn destructurable_values(&self, ctx: &Context) -> Vec<DestructurableValueSlot>

Returns the list of value for which destructuring should be attempted, specifying in which way the value should be destructured into subvalues. This computes the type of the value for each subvalue to be generated. The type of the value must implement DestructurableTypeInterface.

No IR mutation is allowed in this method.

Source

fn destructure( &self, ctx: &mut Context, value: &DestructurableValueSlot, used_indices: &SmallSet<AttrObj, 8>, rewriter: &mut PassRewriter, new_constructors: &mut Vec<TraitOp<dyn DestructurableConstructorOpInterface>>, ) -> HMap<AttrObj, ValueSlot>

Destructures this value into multiple subvalues. The original value must still exist at the end of this call. Only generates subvalues for the indices found in used_indices since all other subvalues are unused.

The rewriter is located before this op.

Source

fn handle_destructuring_complete( &self, ctx: &mut Context, value: &DestructurableValueSlot, rewriter: &mut PassRewriter, ) -> Option<TraitOp<dyn DestructurableConstructorOpInterface>>

Hook triggered once the destructuring of a value is complete, meaning the original value is no longer being referred to and could be deleted. This will only be called for values declared by this operation.

Must return a new destructurable constructor op if this hook creates a new destructurable op, None otherwise.

Provided Methods§

Source

fn verify(_op: &dyn Op, _ctx: &Context) -> Result<()>
where Self: Sized,

Trait Implementations§

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§