Remove pseudo array object type from the project (#4643)
A new class type enum is introduced to describe the class of objects. This enum is organized to improve property resolve and GC performance. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -63,13 +63,13 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
/* 3. */
|
||||
if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_PSEUDO_ARRAY
|
||||
|| ext_obj_p->u.pseudo_array.type != ECMA_PSEUDO_ARRAY_ITERATOR)
|
||||
if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_CLASS
|
||||
|| ext_obj_p->u.cls.type != ECMA_OBJECT_CLASS_ARRAY_ITERATOR)
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator"));
|
||||
}
|
||||
|
||||
ecma_value_t iterated_value = ext_obj_p->u.pseudo_array.u2.iterated_value;
|
||||
ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value;
|
||||
|
||||
/* 4 - 5 */
|
||||
if (ecma_is_value_empty (iterated_value))
|
||||
@@ -103,7 +103,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
}
|
||||
}
|
||||
|
||||
ecma_length_t index = ext_obj_p->u.pseudo_array.u1.iterator_index;
|
||||
ecma_length_t index = ext_obj_p->u.cls.u2.iterator_index;
|
||||
|
||||
if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT))
|
||||
{
|
||||
@@ -129,17 +129,17 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
else
|
||||
{
|
||||
/* 11. */
|
||||
ext_obj_p->u.pseudo_array.u1.iterator_index++;
|
||||
ext_obj_p->u.cls.u2.iterator_index++;
|
||||
}
|
||||
|
||||
if (index >= length)
|
||||
{
|
||||
ext_obj_p->u.pseudo_array.u2.iterated_value = ECMA_VALUE_EMPTY;
|
||||
ext_obj_p->u.cls.u3.iterated_value = ECMA_VALUE_EMPTY;
|
||||
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
}
|
||||
|
||||
/* 7. */
|
||||
uint8_t iterator_kind = ext_obj_p->u.pseudo_array.extra_info;
|
||||
uint8_t iterator_kind = ext_obj_p->u.cls.u1.iterator_kind;
|
||||
|
||||
if (iterator_kind == ECMA_ITERATOR_KEYS)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /**
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
|
||||
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER))
|
||||
{
|
||||
if (ecma_arraybuffer_is_detached (object_p))
|
||||
{
|
||||
@@ -98,7 +98,7 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
/* 2. */
|
||||
if (!ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
|
||||
if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an ArrayBuffer object"));
|
||||
}
|
||||
@@ -168,7 +168,7 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
/* 13. */
|
||||
if (!ecma_object_class_is (new_arraybuffer_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
|
||||
if (!ecma_object_class_is (new_arraybuffer_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER))
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Return value is not an ArrayBuffer object"));
|
||||
goto free_new_arraybuffer;
|
||||
|
||||
@@ -106,7 +106,7 @@ ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
if (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_ASYNC_GENERATOR_UL)
|
||||
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_ASYNC_GENERATOR)
|
||||
{
|
||||
executable_object_p = (vm_executable_object_t *) ext_object_p;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an async generator object"));
|
||||
}
|
||||
|
||||
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED)
|
||||
if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED)
|
||||
{
|
||||
ecma_value_t promise = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE));
|
||||
|
||||
|
||||
@@ -72,13 +72,13 @@ ecma_builtin_bigint_prototype_object_value_of (ecma_value_t this_arg) /**< this
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_BIGINT_UL))
|
||||
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_BIGINT))
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_bigint (ext_object_p->u.class_prop.u.value));
|
||||
JERRY_ASSERT (ecma_is_value_bigint (ext_object_p->u.cls.u3.value));
|
||||
|
||||
return ecma_copy_value (ext_object_p->u.class_prop.u.value);
|
||||
return ecma_copy_value (ext_object_p->u.cls.u3.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,13 +78,13 @@ ecma_builtin_boolean_prototype_object_value_of (ecma_value_t this_arg) /**< this
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_BOOLEAN_UL))
|
||||
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_BOOLEAN))
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ext_object_p->u.class_prop.u.value));
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ext_object_p->u.cls.u3.value));
|
||||
|
||||
return ext_object_p->u.class_prop.u.value;
|
||||
return ext_object_p->u.cls.u3.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ ecma_builtin_dataview_prototype_object_getters (ecma_value_t this_arg, /**< this
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached"));
|
||||
}
|
||||
return ecma_make_uint32_value (obj_p->header.u.class_prop.u.length);
|
||||
return ecma_make_uint32_value (obj_p->header.u.cls.u3.length);
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
||||
@@ -405,7 +405,7 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
|
||||
ecma_number_t *date_value_p = &date_object_p->date_value;
|
||||
#else /* !JERRY_ESNEXT */
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_number_t *date_value_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t, ext_object_p->u.class_prop.u.date);
|
||||
ecma_number_t *date_value_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t, ext_object_p->u.cls.u3.date);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
ecma_number_t date_value = *date_value_p;
|
||||
@@ -415,9 +415,9 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
|
||||
ecma_number_t local_tza;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (date_object_p->header.u.class_prop.extra_info & ECMA_DATE_TZA_SET)
|
||||
if (date_object_p->header.u.cls.u1.date_flags & ECMA_DATE_TZA_SET)
|
||||
{
|
||||
local_tza = date_object_p->header.u.class_prop.u.tza;
|
||||
local_tza = date_object_p->header.u.cls.u3.tza;
|
||||
JERRY_ASSERT (local_tza == ecma_date_local_time_zone_adjustment (date_value));
|
||||
}
|
||||
else
|
||||
@@ -601,7 +601,7 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
|
||||
*date_value_p = full_date;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
date_object_p->header.u.class_prop.extra_info &= (uint16_t) ~ECMA_DATE_TZA_SET;
|
||||
date_object_p->header.u.cls.u1.date_flags &= (uint8_t) ~ECMA_DATE_TZA_SET;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
return ecma_make_number_value (full_date);
|
||||
@@ -637,7 +637,7 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
if (!ecma_is_value_object (this_arg)
|
||||
|| !ecma_object_class_is (ecma_get_object_from_value (this_arg), LIT_MAGIC_STRING_DATE_UL))
|
||||
|| !ecma_object_class_is (ecma_get_object_from_value (this_arg), ECMA_OBJECT_CLASS_DATE))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Date object"));
|
||||
}
|
||||
@@ -647,11 +647,10 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
|
||||
#if JERRY_ESNEXT
|
||||
ecma_date_object_t *date_object_p = (ecma_date_object_t *) this_obj_p;
|
||||
ecma_number_t *date_value_p = &date_object_p->date_value;
|
||||
#else
|
||||
#else /* JERRY_ESNEXT */
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) this_obj_p;
|
||||
ecma_number_t *date_value_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t,
|
||||
ext_object_p->u.class_prop.u.date);
|
||||
#endif
|
||||
ecma_number_t *date_value_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t, ext_object_p->u.cls.u3.date);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
ecma_number_t date_value = *date_value_p;
|
||||
|
||||
@@ -683,9 +682,9 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
|
||||
{
|
||||
ecma_number_t local_tza;
|
||||
#if JERRY_ESNEXT
|
||||
if (date_object_p->header.u.class_prop.extra_info & ECMA_DATE_TZA_SET)
|
||||
if (date_object_p->header.u.cls.u1.date_flags & ECMA_DATE_TZA_SET)
|
||||
{
|
||||
local_tza = date_object_p->header.u.class_prop.u.tza;
|
||||
local_tza = date_object_p->header.u.cls.u3.tza;
|
||||
JERRY_ASSERT (local_tza == ecma_date_local_time_zone_adjustment (date_value));
|
||||
}
|
||||
else
|
||||
@@ -694,8 +693,8 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
|
||||
local_tza = ecma_date_local_time_zone_adjustment (date_value);
|
||||
#if JERRY_ESNEXT
|
||||
JERRY_ASSERT (local_tza <= INT32_MAX && local_tza >= INT32_MIN);
|
||||
date_object_p->header.u.class_prop.u.tza = (int32_t) local_tza;
|
||||
date_object_p->header.u.class_prop.extra_info |= ECMA_DATE_TZA_SET;
|
||||
date_object_p->header.u.cls.u3.tza = (int32_t) local_tza;
|
||||
date_object_p->header.u.cls.u1.date_flags |= ECMA_DATE_TZA_SET;
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -737,9 +737,10 @@ ecma_builtin_date_create (ecma_number_t tv)
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
ecma_date_object_t *date_object_p = (ecma_date_object_t *) obj_p;
|
||||
date_object_p->header.u.class_prop.class_id = LIT_MAGIC_STRING_DATE_UL;
|
||||
date_object_p->header.u.class_prop.u.tza = 0;
|
||||
date_object_p->header.u.class_prop.extra_info = ECMA_DATE_TZA_NONE;
|
||||
date_object_p->header.u.cls.type = ECMA_OBJECT_CLASS_DATE;
|
||||
date_object_p->header.u.cls.u1.date_flags = ECMA_DATE_TZA_NONE;
|
||||
date_object_p->header.u.cls.u2.id = LIT_MAGIC_STRING_DATE_UL;
|
||||
date_object_p->header.u.cls.u3.tza = 0;
|
||||
date_object_p->date_value = tv;
|
||||
#else /* !JERRY_ESNEXT */
|
||||
ecma_number_t *date_value_p = ecma_alloc_number ();
|
||||
@@ -749,8 +750,9 @@ ecma_builtin_date_create (ecma_number_t tv)
|
||||
ecma_object_t *obj_p = ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_DATE_UL;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.class_prop.u.date, date_value_p);
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_DATE;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_DATE_UL;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.cls.u3.date, date_value_p);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
return ecma_make_object_value (obj_p);
|
||||
@@ -802,14 +804,14 @@ ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**<
|
||||
|
||||
/* 4.a */
|
||||
if (ecma_is_value_object (argument)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (argument), LIT_MAGIC_STRING_DATE_UL))
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (argument), ECMA_OBJECT_CLASS_DATE))
|
||||
{
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
tv = ((ecma_date_object_t *) ecma_get_object_from_value (argument))->date_value;
|
||||
#else /* !JERRY_ESNEXT */
|
||||
ecma_extended_object_t *arg_ext_object_p = (ecma_extended_object_t *) ecma_get_object_from_value (argument);
|
||||
tv = *ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t, arg_ext_object_p->u.class_prop.u.date);
|
||||
tv = *ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t, arg_ext_object_p->u.cls.u3.date);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
return ecma_builtin_date_create (tv);
|
||||
|
||||
@@ -91,7 +91,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (generator_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
|
||||
if (generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
|
||||
{
|
||||
ecma_value_t iterator = generator_object_p->frame_ctx.block_result;
|
||||
ecma_value_t next_method = generator_object_p->frame_ctx.stack_top_p[-1];
|
||||
@@ -149,7 +149,8 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
|
||||
return value;
|
||||
}
|
||||
|
||||
bool done = (generator_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED);
|
||||
bool done;
|
||||
done = (generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED);
|
||||
|
||||
if (!done)
|
||||
{
|
||||
@@ -173,7 +174,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
|
||||
}
|
||||
|
||||
ecma_deref_object (ecma_get_object_from_value (iterator));
|
||||
generator_object_p->extended_object.u.class_prop.extra_info |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD;
|
||||
generator_object_p->extended_object.u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD;
|
||||
generator_object_p->frame_ctx.block_result = iterator;
|
||||
|
||||
if (generator_object_p->frame_ctx.stack_top_p[0] != ECMA_VALUE_UNDEFINED)
|
||||
@@ -219,7 +220,7 @@ ecma_builtin_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, /
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
if (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_GENERATOR_UL)
|
||||
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_GENERATOR)
|
||||
{
|
||||
executable_object_p = (vm_executable_object_t *) ext_object_p;
|
||||
}
|
||||
@@ -231,12 +232,12 @@ ecma_builtin_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, /
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a generator object"));
|
||||
}
|
||||
|
||||
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_RUNNING)
|
||||
if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_RUNNING)
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Generator is currently under execution"));
|
||||
}
|
||||
|
||||
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED)
|
||||
if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED)
|
||||
{
|
||||
if (builtin_routine_id != ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW)
|
||||
{
|
||||
|
||||
@@ -39,9 +39,13 @@ typedef enum
|
||||
ECMA_NATIVE_HANDLER_FLAGS_NONE = 0,
|
||||
ECMA_NATIVE_HANDLER_FLAGS_NAME_INITIALIZED = (1 << 0),
|
||||
ECMA_NATIVE_HANDLER_FLAGS_LENGTH_INITIALIZED = (1 << 1),
|
||||
ECMA_NATIVE_HANDLER_FLAGS_PROMISE_ALREADY_RESOLVED = (1 << 2),
|
||||
} ecma_native_handler_flags_t;
|
||||
|
||||
/**
|
||||
* Shift for Promise helper handler function.
|
||||
*/
|
||||
#define ECMA_NATIVE_HANDLER_FLAGS_PROMISE_HELPER_SHIFT 2
|
||||
|
||||
ecma_builtin_handler_t
|
||||
ecma_builtin_handler_get (ecma_native_handler_id_t id);
|
||||
uint8_t
|
||||
|
||||
@@ -116,7 +116,7 @@ ecma_builtin_intrinsic_map_prototype_entries (ecma_value_t this_value)
|
||||
|
||||
return ecma_op_container_create_iterator (this_value,
|
||||
ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE,
|
||||
ECMA_PSEUDO_MAP_ITERATOR,
|
||||
ECMA_OBJECT_CLASS_MAP_ITERATOR,
|
||||
ECMA_ITERATOR_ENTRIES);
|
||||
} /* ecma_builtin_intrinsic_map_prototype_entries */
|
||||
|
||||
@@ -142,7 +142,7 @@ ecma_builtin_intrinsic_set_prototype_values (ecma_value_t this_value)
|
||||
|
||||
return ecma_op_container_create_iterator (this_value,
|
||||
ECMA_BUILTIN_ID_SET_ITERATOR_PROTOTYPE,
|
||||
ECMA_PSEUDO_SET_ITERATOR,
|
||||
ECMA_OBJECT_CLASS_SET_ITERATOR,
|
||||
ECMA_ITERATOR_VALUES);
|
||||
} /* ecma_builtin_intrinsic_set_prototype_values */
|
||||
|
||||
@@ -205,7 +205,7 @@ ecma_builtin_intrinsic_dispatch_routine (uint8_t builtin_routine_id, /**< built-
|
||||
case ECMA_INTRINSIC_DATE_TO_UTC_STRING:
|
||||
{
|
||||
if (!ecma_is_value_object (this_arg)
|
||||
|| !ecma_object_class_is (ecma_get_object_from_value (this_arg), LIT_MAGIC_STRING_DATE_UL))
|
||||
|| !ecma_object_class_is (ecma_get_object_from_value (this_arg), ECMA_OBJECT_CLASS_DATE))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Date object"));
|
||||
}
|
||||
|
||||
@@ -1314,51 +1314,60 @@ ecma_builtin_json_serialize_property (ecma_json_stringify_context_t *context_p,
|
||||
if (ecma_is_value_object (value))
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (value);
|
||||
lit_magic_string_id_t class_name = ecma_object_get_class_name (obj_p);
|
||||
|
||||
/* 5.a */
|
||||
if (class_name == LIT_MAGIC_STRING_NUMBER_UL)
|
||||
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_CLASS)
|
||||
{
|
||||
ecma_number_t num;
|
||||
value = ecma_op_to_number (value, &num);
|
||||
ecma_deref_object (obj_p);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
switch (((ecma_extended_object_t *) obj_p)->u.cls.type)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
/* 5.a */
|
||||
case ECMA_OBJECT_CLASS_NUMBER:
|
||||
{
|
||||
ecma_number_t num;
|
||||
value = ecma_op_to_number (value, &num);
|
||||
ecma_deref_object (obj_p);
|
||||
|
||||
value = ecma_make_number_value (num);
|
||||
}
|
||||
/* 5.b */
|
||||
else if (class_name == LIT_MAGIC_STRING_STRING_UL)
|
||||
{
|
||||
ecma_string_t *str_p = ecma_op_to_string (value);
|
||||
ecma_deref_object (obj_p);
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
if (JERRY_UNLIKELY (str_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
value = ecma_make_number_value (num);
|
||||
break;
|
||||
}
|
||||
/* 5.b */
|
||||
case ECMA_OBJECT_CLASS_STRING:
|
||||
{
|
||||
ecma_string_t *str_p = ecma_op_to_string (value);
|
||||
ecma_deref_object (obj_p);
|
||||
|
||||
value = ecma_make_string_value (str_p);
|
||||
}
|
||||
/* 5.c */
|
||||
else if (class_name == LIT_MAGIC_STRING_BOOLEAN_UL)
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
value = ext_object_p->u.class_prop.u.value;
|
||||
ecma_deref_object (obj_p);
|
||||
}
|
||||
if (JERRY_UNLIKELY (str_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
value = ecma_make_string_value (str_p);
|
||||
break;
|
||||
}
|
||||
/* 5.c */
|
||||
case ECMA_OBJECT_CLASS_BOOLEAN:
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
value = ext_object_p->u.cls.u3.value;
|
||||
ecma_deref_object (obj_p);
|
||||
break;
|
||||
}
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
/* 5.d */
|
||||
else if (class_name == LIT_MAGIC_STRING_BIGINT_UL)
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
value = ecma_copy_value (ext_object_p->u.class_prop.u.value);
|
||||
ecma_deref_object (obj_p);
|
||||
}
|
||||
/* 5.d */
|
||||
case ECMA_OBJECT_CLASS_BIGINT:
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
value = ecma_copy_value (ext_object_p->u.cls.u3.value);
|
||||
ecma_deref_object (obj_p);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 6. - 8. */
|
||||
@@ -1616,20 +1625,24 @@ ecma_builtin_json_stringify (ecma_value_t this_arg, /**< 'this' argument */
|
||||
else if (ecma_is_value_object (value))
|
||||
{
|
||||
ecma_object_t *value_obj_p = ecma_get_object_from_value (value);
|
||||
lit_magic_string_id_t class_id = ecma_object_get_class_name (value_obj_p);
|
||||
|
||||
if (class_id == LIT_MAGIC_STRING_NUMBER_UL || class_id == LIT_MAGIC_STRING_STRING_UL)
|
||||
if (ecma_get_object_type (value_obj_p) == ECMA_OBJECT_TYPE_CLASS)
|
||||
{
|
||||
ecma_string_t *str_p = ecma_op_to_string (value);
|
||||
uint8_t class_type = ((ecma_extended_object_t *) value_obj_p)->u.cls.type;
|
||||
|
||||
if (JERRY_UNLIKELY (str_p == NULL))
|
||||
if (class_type == ECMA_OBJECT_CLASS_NUMBER || class_type == ECMA_OBJECT_CLASS_STRING)
|
||||
{
|
||||
ecma_collection_free (context.property_list_p);
|
||||
ecma_free_value (value);
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
ecma_string_t *str_p = ecma_op_to_string (value);
|
||||
|
||||
item = ecma_make_string_value (str_p);
|
||||
if (JERRY_UNLIKELY (str_p == NULL))
|
||||
{
|
||||
ecma_collection_free (context.property_list_p);
|
||||
ecma_free_value (value);
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
item = ecma_make_string_value (str_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1657,52 +1670,54 @@ ecma_builtin_json_stringify (ecma_value_t this_arg, /**< 'this' argument */
|
||||
}
|
||||
}
|
||||
|
||||
ecma_value_t space;
|
||||
ecma_value_t space = ECMA_VALUE_EMPTY;
|
||||
|
||||
/* 5. */
|
||||
if (ecma_is_value_object (arg3))
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (arg3);
|
||||
lit_magic_string_id_t class_name = ecma_object_get_class_name (obj_p);
|
||||
|
||||
/* 5.a */
|
||||
if (class_name == LIT_MAGIC_STRING_NUMBER_UL)
|
||||
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_CLASS)
|
||||
{
|
||||
ecma_number_t num;
|
||||
ecma_value_t value = ecma_op_to_number (arg3, &num);
|
||||
uint8_t class_type = ((ecma_extended_object_t *) obj_p)->u.cls.type;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
/* 5.a */
|
||||
if (class_type == ECMA_OBJECT_CLASS_NUMBER)
|
||||
{
|
||||
if (context.property_list_p != NULL)
|
||||
{
|
||||
ecma_collection_free (context.property_list_p);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
space = ecma_make_number_value (num);
|
||||
}
|
||||
/* 5.b */
|
||||
else if (class_name == LIT_MAGIC_STRING_STRING_UL)
|
||||
{
|
||||
ecma_string_t *value_str_p = ecma_op_to_string (arg3);
|
||||
ecma_number_t num;
|
||||
ecma_value_t value = ecma_op_to_number (arg3, &num);
|
||||
|
||||
if (JERRY_UNLIKELY (value_str_p == NULL))
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
{
|
||||
if (context.property_list_p != NULL)
|
||||
{
|
||||
ecma_collection_free (context.property_list_p);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
space = ecma_make_number_value (num);
|
||||
}
|
||||
/* 5.b */
|
||||
else if (class_type == ECMA_OBJECT_CLASS_STRING)
|
||||
{
|
||||
if (context.property_list_p != NULL)
|
||||
{
|
||||
ecma_collection_free (context.property_list_p);
|
||||
}
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
ecma_string_t *value_str_p = ecma_op_to_string (arg3);
|
||||
|
||||
space = ecma_make_string_value (value_str_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
space = ecma_copy_value (arg3);
|
||||
if (JERRY_UNLIKELY (value_str_p == NULL))
|
||||
{
|
||||
if (context.property_list_p != NULL)
|
||||
{
|
||||
ecma_collection_free (context.property_list_p);
|
||||
}
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
space = ecma_make_string_value (value_str_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (space == ECMA_VALUE_EMPTY)
|
||||
{
|
||||
space = ecma_copy_value (arg3);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_iterator_prototype_object_next (ecma_value_t this_val) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_iterator_next (this_val, ECMA_PSEUDO_MAP_ITERATOR);
|
||||
return ecma_op_container_iterator_next (this_val, ECMA_OBJECT_CLASS_MAP_ITERATOR);
|
||||
} /* ecma_builtin_map_iterator_prototype_object_next */
|
||||
|
||||
/**
|
||||
|
||||
@@ -446,13 +446,13 @@ ecma_builtin_number_prototype_object_value_of (ecma_value_t this_arg) /**< this
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_NUMBER_UL))
|
||||
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_NUMBER))
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_number (ext_object_p->u.class_prop.u.value));
|
||||
JERRY_ASSERT (ecma_is_value_number (ext_object_p->u.cls.u3.value));
|
||||
|
||||
return ext_object_p->u.class_prop.u.value;
|
||||
return ext_object_p->u.cls.u3.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ static inline ecma_value_t
|
||||
ecma_builtin_promise_reject_abrupt (ecma_value_t value, /**< value */
|
||||
ecma_object_t *capability_obj_p) /**< capability */
|
||||
{
|
||||
JERRY_ASSERT (ecma_object_class_is (capability_obj_p, LIT_INTERNAL_MAGIC_PROMISE_CAPABILITY));
|
||||
JERRY_ASSERT (ecma_object_class_is (capability_obj_p, ECMA_OBJECT_CLASS_PROMISE_CAPABILITY));
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (value))
|
||||
{
|
||||
@@ -101,7 +101,7 @@ ecma_builtin_promise_reject_abrupt (ecma_value_t value, /**< value */
|
||||
|
||||
ecma_free_value (call_ret);
|
||||
|
||||
return ecma_copy_value (capability_p->header.u.class_prop.u.promise);
|
||||
return ecma_copy_value (capability_p->header.u.cls.u3.promise);
|
||||
} /* ecma_builtin_promise_reject_abrupt */
|
||||
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ ecma_builtin_promise_perform_race (ecma_value_t iterator, /**< the iterator for
|
||||
bool *done_p) /**< [out] iteratorRecord[[done]] */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (iterator));
|
||||
JERRY_ASSERT (ecma_object_class_is (capability_obj_p, LIT_INTERNAL_MAGIC_PROMISE_CAPABILITY));
|
||||
JERRY_ASSERT (ecma_object_class_is (capability_obj_p, ECMA_OBJECT_CLASS_PROMISE_CAPABILITY));
|
||||
JERRY_ASSERT (ecma_is_constructor (ctor));
|
||||
|
||||
ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) capability_obj_p;
|
||||
@@ -145,7 +145,7 @@ ecma_builtin_promise_perform_race (ecma_value_t iterator, /**< the iterator for
|
||||
if (ecma_is_value_false (next))
|
||||
{
|
||||
/* ii. */
|
||||
ret_value = ecma_copy_value (capability_p->header.u.class_prop.u.promise);
|
||||
ret_value = ecma_copy_value (capability_p->header.u.cls.u3.promise);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ ecma_builtin_promise_perform (ecma_value_t iterator, /**< iteratorRecord */
|
||||
bool *done_p) /**< [out] iteratorRecord[[done]] */
|
||||
{
|
||||
/* 1. - 2. */
|
||||
JERRY_ASSERT (ecma_object_class_is (capability_obj_p, LIT_INTERNAL_MAGIC_PROMISE_CAPABILITY));
|
||||
JERRY_ASSERT (ecma_object_class_is (capability_obj_p, ECMA_OBJECT_CLASS_PROMISE_CAPABILITY));
|
||||
JERRY_ASSERT (ecma_is_constructor (ctor));
|
||||
|
||||
ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) capability_obj_p;
|
||||
@@ -261,7 +261,7 @@ ecma_builtin_promise_perform (ecma_value_t iterator, /**< iteratorRecord */
|
||||
}
|
||||
|
||||
/* iv. */
|
||||
ret_value = ecma_copy_value (capability_p->header.u.class_prop.u.promise);
|
||||
ret_value = ecma_copy_value (capability_p->header.u.cls.u3.promise);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -320,13 +320,16 @@ ecma_builtin_promise_perform (ecma_value_t iterator, /**< iteratorRecord */
|
||||
|
||||
/* p. */
|
||||
executor_p->remaining_elements = remaining;
|
||||
executor_p->header.u.class_prop.extra_info = ECMA_PROMISE_ALL_RESOLVE;
|
||||
|
||||
uint8_t executor_type = ECMA_PROMISE_ALL_RESOLVE << ECMA_NATIVE_HANDLER_FLAGS_PROMISE_HELPER_SHIFT;
|
||||
|
||||
if (builtin_routine_id == ECMA_PROMISE_ROUTINE_ALLSETTLED)
|
||||
{
|
||||
executor_p->header.u.class_prop.extra_info = ECMA_PROMISE_ALLSETTLED_RESOLVE;
|
||||
executor_type = ECMA_PROMISE_ALLSETTLED_RESOLVE << ECMA_NATIVE_HANDLER_FLAGS_PROMISE_HELPER_SHIFT;
|
||||
}
|
||||
|
||||
executor_p->header.u.built_in.u2.routine_flags |= executor_type;
|
||||
|
||||
args[0] = ecma_make_object_value (executor_func_p);
|
||||
}
|
||||
else
|
||||
@@ -340,22 +343,22 @@ ecma_builtin_promise_perform (ecma_value_t iterator, /**< iteratorRecord */
|
||||
|
||||
if (builtin_routine_id != ECMA_PROMISE_ROUTINE_ALL)
|
||||
{
|
||||
ecma_promise_all_exector_type_t type = ECMA_PROMISE_ALLSETTLED_REJECT;
|
||||
uint8_t executor_type = ECMA_PROMISE_ALLSETTLED_REJECT << ECMA_NATIVE_HANDLER_FLAGS_PROMISE_HELPER_SHIFT;
|
||||
|
||||
if (builtin_routine_id == ECMA_PROMISE_ROUTINE_ANY)
|
||||
{
|
||||
type = ECMA_PROMISE_ANY_REJECT;
|
||||
executor_type = ECMA_PROMISE_ANY_REJECT << ECMA_NATIVE_HANDLER_FLAGS_PROMISE_HELPER_SHIFT;
|
||||
}
|
||||
|
||||
ecma_object_t *reject_func_p = ecma_op_create_native_handler (ECMA_NATIVE_HANDLER_PROMISE_ALL_HELPER,
|
||||
sizeof (ecma_promise_all_executor_t));
|
||||
sizeof (ecma_promise_all_executor_t));
|
||||
|
||||
ecma_promise_all_executor_t *reject_p = (ecma_promise_all_executor_t *) reject_func_p;
|
||||
reject_p->index = idx;
|
||||
reject_p->values = values_array;
|
||||
reject_p->capability = ecma_make_object_value (capability_obj_p);
|
||||
reject_p->remaining_elements = remaining;
|
||||
reject_p->header.u.class_prop.extra_info = (uint16_t) type;
|
||||
reject_p->header.u.built_in.u2.routine_flags |= executor_type;
|
||||
args[1] = ecma_make_object_value (reject_func_p);
|
||||
result = ecma_op_invoke_by_magic_id (next_promise, LIT_MAGIC_STRING_THEN, args, 2);
|
||||
ecma_deref_object (reject_func_p);
|
||||
|
||||
@@ -96,8 +96,7 @@ static ecma_value_t
|
||||
ecma_builtin_regexp_prototype_flags_helper (ecma_extended_object_t *re_obj_p, /**< this object */
|
||||
uint16_t builtin_routine_id) /**< id of the flag */
|
||||
{
|
||||
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
|
||||
re_obj_p->u.class_prop.u.value);
|
||||
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, re_obj_p->u.cls.u3.value);
|
||||
|
||||
uint16_t flags = bc_p->header.status_flags;
|
||||
|
||||
@@ -253,8 +252,7 @@ ecma_op_escape_regexp_pattern (ecma_string_t *pattern_str_p) /**< RegExp pattern
|
||||
static ecma_value_t
|
||||
ecma_builtin_regexp_prototype_get_source (ecma_extended_object_t *re_obj_p) /**< this argument */
|
||||
{
|
||||
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
|
||||
re_obj_p->u.class_prop.u.value);
|
||||
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, re_obj_p->u.cls.u3.value);
|
||||
|
||||
return ecma_op_escape_regexp_pattern (ecma_get_string_from_value (bc_p->source));
|
||||
} /* ecma_builtin_regexp_prototype_get_source */
|
||||
@@ -286,8 +284,7 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this */
|
||||
|
||||
ecma_object_t *this_obj_p = ecma_get_object_from_value (this_arg);
|
||||
ecma_extended_object_t *re_obj_p = (ecma_extended_object_t *) this_obj_p;
|
||||
re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
|
||||
re_obj_p->u.class_prop.u.value);
|
||||
re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, re_obj_p->u.cls.u3.value);
|
||||
|
||||
ecma_value_t ret_value;
|
||||
|
||||
@@ -299,8 +296,7 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this */
|
||||
}
|
||||
|
||||
ecma_extended_object_t *pattern_obj_p = (ecma_extended_object_t *) ecma_get_object_from_value (pattern_arg);
|
||||
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
|
||||
pattern_obj_p->u.class_prop.u.value);
|
||||
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, pattern_obj_p->u.cls.u3.value);
|
||||
|
||||
ret_value = ecma_op_create_regexp_from_bytecode (this_obj_p, bc_p);
|
||||
}
|
||||
@@ -471,7 +467,7 @@ ecma_builtin_regexp_prototype_to_string (ecma_object_t *object_p) /**< this obje
|
||||
ecma_extended_object_t *re_obj_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
|
||||
re_obj_p->u.class_prop.u.value);
|
||||
re_obj_p->u.cls.u3.value);
|
||||
|
||||
ecma_string_t *source_p = ecma_get_string_from_value (bc_p->source);
|
||||
uint16_t flags = bc_p->header.status_flags;
|
||||
@@ -639,11 +635,11 @@ ecma_builtin_regexp_prototype_match_all (ecma_object_t *regexp_obj_p, /**< this
|
||||
ecma_object_t *proto_p = ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP_STRING_ITERATOR_PROTOTYPE);
|
||||
result_obj = ecma_create_object (proto_p,
|
||||
sizeof (ecma_regexp_string_iterator_t),
|
||||
ECMA_OBJECT_TYPE_PSEUDO_ARRAY);
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) result_obj;
|
||||
ext_obj_p->u.pseudo_array.type = (uint8_t) ECMA_PSEUDO_REGEXP_STRING_ITERATOR;
|
||||
ext_obj_p->u.pseudo_array.extra_info = (uint8_t) (parsed_flag & (RE_FLAG_GLOBAL | RE_FLAG_UNICODE));
|
||||
ext_obj_p->u.cls.type = ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR;
|
||||
ext_obj_p->u.cls.u1.regexp_string_iterator_flags = (uint8_t) (parsed_flag & (RE_FLAG_GLOBAL | RE_FLAG_UNICODE));
|
||||
|
||||
ecma_regexp_string_iterator_t *regexp_string_iterator_obj = (ecma_regexp_string_iterator_t *) result_obj;
|
||||
|
||||
@@ -684,7 +680,7 @@ ecma_builtin_regexp_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
{
|
||||
obj_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (require_regexp && !ecma_object_class_is (obj_p, LIT_MAGIC_STRING_REGEXP_UL))
|
||||
if (require_regexp && !ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_REGEXP))
|
||||
{
|
||||
obj_p = NULL;
|
||||
}
|
||||
@@ -742,7 +738,7 @@ ecma_builtin_regexp_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
}
|
||||
case ECMA_REGEXP_PROTOTYPE_ROUTINE_GET_SOURCE:
|
||||
{
|
||||
if (!ecma_object_class_is (obj_p, LIT_MAGIC_STRING_REGEXP_UL))
|
||||
if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_REGEXP))
|
||||
{
|
||||
if (obj_p == ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE))
|
||||
{
|
||||
@@ -762,7 +758,7 @@ ecma_builtin_regexp_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
case ECMA_REGEXP_PROTOTYPE_ROUTINE_GET_UNICODE:
|
||||
case ECMA_REGEXP_PROTOTYPE_ROUTINE_GET_DOT_ALL:
|
||||
{
|
||||
if (!ecma_object_class_is (obj_p, LIT_MAGIC_STRING_REGEXP_UL))
|
||||
if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_REGEXP))
|
||||
{
|
||||
if (obj_p == ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE))
|
||||
{
|
||||
|
||||
@@ -61,11 +61,9 @@ ecma_builtin_regexp_string_iterator_prototype_object_next (ecma_value_t this_val
|
||||
}
|
||||
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_val);
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
/* 3. */
|
||||
if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_PSEUDO_ARRAY
|
||||
|| ext_obj_p->u.pseudo_array.type != ECMA_PSEUDO_REGEXP_STRING_ITERATOR)
|
||||
if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator"));
|
||||
}
|
||||
@@ -106,7 +104,7 @@ ecma_builtin_regexp_string_iterator_prototype_object_next (ecma_value_t this_val
|
||||
ecma_value_t result = ECMA_VALUE_ERROR;
|
||||
|
||||
/* 11. */
|
||||
if (regexp_string_iterator_obj->header.u.pseudo_array.extra_info & RE_FLAG_GLOBAL)
|
||||
if (regexp_string_iterator_obj->header.u.cls.u1.regexp_string_iterator_flags & RE_FLAG_GLOBAL)
|
||||
{
|
||||
ecma_value_t matched_str_value = ecma_op_object_get_by_index (match_result_array_p, 0);
|
||||
|
||||
@@ -145,10 +143,10 @@ ecma_builtin_regexp_string_iterator_prototype_object_next (ecma_value_t this_val
|
||||
goto free_variables;
|
||||
}
|
||||
|
||||
bool full_unciode = (regexp_string_iterator_obj->header.u.pseudo_array.extra_info & RE_FLAG_UNICODE) != 0;
|
||||
uint8_t flags = regexp_string_iterator_obj->header.u.cls.u1.regexp_string_iterator_flags;
|
||||
ecma_length_t next_index = ecma_op_advance_string_index (matcher_str_p,
|
||||
this_index,
|
||||
full_unciode);
|
||||
(flags & RE_FLAG_UNICODE) != 0);
|
||||
|
||||
ecma_value_t next_index_value = ecma_make_length_value (next_index);
|
||||
ecma_value_t set = ecma_op_object_put (regexp_obj_p,
|
||||
|
||||
@@ -106,8 +106,7 @@ ecma_builtin_regexp_dispatch_helper (const ecma_value_t *arguments_list_p, /**<
|
||||
if (ecma_object_is_regexp_object (pattern_value))
|
||||
{
|
||||
ecma_extended_object_t *pattern_obj_p = (ecma_extended_object_t *) ecma_get_object_from_value (pattern_value);
|
||||
bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
|
||||
pattern_obj_p->u.class_prop.u.value);
|
||||
bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, pattern_obj_p->u.cls.u3.value);
|
||||
|
||||
create_regexp_from_bc = ecma_is_value_undefined (flags_value);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_iterator_prototype_object_next (ecma_value_t this_val) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_iterator_next (this_val, ECMA_PSEUDO_SET_ITERATOR);
|
||||
return ecma_op_container_iterator_next (this_val, ECMA_OBJECT_CLASS_SET_ITERATOR);
|
||||
} /* ecma_builtin_set_iterator_prototype_object_next */
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,13 +61,12 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**<
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
/* 3. */
|
||||
if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_PSEUDO_ARRAY
|
||||
|| ext_obj_p->u.pseudo_array.type != ECMA_PSEUDO_STRING_ITERATOR)
|
||||
if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_STRING_ITERATOR))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator"));
|
||||
}
|
||||
|
||||
ecma_value_t iterated_value = ext_obj_p->u.pseudo_array.u2.iterated_value;
|
||||
ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value;
|
||||
|
||||
/* 4 - 5 */
|
||||
if (ecma_is_value_empty (iterated_value))
|
||||
@@ -80,7 +79,7 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**<
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (iterated_value);
|
||||
|
||||
/* 6. */
|
||||
lit_utf8_size_t position = ext_obj_p->u.pseudo_array.u1.iterator_index;
|
||||
lit_utf8_size_t position = ext_obj_p->u.cls.u2.iterator_index;
|
||||
|
||||
if (JERRY_UNLIKELY (position == ECMA_ITERATOR_INDEX_LIMIT))
|
||||
{
|
||||
@@ -94,7 +93,7 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**<
|
||||
if (position >= len)
|
||||
{
|
||||
ecma_deref_ecma_string (string_p);
|
||||
ext_obj_p->u.pseudo_array.u2.iterated_value = ECMA_VALUE_EMPTY;
|
||||
ext_obj_p->u.cls.u3.iterated_value = ECMA_VALUE_EMPTY;
|
||||
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
}
|
||||
|
||||
@@ -129,7 +128,7 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**<
|
||||
}
|
||||
|
||||
/* 13. */
|
||||
ext_obj_p->u.pseudo_array.u1.iterator_index = (uint16_t) (position + result_size);
|
||||
ext_obj_p->u.cls.u2.iterator_index = (uint16_t) (position + result_size);
|
||||
|
||||
/* 14. */
|
||||
ecma_value_t result = ecma_create_iter_result_object (ecma_make_string_value (result_str_p), ECMA_VALUE_FALSE);
|
||||
|
||||
@@ -130,13 +130,13 @@ ecma_builtin_string_prototype_object_to_string (ecma_value_t this_arg) /**< this
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_STRING_UL))
|
||||
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_STRING))
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_string (ext_object_p->u.class_prop.u.value));
|
||||
JERRY_ASSERT (ecma_is_value_string (ext_object_p->u.cls.u3.value));
|
||||
|
||||
return ecma_copy_value (ext_object_p->u.class_prop.u.value);
|
||||
return ecma_copy_value (ext_object_p->u.cls.u3.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1447,7 +1447,7 @@ ecma_builtin_string_prototype_object_iterator (ecma_value_t to_string) /**< this
|
||||
{
|
||||
return ecma_op_create_iterator_object (ecma_copy_value (to_string),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_STRING_ITERATOR_PROTOTYPE),
|
||||
ECMA_PSEUDO_STRING_ITERATOR,
|
||||
ECMA_OBJECT_CLASS_STRING_ITERATOR,
|
||||
ECMA_ITERATOR_VALUES);
|
||||
} /* ecma_builtin_string_prototype_object_iterator */
|
||||
|
||||
|
||||
@@ -55,12 +55,12 @@ ecma_builtin_weakref_prototype_object_deref (ecma_value_t this_arg) /**< this ar
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
ecma_extended_object_t *this_ext_obj = (ecma_extended_object_t *) object_p;
|
||||
|
||||
if (!ecma_object_class_is (object_p, LIT_MAGIC_STRING_WEAKREF_UL))
|
||||
if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_WEAKREF))
|
||||
{
|
||||
return ecma_raise_type_error ("Target is not weakRef");
|
||||
}
|
||||
|
||||
return ecma_copy_value (this_ext_obj->u.class_prop.u.target);
|
||||
return ecma_copy_value (this_ext_obj->u.cls.u3.target);
|
||||
} /* ecma_builtin_weakref_prototype_object_deref */
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,8 +81,9 @@ ecma_builtin_weakref_dispatch_construct (const ecma_value_t *arguments_list_p, /
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_deref_object (proto_p);
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
|
||||
ext_obj_p->u.class_prop.class_id = (uint16_t) LIT_MAGIC_STRING_WEAKREF_UL;
|
||||
ext_obj_p->u.class_prop.u.target = arguments_list_p[0];
|
||||
ext_obj_p->u.cls.type = ECMA_OBJECT_CLASS_WEAKREF;
|
||||
ext_obj_p->u.cls.u2.id = LIT_MAGIC_STRING_WEAKREF_UL;
|
||||
ext_obj_p->u.cls.u3.target = arguments_list_p[0];
|
||||
ecma_op_object_set_weak (ecma_get_object_from_value (arguments_list_p[0]), object_p);
|
||||
|
||||
return ecma_make_object_value (object_p);
|
||||
|
||||
@@ -463,8 +463,9 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
JERRY_ASSERT (obj_type == ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_STRING_UL;
|
||||
ext_object_p->u.class_prop.u.value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_STRING;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_STRING_UL;
|
||||
ext_object_p->u.cls.u3.value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_STRING */
|
||||
@@ -475,8 +476,9 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
JERRY_ASSERT (obj_type == ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_NUMBER_UL;
|
||||
ext_object_p->u.class_prop.u.value = ecma_make_integer_value (0);
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_NUMBER;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_NUMBER_UL;
|
||||
ext_object_p->u.cls.u3.value = ecma_make_integer_value (0);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_NUMBER */
|
||||
@@ -487,8 +489,9 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
JERRY_ASSERT (obj_type == ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_BOOLEAN_UL;
|
||||
ext_object_p->u.class_prop.u.value = ECMA_VALUE_FALSE;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_BOOLEAN;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_BOOLEAN_UL;
|
||||
ext_object_p->u.cls.u3.value = ECMA_VALUE_FALSE;
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_BOOLEAN */
|
||||
@@ -500,11 +503,12 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
JERRY_ASSERT (obj_type == ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_DATE_UL;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_DATE;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_DATE_UL;
|
||||
|
||||
ecma_number_t *prim_prop_num_value_p = ecma_alloc_number ();
|
||||
*prim_prop_num_value_p = ecma_number_make_nan ();
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.class_prop.u.value, prim_prop_num_value_p);
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.cls.u3.value, prim_prop_num_value_p);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
@@ -515,15 +519,15 @@ ecma_instantiate_builtin (ecma_global_object_t *global_object_p, /**< global obj
|
||||
JERRY_ASSERT (obj_type == ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_REGEXP_UL;
|
||||
ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_REGEXP;
|
||||
ext_object_p->u.cls.u2.id = LIT_MAGIC_STRING_REGEXP_UL;
|
||||
|
||||
re_compiled_code_t *bc_p = re_compile_bytecode (ecma_get_magic_string (LIT_MAGIC_STRING_EMPTY_NON_CAPTURE_GROUP),
|
||||
RE_FLAG_EMPTY);
|
||||
|
||||
JERRY_ASSERT (bc_p != NULL);
|
||||
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.class_prop.u.value, bc_p);
|
||||
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.cls.u3.value, bc_p);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
|
||||
@@ -1864,7 +1864,7 @@ ecma_builtin_typedarray_prototype_dispatch_routine (uint8_t builtin_routine_id,
|
||||
case ECMA_TYPEDARRAY_PROTOTYPE_ROUTINE_TO_STRING_TAG_GETTER:
|
||||
{
|
||||
ecma_extended_object_t *obj_p = (ecma_extended_object_t *) typedarray_p;
|
||||
return ecma_make_magic_string_value (obj_p->u.pseudo_array.u1.class_id);
|
||||
return ecma_make_magic_string_value (obj_p->u.cls.u2.id);
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user