pub struct ObjectData {
pub proto: Option<Gc<JsObject>>,
pub props: Vec<(PropertyKey, Property)>,
pub kind: ObjectKind,
pub extensible: bool,
pub elements_writable: bool,
pub length_writable: bool,
pub home_object: Option<Gc<JsObject>>,
pub private_brand: Option<Gc<JsSymbol>>,
pub brands: Vec<Gc<JsSymbol>>,
pub class_constructor: bool,
pub constructible: bool,
}Expand description
An object’s mutable state: its prototype, property table and internal slots.
Fields§
§proto: Option<Gc<JsObject>>The prototype, or None for Object.prototype and for a null-prototype
object created with Object.create(null).
props: Vec<(PropertyKey, Property)>Properties in definition order, string and symbol keys interleaved.
kind: ObjectKindWhat kind of object this is.
extensible: boolWhether new properties may be added. Object.preventExtensions, seal and
freeze clear it, and nothing clears it back.
elements_writable: boolWhether array elements may be replaced.
Elements are not in the property table, so their attributes need somewhere to
live; Object.freeze clears this and Object.isFrozen reads it. A single
non-writable element is recorded in the property table instead, which is what
Object.defineProperty(a, "3", {configurable: false}) does.
length_writable: boolWhether an array’s length may be changed.
Object.defineProperty(a, "length", {writable: false}) makes it read-only without
touching the elements, so it cannot share elements_writable: the two mean
different things and Object.freeze sets both.
home_object: Option<Gc<JsObject>>The object a method was defined on, which is what super resolves against.
Kept here rather than as a property because it is not observable: the spec calls
it [[HomeObject]] and no script can read it, so putting it in the property
table would leak it to Object.getOwnPropertyNames and JSON.stringify.
private_brand: Option<Gc<JsSymbol>>The brand symbol this object owns, when it is the home object of a class.
The reference keeps two separate things under private names it never exposes. The
first is [[PrivateBrand]]: one symbol per class, stored on the home object — the
prototype for the instance brand, the constructor for the static one. Creating it the
first time and reusing it after is what ties a prototype, its instances and the class
itself to one identity.
Kept off the property table for the same reason as home_object: a property would be
reachable from Object.getOwnPropertyNames.
brands: Vec<Gc<JsSymbol>>The brand symbols this object carries, as an instance of one or more classes.
A list rather than one symbol because brands accumulate down an inheritance chain:
class D extends C with a private method in each means a D instance carries both,
since C’s field initialiser runs on it and so does D’s. Membership is what
check_brand — and so #m() and #a — tests before it runs.
class_constructor: boolWhether this function is a class constructor, which may not be called without
new.
constructible: boolWhether this function has a [[Construct]], i.e. may appear as the target of
new or Reflect.construct.
Not derivable from being callable, and that is the whole point: an ordinary
method, an arrow function, a generator, an async function and most built-in
methods are all callable and none of them may be constructed (§10.2.1,
§15.3.1). Deriving it from is_callable made new (Array.prototype.map) succeed,
which test262 checks for every built-in (not-a-constructor.js, 515 files).