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.
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
TypedArray
A typed-array view: a window onto an ArrayBuffer.
Fields
element: ElementTypeWhat one element is.
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.