Skip to main content

ObjectKind

Enum ObjectKind 

Source
pub enum ObjectKind {
    Ordinary,
    Array {
        elements: Vec<Value>,
    },
    Function(Callable),
    RegExp(RegExpData),
    DisposableStack(StackState),
    ArrayBuffer(Rc<RefCell<BufferStorage>>),
    Collection {
        entries: Vec<(Value, Value)>,
        is_set: bool,
    },
    TypedArray {
        buffer: Gc<JsObject>,
        element: ElementType,
        offset: usize,
        length: usize,
    },
    Generator(Box<GeneratorState>),
    Proxy(ProxyRef),
    Promise(PromiseRef),
}
Expand description

What kind of object this is.

Variants§

§

Ordinary

An ordinary object: only its property table.

§

Array

An array: dense elements plus a property table for everything else.

Fields

§elements: Vec<Value>

The dense prefix of the array.

§

Function(Callable)

A function or a class constructor.

§

RegExp(RegExpData)

A regular expression: the compiled pattern, plus lastIndex as a property.

§

DisposableStack(StackState)

A DisposableStack or AsyncDisposableStack: the resources it holds.

§

ArrayBuffer(Rc<RefCell<BufferStorage>>)

An ArrayBuffer: a byte range that typed-array views share.

The bytes sit behind an Rc<RefCell<…>> rather than in the object so that every view of the buffer sees the same storage; the views hold the Gc<JsObject> of this buffer, which is what keeps it alive and what the collector traces.

§

Collection

A Map or a Set: insertion-ordered entries with SameValueZero key equality.

One variant for both, because a Set is exactly a Map whose value is unused — the difference is a flag, and is_set is what makes entries yield [v, v] pairs.

Fields

§entries: Vec<(Value, Value)>

The entries, in insertion order.

§is_set: bool

Whether this is a Set rather than a Map.

§

TypedArray

A typed-array view: a window onto an ArrayBuffer.

Fields

§buffer: Gc<JsObject>

The buffer whose bytes this view reads.

§element: ElementType

What one element is.

§offset: usize

Byte offset of element zero.

§length: usize

How many elements the view exposes.

§

Generator(Box<GeneratorState>)

A generator object: a detached frame plus how far it got.

The frame lives here rather than in the interpreter because a suspended generator has to keep its locals and operand stack alive for as long as the script can reach the generator object — and the collector has to see them, which it only does for things hanging off a Gc.

§

Proxy(ProxyRef)

A Proxy: a stand-in that forwards every internal method to a target through a handler’s traps.

The state sits behind an Rc because Proxy.revocable hands the script a revoke function that has to reach this proxy’s two slots later, from a call site that has no pointer to the object. Revoking clears them, which also drops the collector’s references to the target and the handler.

§

Promise(PromiseRef)

A Promise.

The state sits behind an Rc for the same reason a proxy’s slots do: the resolve/reject pair handed to an executor has to settle this promise later, and those are function objects with no pointer back to it otherwise.

Trait Implementations§

Source§

impl Trace for ObjectKind

Source§

fn trace(&self, tracer: &mut Tracer<'_>)

Report every Gc owned by self to tracer.

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.