mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
修复slice返回数字获取属性异常的问题
Signed-off-by: 杨云飞 <yangyunfei19@h-partners.com>
This commit is contained in:
parent
f4972d28c8
commit
8d9f113f58
@ -1121,6 +1121,20 @@ bool JSObject::OrdinaryGetOwnProperty(JSThread *thread, const JSHandle<JSObject>
|
||||
const JSHandle<JSTaggedValue> &key, PropertyDescriptor &desc)
|
||||
{
|
||||
ASSERT_PRINT(JSTaggedValue::IsPropertyKey(key), "Key is not a property key");
|
||||
JSHandle<JSTaggedValue> thisObjVal(obj);
|
||||
bool isArray = obj->IsJSArray();
|
||||
if (isArray) {
|
||||
JSHandle<TaggedArray> srcElements(thread, obj->GetElements());
|
||||
int64_t len = static_cast<int64_t>(srcElements->GetLength());
|
||||
for (int i = 0; i < len; i++) {
|
||||
JSTaggedValue value = srcElements->Get(thread, i);
|
||||
if (value.IsHole() && JSTaggedValue::HasProperty(thread, thisObjVal, i)) {
|
||||
value = JSArray::FastGetPropertyByValue(thread, thisObjVal, i).GetTaggedValue();
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false);
|
||||
srcElements->Set(thread, i, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
ObjectOperator op(thread, JSHandle<JSTaggedValue>(obj), key, OperatorType::OWN);
|
||||
|
||||
if (!op.IsFound()) {
|
||||
|
@ -1063,7 +1063,6 @@ JSTaggedValue JSStableArray::Slice(JSThread *thread, JSHandle<JSObject> thisObjH
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<TaggedArray> srcElements(thread, thisObjHandle->GetElements());
|
||||
JSHandle<JSTaggedValue> thisObjVal(thisObjHandle);
|
||||
int64_t len = static_cast<int64_t>(srcElements->GetLength());
|
||||
int64_t oldLen;
|
||||
if (len > k + count) {
|
||||
@ -1072,14 +1071,6 @@ JSTaggedValue JSStableArray::Slice(JSThread *thread, JSHandle<JSObject> thisObjH
|
||||
oldLen = len - k;
|
||||
}
|
||||
JSHandle<TaggedArray> dstElements = factory->NewAndCopyTaggedArray(srcElements, count, oldLen, k);
|
||||
for (int i = 0; i < count; i++) {
|
||||
JSTaggedValue value = dstElements->Get(thread, i);
|
||||
if (value.IsHole() && JSTaggedValue::HasProperty(thread, thisObjVal, i)) {
|
||||
value = JSArray::FastGetPropertyByValue(thread, thisObjVal, i).GetTaggedValue();
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
dstElements->Set(thread, i, value);
|
||||
}
|
||||
}
|
||||
return factory->NewJSStableArrayWithElements(dstElements).GetTaggedValue();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user