Skip to main content

Obj

Struct Obj 

Source
pub struct Obj {
    pub holes: Option<Box<Vec<bool>>>,
    pub gc_slot: u32,
    pub props: PropMap<Value>,
    pub accessors: LazyPropMap<Accessor>,
    pub attrs: LazyPropMap<PropertyAttributes>,
    pub proto: Option<ObjRef>,
    pub kind: ObjKind,
    pub frozen: bool,
    pub sealed: bool,
    pub non_extensible: bool,
    pub null_proto: bool,
}
Expand description

ヒープオブジェクト本体。名前付きプロパティ + プロトタイプ + 種別。

Fields§

§holes: Option<Box<Vec<bool>>>

配列の穴(Array(n) 等で作られ、まだ書かれていない要素)の印。 印があり、かつ値が undefined の要素だけを穴とみなす(書き込めば自然に穴でなくなる)。 添字をずらす操作(shift/unshift/splice/sort/reverse)では捨てる。 【2026-10-19】YouTube の kevlar_base が同梱する D3 の配色表 Array(3).concat("…").map(DE) で、穴の 3 要素にも DE(undefined) を呼んで落ちていた。

§gc_slot: u32

循環ゴミ回収(cycle_gc)の台帳の番号(未登録は NO_GC_SLOT)。

§props: PropMap<Value>§accessors: LazyPropMap<Accessor>

Object.defineProperty で登録された getter/setter。

§attrs: LazyPropMap<PropertyAttributes>§proto: Option<ObjRef>§kind: ObjKind§frozen: bool

Object.freeze() 済みか。真なら set_property/delete によるプロパティの 追加・変更・削除を無視する(非 strict モード相当の黙殺。Object.isFrozen() が読む)。

§sealed: bool

Object.seal() 済みか。真なら新規プロパティの追加・既存プロパティの削除を無視する (既存プロパティの値の変更は許可。frozen はこれも自動的に含意する)。

§non_extensible: bool

Object.preventExtensions() 済みか。真なら新規プロパティの追加のみを禁止する (削除・既存値の変更は許可。sealed/frozen はこれも自動的に含意する)。

§null_proto: bool

Object.create(null)/Object.groupBy()等、仕様上[[Prototype]]が nullと明示されたオブジェクトか。proto: Noneだけでは「明示的に nullプロトタイプ」なのか「単に通常オブジェクトでprotoチェーンが 尽きた」なのかをget_propertyの共通メソッドフォールバック (interp/properties.rsのobject_get呼び出し)が区別できず、 Object.create(null).hasOwnProperty等がフォールバック経由で 誤って動いてしまうバグがあった(2026-07-18 発見・実装)。

Implementations§

Source§

impl Obj

Source

pub fn plain() -> ObjRef

Source

pub fn bytes(store: ByteStore) -> ObjRef

Source

pub fn is_hole(&self, i: usize) -> bool

配列の i 番目が穴か。

Source

pub fn hole_mask(&self) -> Vec<bool>

配列の穴の一覧(len 要素。穴が無ければ空)。

Source

pub fn array(items: Vec<Value>) -> ObjRef

Source

pub fn function(data: FunctionData) -> ObjRef

Source

pub fn native(name: &str, func: NativeFn) -> ObjRef

Source

pub fn host(tag: &str) -> ObjRef

Source

pub fn dom(node_idx: usize) -> ObjRef

Source

pub fn map_obj(entries: Vec<(Value, Value)>) -> ObjRef

Source

pub fn set_obj(items: Vec<Value>) -> ObjRef

Source

pub fn promise(state: Rc<RefCell<PromiseState>>) -> ObjRef

Source

pub fn resolver(state: Rc<RefCell<PromiseState>>, reject: bool) -> ObjRef

Source

pub fn generator(state: GenState) -> ObjRef

Source

pub fn regexp(data: RegExpData) -> ObjRef

Source

pub fn proxy(target: ObjRef, handler: ObjRef) -> ObjRef

Source

pub fn date_obj(epoch_ms: f64) -> ObjRef

Source

pub fn bound(target: Value, bound_this: Value, bound_args: Vec<Value>) -> ObjRef

Source

pub fn clear_references(&mut self)

Source

pub fn is_callable(&self) -> bool

Trait Implementations§

Source§

impl Drop for Obj

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Obj

§

impl !Send for Obj

§

impl !Sync for Obj

§

impl !UnwindSafe for Obj

§

impl Freeze for Obj

§

impl Unpin for Obj

§

impl UnsafeUnpin for Obj

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> Same for T

Source§

type Output = T

Should always be Self
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.