Skip to main content

Type

Trait Type 

Source
pub trait Type: Send + Sync {
    // Required methods
    fn size(&self) -> usize;
    fn clone_box(&self) -> Box<dyn Type>;
    fn repr(&self) -> TypeRepr;

    // Provided methods
    fn space(&self) -> Option<MemorySpaceId> { ... }
    fn fields(&self) -> Option<&[AggregateField]> { ... }
    fn struct_name(&self) -> Option<&str> { ... }
    fn function_return_owner(&self) -> Option<FunctionId> { ... }
    fn pointee(&self) -> Option<TypeId> { ... }
    fn array(&self) -> Option<(TypeId, usize)> { ... }
    fn list(&self) -> Option<(TypeId, Option<usize>)> { ... }
}

Required Methods§

Source

fn size(&self) -> usize

Width of values of this type in bytes.

Source

fn clone_box(&self) -> Box<dyn Type>

Clones this type into a fresh boxed trait object.

This enables Clone for Box<dyn Type> (and hence Clone for TypeManager and Context), which the GUI relies on to fork a context before running an analysis pipeline.

Source

fn repr(&self) -> TypeRepr

Describes this type in a flat, serializable form.

Used to persist the TypeManager across a saved session: trait objects cannot be serialized directly, so each type reports a TypeRepr from which it can be reconstructed.

Provided Methods§

Source

fn space(&self) -> Option<MemorySpaceId>

The memory space this type lives in, if it is a pointer type.

Source

fn fields(&self) -> Option<&[AggregateField]>

The ordered field types, if this is an AggregateType or nominal StructType.

Source

fn struct_name(&self) -> Option<&str>

The name of this type, if it is a nominal StructType.

Source

fn function_return_owner(&self) -> Option<FunctionId>

Owning function when this is its unique, editable return-record type.

Source

fn pointee(&self) -> Option<TypeId>

The pointee type, if this is a StructPointer.

Source

fn array(&self) -> Option<(TypeId, usize)>

The (elem, count) pair, if this is an ArrayType. Returns None for every other type — this is the only discriminator element-aware code uses to tell an array from the width-N scalar it otherwise looks like.

Source

fn list(&self) -> Option<(TypeId, Option<usize>)>

The (elem, bound) pair, if this is a ListType — a variable-length sequence whose bound is the static element upper bound (Some(n)) or None when unbounded (a pointer-sourced string). Returns None (the outer option) for every non-list type. This is the discriminator that tells a list (take_while’s result) from a fixed-length array: both look like width-N scalars structurally, but a list’s length is not statically known.

Trait Implementations§

Source§

impl Clone for Box<dyn Type>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§