Skip to main content

Repr

Enum Repr 

Source
pub enum Repr {
    Unit,
    Bool,
    Int,
    Float,
    Duration,
    Ref,
    Addr,
    Host,
    Task,
    Scope,
    Tag,
}
Expand description

The interpretation of one word.

The collector consults exactly one thing about a Repr: whether it is Repr::Ref. Everything else is for the boundary, the verifier and the printer, all of which run outside the dispatch loop.

Variants§

§

Unit

Nothing. The word is zero.

Unit is a value in Cove — fn f() {} answers one — so it takes a slot rather than being absent, which keeps the slot numbering and the calling convention free of a special case.

§

Bool

0 or 1.

§

Int

A two’s-complement i64.

§

Float

An IEEE-754 double, bit-cast into the word.

Bit-cast rather than converted: f64::to_bits round-trips every value including the NaN payloads, and the word is never read as an integer by anything that did not write it as one.

§

Duration

Nanoseconds, as an i64.

A separate Repr from Repr::Int although the bits are the same, because the boundary has to know which one to materialise and asking the slot is cheaper than carrying a second table.

§

Ref

The linear address of a heap object’s header, or 0 for none.

This is the only Repr the collector treats as a root. Heap addresses start at STACK_WORDS, so 0 can never name an object and is free to mean null — which is what a frame full of zeroes gives a Ref slot that has not been written yet.

§

Addr

The linear address of one mutable word: a place.

Not a root. The object an interior address points into is kept alive by the Ref slot the lowering holds it in, and the heap does not move, so the address stays correct across a collection without the collector knowing it exists.

§

Host

An index into the run’s host resource table.

A host resource is owned by the host, not by Cove, so it is not an object in the heap and not a root. The word names it; the host owns its lifetime.

§

Task

A task handle: one past an index into the task’s scheduler table, or 0 for none.

Not a root, and for the same reason Repr::Host is not: what the word names is not storage this collector allocated. A task is a thread, a cancellation flag and a place to put an answer, and none of those is a Cove value. The answer is an object in the run’s heap, and the table names its address — which makes the table a provider of roots rather than a second place to keep a value, because nothing a program can write down could be put in one.

One past the index, so that a slot a zeroed frame has not written names no task. That is Repr::Host’s rule, kept because the reason for it is the same one.

§

Scope

A task scope: one past an index into the task’s scheduler table, or 0 for none.

The other half of what Repr::Task names, under the same rules. A scope owns the tasks spawned into it, which is what lets leaving one wait for or cancel them, and it holds nothing else.

Neither of these two crosses a task boundary — the task-safety rule says so — so the table they index is the task’s own and never a second task’s. Two tasks cannot form one another’s handles, which is the same disjointness by construction that keeps two stack segments apart.

§

Tag

An enum’s case index: which case an enum value holds.

Physically an integer word and semantically not an integer. It is produced by Inst::Tag, consumed by Inst::Switch, copied and cleared like any other word, and refused by arithmetic, ordering and integer equality — which is the whole of why it is a Repr of its own rather than Repr::Int with a comment.

Implementations§

Source§

impl Repr

Source

pub fn is_ref(self) -> bool

Whether a word of this Repr is a garbage-collection root.

This is the whole of what the collector asks the static side.

Source

pub fn name(self) -> &'static str

The name this Repr prints under in a disassembly.

Trait Implementations§

Source§

impl Clone for Repr

Source§

fn clone(&self) -> Repr

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
Source§

impl Copy for Repr

Source§

impl Debug for Repr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Repr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Repr

Source§

impl Hash for Repr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Repr

Source§

fn eq(&self, other: &Repr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Repr

Auto Trait Implementations§

§

impl Freeze for Repr

§

impl RefUnwindSafe for Repr

§

impl Send for Repr

§

impl Sync for Repr

§

impl Unpin for Repr

§

impl UnsafeUnpin for Repr

§

impl UnwindSafe for Repr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.