Skip to main content

ObjectData

Struct ObjectData 

Source
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 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: ObjectKind

What kind of object this is.

§extensible: bool

Whether new properties may be added. Object.preventExtensions, seal and freeze clear it, and nothing clears it back.

§elements_writable: bool

Whether 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: bool

Whether 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.

§class_constructor: bool

Whether this function is a class constructor, which may not be called without new.

§constructible: bool

Whether 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).

Trait Implementations§

Source§

impl Trace for ObjectData

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.