refactor: 重写 abstract_eq 为 ES §7.2.15 11 步算法

This commit is contained in:
2026-06-27 13:23:35 +08:00
parent f23d75a63e
commit 27b7e8ad29
5 changed files with 136 additions and 56 deletions
+25 -1
View File
@@ -2,9 +2,10 @@ use std::sync::Arc;
use oxide_kernel::builtin::ObjectMethods;
use oxide_kernel::kernel::{KernelCore, KernelSession};
use oxide_types::object::JsObject;
use oxide_types::object::{JsObject, PropAttributes};
use crate::bind_constructor;
use crate::bindings::apply_binding_table;
pub fn bind_object(core: &Arc<KernelCore>, session: &KernelSession, global: &mut JsObject) {
let methods = ObjectMethods {
@@ -36,6 +37,29 @@ pub fn bind_object(core: &Arc<KernelCore>, session: &KernelSession, global: &mut
.builtin_world()
.bind_object_methods(&methods, core.perm_interner().as_ref(), core.shape_forge().as_ref());
let object_proto_ptr = session.builtin_world().object_proto.as_ptr() as *mut JsObject;
let object_proto = unsafe { &mut *object_proto_ptr };
apply_binding_table(
session.builtin_world(),
object_proto,
core,
&[
(
"toString",
oxide_builtins::object::object_proto_to_string::<crate::vm::Vm> as *const (),
0,
),
("valueOf", oxide_builtins::object::object_proto_value_of::<crate::vm::Vm> as *const (), 0),
],
);
// Built-in prototype methods are non-enumerable (otherwise they leak into for-in).
for name in ["toString", "valueOf"] {
let si = core.perm_interner().intern(name).0;
if let Some(pos) = core.shape_forge().lookup_position(object_proto.shape_id(), si) {
object_proto.set_data_meta(pos, PropAttributes::new(true, false, true));
}
}
let ctor_ptr = session.builtin_world().object_constructor.as_ptr() as *mut JsObject;
bind_constructor!(
core,