feat: 补全 Object.prototype 方法族与 toString 标签

This commit is contained in:
2026-09-21 03:30:25 +00:00
parent 7481ceb798
commit d93215c83b
8 changed files with 397 additions and 91 deletions
+6 -4
View File
@@ -748,9 +748,10 @@ pub(crate) fn init_async_generator_intrinsics(vm: &mut Vm) {
("return", async_generator_return as *const (), 1),
("throw", async_generator_throw as *const (), 1),
);
// @@toStringTag(Object.prototype.toString → "[object AsyncGenerator]")。
let tag_si = sf.intern("@@toStringTag").0;
let tag_shape = sh.make_shape(ag_proto.shape_id(), tag_si);
// Symbol.toStringTag(Object.prototype.toString → "[object AsyncGenerator]")。
let tag_key =
oxide_types::private_key::make_well_known_symbol_key(oxide_types::private_key::WELL_KNOWN_SYMBOL_TO_STRING_TAG);
let tag_shape = sh.make_shape(ag_proto.shape_id(), tag_key);
ag_proto.set_shape_id(tag_shape);
let tag_pos = ag_proto.push_prop(JsValue::perm_string(sf.string_ptr(sf.intern("AsyncGenerator").0)));
ag_proto.set_data_meta(tag_pos, PropAttributes::new(false, false, true));
@@ -811,7 +812,8 @@ pub(crate) fn init_async_generator_intrinsics(vm: &mut Vm) {
let ppos2 = agf_proto.push_prop(JsValue::from_js_object(vm.async_generator_proto.as_ptr() as *mut JsObject));
agf_proto.set_data_meta(ppos2, PropAttributes::new(false, false, false));
// agf_proto[Symbol.toStringTag] = "AsyncGeneratorFunction"(数据属性,w/e/c = false/false/true)。
let tag2_key = oxide_types::private_key::make_well_known_symbol_key(0);
let tag2_key =
oxide_types::private_key::make_well_known_symbol_key(oxide_types::private_key::WELL_KNOWN_SYMBOL_TO_STRING_TAG);
let tag2_shape = sh.make_shape(agf_proto.shape_id(), tag2_key);
agf_proto.set_shape_id(tag2_shape);
let tag2_pos = agf_proto.push_prop(JsValue::perm_string(sf.string_ptr(sf.intern("AsyncGeneratorFunction").0)));