Update TypedArray internals methods (#4653)
releated test262 test-cases has been removed from the skip list. JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "jcontext.h"
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
@@ -138,18 +139,28 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
|
||||
{
|
||||
break;
|
||||
}
|
||||
ecma_number_t num = ecma_string_to_number (property_name_p);
|
||||
bool is_same;
|
||||
if (num <= 0)
|
||||
{
|
||||
is_same = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
|
||||
is_same = ecma_compare_ecma_strings (property_name_p, num_to_str);
|
||||
ecma_deref_ecma_string (num_to_str);
|
||||
}
|
||||
|
||||
uint32_t array_index = ecma_string_get_array_index (property_name_p);
|
||||
|
||||
if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
|
||||
if (is_same)
|
||||
{
|
||||
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
|
||||
ecma_value_t value = ECMA_VALUE_UNDEFINED;
|
||||
ecma_value_t value = ecma_get_typedarray_element (&info, num);
|
||||
|
||||
if (array_index < info.length)
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
{
|
||||
uint32_t byte_pos = array_index << info.shift;
|
||||
value = ecma_get_typedarray_element (info.buffer_p + byte_pos, info.id);
|
||||
property_ref_p->virtual_value = value;
|
||||
return ECMA_PROPERTY_TYPE_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (!ecma_is_value_undefined (value))
|
||||
@@ -165,21 +176,11 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
return ECMA_PROPERTY_ENUMERABLE_WRITABLE | ECMA_PROPERTY_VIRTUAL;
|
||||
}
|
||||
|
||||
return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP;
|
||||
else
|
||||
{
|
||||
return ECMA_PROPERTY_TYPE_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_number_t num = ecma_string_to_number (property_name_p);
|
||||
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
|
||||
|
||||
if (ecma_compare_ecma_strings (property_name_p, num_to_str))
|
||||
{
|
||||
ecma_deref_ecma_string (num_to_str);
|
||||
|
||||
return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP;
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (num_to_str);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
@@ -453,6 +454,44 @@ ecma_op_object_has_property (ecma_object_t *object_p, /**< the object */
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
if (ecma_object_is_typedarray (object_p) && !ecma_prop_name_is_symbol (property_name_p))
|
||||
{
|
||||
ecma_number_t num = ecma_string_to_number (property_name_p);
|
||||
bool is_same;
|
||||
if (num <= 0)
|
||||
{
|
||||
is_same = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
|
||||
is_same = ecma_compare_ecma_strings (property_name_p, num_to_str);
|
||||
ecma_deref_ecma_string (num_to_str);
|
||||
}
|
||||
|
||||
if (is_same)
|
||||
{
|
||||
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
|
||||
|
||||
if (ecma_arraybuffer_is_detached (info.array_buffer_p))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached));
|
||||
}
|
||||
|
||||
if (!ecma_op_is_integer (num)
|
||||
|| num >= info.length
|
||||
|| num < 0
|
||||
|| (ecma_number_is_negative (num) && ecma_number_is_zero (num)))
|
||||
{
|
||||
return ECMA_VALUE_FALSE;
|
||||
}
|
||||
|
||||
return ECMA_VALUE_TRUE;
|
||||
}
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
/* 2 - 3. */
|
||||
if (ecma_op_ordinary_object_has_own_property (object_p, property_name_p))
|
||||
{
|
||||
@@ -562,32 +601,25 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t array_index = ecma_string_get_array_index (property_name_p);
|
||||
ecma_number_t num = ecma_string_to_number (property_name_p);
|
||||
bool is_same;
|
||||
if (num <= 0)
|
||||
{
|
||||
is_same = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
|
||||
is_same = ecma_compare_ecma_strings (property_name_p, num_to_str);
|
||||
ecma_deref_ecma_string (num_to_str);
|
||||
}
|
||||
|
||||
if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
|
||||
if (is_same)
|
||||
{
|
||||
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
|
||||
|
||||
if (array_index >= info.length)
|
||||
{
|
||||
return ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
|
||||
uint32_t byte_pos = array_index << info.shift;
|
||||
return ecma_get_typedarray_element (info.buffer_p + byte_pos, info.id);
|
||||
return ecma_get_typedarray_element (&info, num);
|
||||
}
|
||||
|
||||
ecma_number_t num = ecma_string_to_number (property_name_p);
|
||||
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
|
||||
|
||||
if (ecma_compare_ecma_strings (property_name_p, num_to_str))
|
||||
{
|
||||
ecma_deref_ecma_string (num_to_str);
|
||||
|
||||
return ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (num_to_str);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
@@ -1410,29 +1442,23 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t array_index = ecma_string_get_array_index (property_name_p);
|
||||
|
||||
if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
|
||||
{
|
||||
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
|
||||
|
||||
if (array_index >= info.length)
|
||||
{
|
||||
return ECMA_VALUE_FALSE;
|
||||
}
|
||||
|
||||
uint32_t byte_pos = array_index << info.shift;
|
||||
return ecma_set_typedarray_element (info.buffer_p + byte_pos, value, info.id);
|
||||
}
|
||||
|
||||
ecma_number_t num = ecma_string_to_number (property_name_p);
|
||||
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
|
||||
bool is_same = ecma_compare_ecma_strings (property_name_p, num_to_str);
|
||||
ecma_deref_ecma_string (num_to_str);
|
||||
bool is_same;
|
||||
if (num <= 0)
|
||||
{
|
||||
is_same = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *num_to_str = ecma_new_ecma_string_from_number (num);
|
||||
is_same = ecma_compare_ecma_strings (property_name_p, num_to_str);
|
||||
ecma_deref_ecma_string (num_to_str);
|
||||
}
|
||||
|
||||
if (is_same)
|
||||
{
|
||||
return ECMA_VALUE_FALSE;
|
||||
ecma_typedarray_info_t info = ecma_typedarray_get_info (object_p);
|
||||
return ecma_set_typedarray_element (&info, value, num);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1929,12 +1955,17 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
|
||||
ecma_property_ref_t property_ref;
|
||||
|
||||
property_ref.virtual_value = ECMA_VALUE_EMPTY;
|
||||
ecma_property_t property = ecma_op_object_get_own_property (object_p,
|
||||
property_name_p,
|
||||
&property_ref,
|
||||
ECMA_PROPERTY_GET_VALUE);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (property_ref.virtual_value))
|
||||
{
|
||||
return property_ref.virtual_value;
|
||||
}
|
||||
|
||||
if (property == ECMA_PROPERTY_TYPE_NOT_FOUND || property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP)
|
||||
{
|
||||
return ECMA_VALUE_FALSE;
|
||||
|
||||
Reference in New Issue
Block a user