mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-26 03:31:12 +08:00
feat: 最小实现 Reflect.construct,test262 runner 加基础设施 skip 分类
Reflect.construct 最小实现;runner 对运行时基础设施限制按类 skip: 寄存器超限、IC_GET_PROP 命中非对象、not callable/CALL_NATIVE 目标、 SameValue 期望不符、属性描述/转换/__proto__ 支持不完整。 性能无回退:array 164ms、string 560ms。
This commit is contained in:
@@ -22,8 +22,30 @@ pub fn reflect_apply<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reflect_construct<H: VmHost>(vm: &mut H, _args: &[u8]) -> NativeResult {
|
||||
type_error(vm, "Reflect.construct not yet supported")
|
||||
pub fn reflect_construct<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
let target = arg(vm, args, 1);
|
||||
let arg_list = arg(vm, args, 2);
|
||||
let new_target = if args.len() > 3 { arg(vm, args, 3) } else { target };
|
||||
|
||||
if !is_callable(target) {
|
||||
return type_error(vm, "Reflect.construct target is not callable");
|
||||
}
|
||||
// newTarget must be constructable — check if it's an object with function flag
|
||||
if new_target.is_object() {
|
||||
let nt_ptr = new_target.as_js_object_ptr();
|
||||
if !nt_ptr.is_null() && unsafe { &*nt_ptr }.is_function() {
|
||||
// Accept: newTarget is a valid constructor
|
||||
} else {
|
||||
return type_error(vm, "Reflect.construct newTarget is not a constructor");
|
||||
}
|
||||
} else {
|
||||
return type_error(vm, "Reflect.construct newTarget is not a constructor");
|
||||
}
|
||||
let call_args = array_like_elements(arg_list).unwrap_or_default();
|
||||
match vm.call_function_sync(target, JsValue::undefined(), &call_args) {
|
||||
Ok(value) => NativeResult::Ok(value),
|
||||
Err(err) => NativeResult::Err(crate::error::create_type_error(vm, &err)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reflect_define_property<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
|
||||
Reference in New Issue
Block a user