mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 11:11:11 +08:00
fix: 原型链直读改经 get_prototype_of 路由
This commit is contained in:
@@ -191,6 +191,11 @@ impl Vm {
|
||||
while proto.is_object() && depth < MAX_PROTO_CHAIN_DEPTH {
|
||||
depth += 1;
|
||||
let proto_obj = unsafe { &*proto.as_js_object_ptr() };
|
||||
// 链上代理层:不可变签名无法同步调 get trap,保守返 None,
|
||||
// 与顶层代理口径一致(权威路径由可变签名入口承载)。
|
||||
if proto_obj.is_proxy_obj() {
|
||||
return None;
|
||||
}
|
||||
if let Some(pos) = self
|
||||
.kernel_core
|
||||
.shape_forge()
|
||||
@@ -300,7 +305,9 @@ impl Vm {
|
||||
break;
|
||||
}
|
||||
depth += 1;
|
||||
let proto = obj.proto();
|
||||
// 链上续层经 [[GetPrototypeOf]] 路由:代理层经 trap 取原型,
|
||||
// 取到的代理层在下一轮循环经入口守卫路由 has trap。
|
||||
let proto = self.get_prototype_of(obj)?;
|
||||
current = proto.is_object().then(|| unsafe { &*proto.as_js_object_ptr() });
|
||||
}
|
||||
Ok(false)
|
||||
|
||||
@@ -571,20 +571,21 @@ impl oxide_runtime_api::VmHost for Vm {
|
||||
// 按严格处理(受限访问器对其抛错)。
|
||||
self.callee_module(obj).map(|m| m.is_strict).unwrap_or(true)
|
||||
}
|
||||
fn function_is_restricted(&self, obj: &JsObject) -> bool {
|
||||
fn function_is_restricted(&mut self, obj: &JsObject) -> Result<bool, String> {
|
||||
// 严格函数对象,或 [[Prototype]] 为三个动态函数原型之一(生成器 /
|
||||
// 异步 / 异步生成器函数):caller/arguments 访问一律受限。
|
||||
// 异步 / 异步生成器函数):caller/arguments 访问一律受限。原型经
|
||||
// [[GetPrototypeOf]] 路由取(代理函数对象经 getPrototypeOf trap)。
|
||||
if self.function_is_strict(obj) {
|
||||
return true;
|
||||
return Ok(true);
|
||||
}
|
||||
let proto = obj.proto();
|
||||
let proto = self.get_prototype_of(obj)?;
|
||||
if !proto.is_object() {
|
||||
return false;
|
||||
return Ok(false);
|
||||
}
|
||||
let p = proto.as_js_object_ptr() as *const JsObject;
|
||||
std::ptr::eq(p, self.realm.generator_function_proto.borrow().as_ptr())
|
||||
Ok(std::ptr::eq(p, self.realm.generator_function_proto.borrow().as_ptr())
|
||||
|| std::ptr::eq(p, self.realm.async_function_proto.borrow().as_ptr())
|
||||
|| std::ptr::eq(p, self.realm.async_generator_function_proto.borrow().as_ptr())
|
||||
|| std::ptr::eq(p, self.realm.async_generator_function_proto.borrow().as_ptr()))
|
||||
}
|
||||
fn step_rng(&mut self) {
|
||||
self.step_rng()
|
||||
|
||||
Reference in New Issue
Block a user