fix: 绑定 Function 和 Object prototype harness helper

This commit is contained in:
爱特每羊队
2026-06-09 19:31:46 +08:00
parent 3987d39db9
commit e588fa4c8c
7 changed files with 103 additions and 7 deletions
@@ -2,8 +2,12 @@ use std::sync::Arc;
use oxide_kernel::builtin::FunctionMethods;
use oxide_kernel::kernel::OxideKernel;
use oxide_types::object::JsObject;
use oxide_types::value::JsValue;
pub fn bind_function(kernel: &Arc<OxideKernel>) {
use super::bind_global_value;
pub fn bind_function(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
let function_methods = FunctionMethods {
call: crate::builtins::function::function_call as *const (),
apply: crate::builtins::function::function_apply as *const (),
@@ -15,4 +19,7 @@ pub fn bind_function(kernel: &Arc<OxideKernel>) {
kernel.string_forge().as_ref(),
kernel.shape_forge().as_ref(),
);
let function_ctor = kernel.builtin_world().function_constructor.as_ptr() as *mut JsObject;
bind_global_value(kernel, global, "Function", JsValue::from_js_object(function_ctor));
}
@@ -26,6 +26,8 @@ pub fn bind_object(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
has_own: crate::builtins::object::object_has_own as *const (),
entries: crate::builtins::object::object_entries as *const (),
values: crate::builtins::object::object_values as *const (),
has_own_property: crate::builtins::object::object_proto_has_own_property as *const (),
property_is_enumerable: crate::builtins::object::object_proto_property_is_enumerable as *const (),
};
kernel
.builtin_world()
+1 -1
View File
@@ -87,7 +87,7 @@ pub fn init_kernel_builtins(kernel: &Arc<OxideKernel>) {
bind_set::bind_set(kernel, global);
bind_map::bind_map(kernel, global);
bind_boolean::bind_boolean(kernel, global);
bind_function::bind_function(kernel);
bind_function::bind_function(kernel, global);
bind_regexp::bind_regexp(kernel, global);
bind_symbol::bind_symbol(kernel, global);