style: 自动格式化

This commit is contained in:
2026-10-17 07:53:31 +00:00
parent e5db10581e
commit 2c8ad6c772
3 changed files with 6 additions and 21 deletions
+1 -4
View File
@@ -82,10 +82,7 @@ fn proxy_create_invariants<H: VmHost>(
) -> Result<(), JsValue> { ) -> Result<(), JsValue> {
// target 可调用且不可扩展:函数代理的不变量无法满足,抛 TypeError。 // target 可调用且不可扩展:函数代理的不变量无法满足,抛 TypeError。
if crate::iterator::is_callable(target) && !target_obj.is_extensible() { if crate::iterator::is_callable(target) && !target_obj.is_extensible() {
return Err(crate::error::create_type_error( return Err(crate::error::create_type_error(vm, "Proxy target must be extensible if it is callable"));
vm,
"Proxy target must be extensible if it is callable",
));
} }
// isExtensible trap:handler 报 true 时 target 须可扩展,报 false 时须不可扩展。 // isExtensible trap:handler 报 true 时 target 须可扩展,报 false 时须不可扩展。
let si_is_extensible = vm.perm_intern("isExtensible"); let si_is_extensible = vm.perm_intern("isExtensible");
+4 -11
View File
@@ -85,16 +85,10 @@ pub(crate) fn call_trap(
// trap 值须可调用(规范 Call 语义):非可调用抛 TypeError 而非落入 // trap 值须可调用(规范 Call 语义):非可调用抛 TypeError 而非落入
// call_function_sync 的通用「accessor is not callable」文本(kind 丢失)。 // call_function_sync 的通用「accessor is not callable」文本(kind 丢失)。
if !trap_val.is_object() { if !trap_val.is_object() {
return Err(oxide_runtime_api::format_error_message( return Err(oxide_runtime_api::format_error_message("TypeError", "Proxy trap is not callable"));
"TypeError",
"Proxy trap is not callable",
));
} }
if !unsafe { &*trap_val.as_js_object_ptr() }.is_function() { if !unsafe { &*trap_val.as_js_object_ptr() }.is_function() {
return Err(oxide_runtime_api::format_error_message( return Err(oxide_runtime_api::format_error_message("TypeError", "Proxy trap is not callable"));
"TypeError",
"Proxy trap is not callable",
));
} }
let result = vm.call_function_sync(trap_val, handler, args)?; let result = vm.call_function_sync(trap_val, handler, args)?;
Ok(Some(result)) Ok(Some(result))
@@ -407,9 +401,8 @@ mod tests {
let target = native_fn_obj(&mut vm, target_return_7); let target = native_fn_obj(&mut vm, target_return_7);
let handler = vm.alloc_object(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::undefined())); let handler = vm.alloc_object(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::undefined()));
let proxy = proxy_with_state(&mut vm, JsValue::from_js_object(target), JsValue::from_js_object(handler)); let proxy = proxy_with_state(&mut vm, JsValue::from_js_object(target), JsValue::from_js_object(handler));
let result = let result = proxy_apply_call(&mut vm, unsafe { &*proxy }, JsValue::undefined(), &[JsValue::int(1)])
proxy_apply_call(&mut vm, unsafe { &*proxy }, JsValue::undefined(), &[JsValue::int(1)]) .expect("落穿 target 应成功");
.expect("落穿 target 应成功");
assert_eq!(result, JsValue::int(7), "target 调用结果须原样返回"); assert_eq!(result, JsValue::int(7), "target 调用结果须原样返回");
} }
+1 -6
View File
@@ -110,12 +110,7 @@ impl Vm {
/// - `ctor_obj` 为待分派的构造器(native / 字节码臂);`new_target` 为 /// - `ctor_obj` 为待分派的构造器(native / 字节码臂);`new_target` 为
/// newTarget(原型读源与 new.target 槽),非代理路径两者恒同一值。 /// newTarget(原型读源与 new.target 槽),非代理路径两者恒同一值。
pub(crate) fn dispatch_new_target( pub(crate) fn dispatch_new_target(
&mut self, &mut self, ctor_obj: &JsObject, constructor: JsValue, new_target: JsValue, rd: usize, args: &[JsValue],
ctor_obj: &JsObject,
constructor: JsValue,
new_target: JsValue,
rd: usize,
args: &[JsValue],
call_window: u8, call_window: u8,
) -> Result<bool, String> { ) -> Result<bool, String> {
// Proxy [[Construct]]:construct trap 权威(target, argumentsList, // Proxy [[Construct]]:construct trap 权威(target, argumentsList,