mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 10:41:11 +08:00
feat: TA 定义自身属性数值索引臂与原型链门口径
This commit is contained in:
@@ -216,10 +216,10 @@ impl Vm {
|
||||
/// 属性即存在。数组 length 虚拟属性恒存在;数组元素区 hole 视同缺失;
|
||||
/// 其余按 shape 槽判定。
|
||||
///
|
||||
/// 顶层 TypedArray 经统一数值键门(exotic [[HasProperty]]):界内整数索引
|
||||
/// TypedArray 经统一数值键门(exotic [[HasProperty]]):界内整数索引
|
||||
/// 判存在;数字无效键(负/分数/±Infinity/NaN/越界,含 "-0" 特例)立即
|
||||
/// false,不查自身命名属性也不走原型链;非规范数字串落普通路径。原型链上
|
||||
/// 的 TA 按普通对象查 shape 槽。
|
||||
/// false,不查自身命名属性也不走原型链;非规范数字串落普通路径。原型链
|
||||
/// 上的 TA 按同口径经门判定。
|
||||
///
|
||||
/// 与 `resolve_property` 的差异:原型链上每层都检查数组元素区
|
||||
/// (`resolve_property` 只在顶层检查元素区,链上仅走 shape 槽),
|
||||
@@ -233,8 +233,8 @@ impl Vm {
|
||||
return true;
|
||||
}
|
||||
// 统一数值键门(exotic [[HasProperty]]):同 `ordinary_get_inner`
|
||||
// 的口径,门只落在顶层对象。
|
||||
if obj.is_typed_array_obj() && depth == 0 {
|
||||
// 的口径,链上每层同口径判定。
|
||||
if obj.is_typed_array_obj() {
|
||||
match oxide_builtins::typed_array::ta_index_gate(self, obj, prop_name_si) {
|
||||
oxide_builtins::typed_array::TaIndexGate::NumericValid(_) => return true,
|
||||
oxide_builtins::typed_array::TaIndexGate::NumericInvalid => return false,
|
||||
|
||||
@@ -61,6 +61,12 @@ impl oxide_runtime_api::VmHost for Vm {
|
||||
fn take_pending_length_exception(&mut self) -> Option<JsValue> {
|
||||
self.pending_length_exception.take()
|
||||
}
|
||||
fn clear_uncaught_value(&mut self) {
|
||||
self.last_uncaught_value = None;
|
||||
}
|
||||
fn move_uncaught_to_pending_length(&mut self) {
|
||||
self.pending_length_exception = self.last_uncaught_value.take();
|
||||
}
|
||||
fn property_key_si(&mut self, val: JsValue) -> u32 {
|
||||
// 对象键转换(to_string_full)失败时降级为空键:本 trait 路径供
|
||||
// Reflect/Object 内置使用,这些内置按规范不传播键转换异常;计算属性
|
||||
|
||||
@@ -103,8 +103,8 @@ impl Vm {
|
||||
// 统一数值键门(exotic [[Get]]):界内整数读底层 buffer;数字无效
|
||||
// 键(负/分数/±Infinity/NaN/越界,含 "-0" 特例)立即 undefined 不
|
||||
// 查自身命名属性也不走原型链;非规范数字串落下方普通属性路径。
|
||||
// 门只落在顶层对象:原型链上的 TA 维持普通 shape 槽查找。
|
||||
if obj.is_typed_array_obj() && depth == 0 {
|
||||
// 链上每层同口径:原型链上的 TA 亦按 exotic 语义判定。
|
||||
if obj.is_typed_array_obj() {
|
||||
match oxide_builtins::typed_array::ta_index_gate(self, obj, prop_name_si) {
|
||||
oxide_builtins::typed_array::TaIndexGate::NumericValid(index) => {
|
||||
return oxide_builtins::typed_array::typed_array_element_get(self, obj, index);
|
||||
@@ -1105,6 +1105,17 @@ impl Vm {
|
||||
let target_ptr = obj as *mut JsObject;
|
||||
let get = self.promote_if_needed_for_write_ptr(target_ptr, get);
|
||||
let set = self.promote_if_needed_for_write_ptr(target_ptr, set);
|
||||
// TA 数值索引臂:界内 / 数字无效索引不接受 accessor(false);非规范数字
|
||||
// 串 / symbol 键落真实 accessor 属性。
|
||||
if obj.is_typed_array_obj() {
|
||||
match oxide_builtins::typed_array::ta_index_gate(self, obj, prop_name_si) {
|
||||
oxide_builtins::typed_array::TaIndexGate::NumericValid(_)
|
||||
| oxide_builtins::typed_array::TaIndexGate::NumericInvalid => {
|
||||
return Err("cannot define property: TypedArray index only accepts a data descriptor".to_string());
|
||||
}
|
||||
oxide_builtins::typed_array::TaIndexGate::Ordinary => {}
|
||||
}
|
||||
}
|
||||
if obj.is_array() {
|
||||
if let Some(index) = self.array_index_from_property_key(prop_name_si) {
|
||||
return self.define_array_index_element(obj, index, JsValue::undefined(), attributes, true, get, set);
|
||||
|
||||
Reference in New Issue
Block a user