mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
style: 自动格式化
This commit is contained in:
@@ -7,9 +7,7 @@
|
||||
//! 原位安装(既有槽更新槽值、无槽新开)。
|
||||
|
||||
use crate::bind_constructor;
|
||||
use crate::bindings::{
|
||||
apply_binding_table, bind_well_known_data_property, configure_native_constructor, BindEnv,
|
||||
};
|
||||
use crate::bindings::{apply_binding_table, bind_well_known_data_property, configure_native_constructor, BindEnv};
|
||||
use oxide_kernel::shape_forge::EMPTY_SHAPE_ID;
|
||||
use oxide_types::object::{JsObject, PropAttributes};
|
||||
use oxide_types::value::JsValue;
|
||||
@@ -45,11 +43,7 @@ pub fn bind_shadow_realm(env: BindEnv<'_>, global: &mut JsObject) {
|
||||
let function_proto = world.function_proto.as_ptr() as *mut JsObject;
|
||||
let mut ctor = JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(function_proto));
|
||||
ctor.set_function(true);
|
||||
configure_native_constructor(
|
||||
&mut ctor,
|
||||
crate::shadow_realm::shadow_realm_constructor as *const (),
|
||||
0,
|
||||
);
|
||||
configure_native_constructor(&mut ctor, crate::shadow_realm::shadow_realm_constructor as *const (), 0);
|
||||
let ptr = Box::into_raw(Box::new(ctor));
|
||||
world.track_leaked_object(ptr);
|
||||
ptr
|
||||
@@ -130,27 +124,11 @@ pub fn bind_shadow_realm(env: BindEnv<'_>, global: &mut JsObject) {
|
||||
// evaluate / importValue 方法(not supported 桩,幂等守卫)。
|
||||
let si_evaluate = sf.intern("evaluate").0;
|
||||
if sh.lookup_position(proto.shape_id(), si_evaluate).is_none() {
|
||||
apply_binding_table(
|
||||
env,
|
||||
proto,
|
||||
&[(
|
||||
"evaluate",
|
||||
crate::shadow_realm::evaluate_stub as *const (),
|
||||
1,
|
||||
)],
|
||||
);
|
||||
apply_binding_table(env, proto, &[("evaluate", crate::shadow_realm::evaluate_stub as *const (), 1)]);
|
||||
}
|
||||
let si_import_value = sf.intern("importValue").0;
|
||||
if sh.lookup_position(proto.shape_id(), si_import_value).is_none() {
|
||||
apply_binding_table(
|
||||
env,
|
||||
proto,
|
||||
&[(
|
||||
"importValue",
|
||||
crate::shadow_realm::import_value_stub as *const (),
|
||||
2,
|
||||
)],
|
||||
);
|
||||
apply_binding_table(env, proto, &[("importValue", crate::shadow_realm::import_value_stub as *const (), 2)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ pub mod bind_object;
|
||||
pub mod bind_reflect;
|
||||
/// RegExp 构造器与原型的 native 方法绑定。
|
||||
pub mod bind_regexp;
|
||||
/// ShadowRealm 构造器绑定(Box 分配,不占 BuiltinWorld P 字段)。
|
||||
pub mod bind_shadow_realm;
|
||||
/// Set 构造器与原型的 native 方法绑定。
|
||||
pub mod bind_set;
|
||||
/// ShadowRealm 构造器绑定(Box 分配,不占 BuiltinWorld P 字段)。
|
||||
pub mod bind_shadow_realm;
|
||||
/// SharedArrayBuffer 构造器与原型的 native 方法绑定。
|
||||
pub mod bind_shared_array_buffer;
|
||||
/// String 构造器与原型的 native 方法绑定。
|
||||
|
||||
@@ -38,10 +38,7 @@ use crate::vm::Vm;
|
||||
pub(crate) fn shadow_realm_constructor(vm: &mut Vm, _args: &[u8]) -> NativeResult {
|
||||
// 构造形态校验(规范只有 [[Construct]])。
|
||||
if !vm.constructing_native {
|
||||
return NativeResult::Err(error::create_type_error(
|
||||
vm,
|
||||
"ShadowRealm constructor requires new",
|
||||
));
|
||||
return NativeResult::Err(error::create_type_error(vm, "ShadowRealm constructor requires new"));
|
||||
}
|
||||
|
||||
// 建影子 Vm:共享主 Vm 的 KernelCore 与动态编译服务。
|
||||
@@ -95,10 +92,7 @@ pub(crate) fn evaluate_stub(vm: &mut Vm, args: &[u8]) -> NativeResult {
|
||||
return NativeResult::Err(error::create_syntax_error(vm, &msg));
|
||||
}
|
||||
|
||||
NativeResult::Err(error::create_type_error(
|
||||
vm,
|
||||
"ShadowRealm.prototype.evaluate is not supported",
|
||||
))
|
||||
NativeResult::Err(error::create_type_error(vm, "ShadowRealm.prototype.evaluate is not supported"))
|
||||
}
|
||||
|
||||
/// `ShadowRealm.prototype.importValue` 桩:按规范前置步骤校验后抛 not supported。
|
||||
@@ -121,10 +115,7 @@ pub(crate) fn import_value_stub(vm: &mut Vm, args: &[u8]) -> NativeResult {
|
||||
// 入异常通道)。
|
||||
let specifier_val = if args.len() > 1 { vm.reg(args[1]) } else { JsValue::undefined() };
|
||||
if let Err(e) = oxide_runtime_api::to_string_full(specifier_val, vm) {
|
||||
let exc = vm
|
||||
.exception_value
|
||||
.take()
|
||||
.unwrap_or_else(|| error::create_from_text(vm, &e));
|
||||
let exc = vm.exception_value.take().unwrap_or_else(|| error::create_from_text(vm, &e));
|
||||
return NativeResult::Err(exc);
|
||||
}
|
||||
|
||||
@@ -137,19 +128,13 @@ pub(crate) fn import_value_stub(vm: &mut Vm, args: &[u8]) -> NativeResult {
|
||||
));
|
||||
}
|
||||
|
||||
NativeResult::Err(error::create_type_error(
|
||||
vm,
|
||||
"ShadowRealm.prototype.importValue is not supported",
|
||||
))
|
||||
NativeResult::Err(error::create_type_error(vm, "ShadowRealm.prototype.importValue is not supported"))
|
||||
}
|
||||
|
||||
/// brand 校验:`this` 须是对象且指针在主 Vm 侧表内(实例对象注册表)。
|
||||
fn shadow_realm_brand_check(vm: &mut Vm, this_val: JsValue) -> Result<(), JsValue> {
|
||||
if !this_val.is_object() {
|
||||
return Err(error::create_type_error(
|
||||
vm,
|
||||
"ShadowRealm method called on non-object",
|
||||
));
|
||||
return Err(error::create_type_error(vm, "ShadowRealm method called on non-object"));
|
||||
}
|
||||
let this_ptr = this_val.as_js_object_ptr();
|
||||
let in_table = vm
|
||||
|
||||
Reference in New Issue
Block a user