fix: 迭代器原型形状补全(Iterator.prototype/string 中继层/next 原型化)
This commit is contained in:
@@ -5,7 +5,10 @@ use oxide_kernel::shape_forge::EMPTY_SHAPE_ID;
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
use crate::bindings::{apply_binding_table, bind_global_value, configure_native_constructor};
|
||||
use crate::bindings::{
|
||||
apply_binding_table, bind_global_value, bind_iterator_function_prototype, bind_iterator_proto_next,
|
||||
configure_native_constructor,
|
||||
};
|
||||
|
||||
/// 绑定迭代器基础设施:`%IteratorPrototype%` 与 `%ArrayIteratorPrototype%` 等。
|
||||
pub fn bind_iterator(core: &Arc<KernelCore>, session: &KernelSession, global: &mut JsObject) {
|
||||
@@ -17,6 +20,7 @@ pub fn bind_iterator(core: &Arc<KernelCore>, session: &KernelSession, global: &m
|
||||
oxide_builtins::iterator::iterator_constructor::<crate::vm::Vm> as *const (),
|
||||
0,
|
||||
);
|
||||
bind_iterator_function_prototype(core, session, &mut iterator);
|
||||
|
||||
apply_binding_table(
|
||||
session.builtin_world(),
|
||||
@@ -40,4 +44,32 @@ pub fn bind_iterator(core: &Arc<KernelCore>, session: &KernelSession, global: &m
|
||||
oxide_builtins::iterator::iterator_symbol_iterator::<crate::vm::Vm> as *const (),
|
||||
0,
|
||||
);
|
||||
|
||||
// 集合迭代器原型各自安装 next(%ArrayIteratorPrototype% 服务 Array/TA 两族;
|
||||
// Map/Set 共用按 `__mode__` 分发的实现;%RegExpStringIteratorPrototype% 供 matchAll)。
|
||||
let world = session.builtin_world();
|
||||
bind_iterator_proto_next(
|
||||
core,
|
||||
session,
|
||||
world.array_iterator_proto.as_ptr() as *mut JsObject,
|
||||
oxide_builtins::array::array_iterator_next::<crate::vm::Vm> as *const (),
|
||||
);
|
||||
bind_iterator_proto_next(
|
||||
core,
|
||||
session,
|
||||
world.map_iterator_proto.as_ptr() as *mut JsObject,
|
||||
oxide_builtins::iterator::map_set_iterator_next::<crate::vm::Vm> as *const (),
|
||||
);
|
||||
bind_iterator_proto_next(
|
||||
core,
|
||||
session,
|
||||
world.set_iterator_proto.as_ptr() as *mut JsObject,
|
||||
oxide_builtins::iterator::map_set_iterator_next::<crate::vm::Vm> as *const (),
|
||||
);
|
||||
bind_iterator_proto_next(
|
||||
core,
|
||||
session,
|
||||
world.regexp_string_iterator_proto.as_ptr() as *mut JsObject,
|
||||
oxide_builtins::string::string_match_all_next::<crate::vm::Vm> as *const (),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user