Improve magic string handling. (#2221)
Remove unnecessary ref / deref calls when magic strings are used. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -59,17 +59,14 @@ ecma_builtin_array_prototype_helper_set_length (ecma_object_t *object, /**< obje
|
||||
ecma_number_t length) /**< new length */
|
||||
{
|
||||
ecma_value_t ret_value;
|
||||
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
|
||||
|
||||
ecma_value_t length_value = ecma_make_number_value (length);
|
||||
ret_value = ecma_op_object_put (object,
|
||||
magic_string_length_p,
|
||||
ecma_get_length_string (),
|
||||
length_value,
|
||||
true),
|
||||
|
||||
ecma_free_value (length_value);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_array_prototype_helper_set_length */
|
||||
|
||||
@@ -155,8 +152,7 @@ ecma_builtin_array_prototype_object_to_locale_string (const ecma_value_t this_ar
|
||||
/* 5. */
|
||||
if (length == 0)
|
||||
{
|
||||
ecma_string_t *empty_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
ret_value = ecma_make_string_value (empty_string_p);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -282,13 +278,10 @@ ecma_op_array_get_separator_string (ecma_value_t separator) /**< possible separa
|
||||
{
|
||||
if (ecma_is_value_undefined (separator))
|
||||
{
|
||||
ecma_string_t *comma_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_COMMA_CHAR);
|
||||
return ecma_make_string_value (comma_string_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ecma_op_to_string (separator);
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING_COMMA_CHAR);
|
||||
}
|
||||
|
||||
return ecma_op_to_string (separator);
|
||||
} /* ecma_op_array_get_separator_string */
|
||||
|
||||
/**
|
||||
@@ -314,8 +307,7 @@ ecma_op_array_get_to_string_at_index (ecma_object_t *obj_p, /**< this object */
|
||||
if (ecma_is_value_undefined (index_value)
|
||||
|| ecma_is_value_null (index_value))
|
||||
{
|
||||
ecma_string_t *empty_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
ret_value = ecma_make_string_value (empty_string_p);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -371,8 +363,7 @@ ecma_builtin_array_prototype_join (const ecma_value_t this_arg, /**< this argume
|
||||
if (length == 0)
|
||||
{
|
||||
/* 6. */
|
||||
ecma_string_t *empty_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
ret_value = ecma_make_string_value (empty_string_p);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -709,10 +700,10 @@ ecma_builtin_array_prototype_object_shift (ecma_value_t this_arg) /**< this argu
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (0);
|
||||
|
||||
/* 5. */
|
||||
ECMA_TRY_CATCH (first_value, ecma_op_object_get (obj_p, index_str_p), ret_value);
|
||||
ECMA_TRY_CATCH (first_value,
|
||||
ecma_op_object_get (obj_p, ecma_get_ecma_string_from_uint32 (0)),
|
||||
ret_value);
|
||||
|
||||
/* 6. and 7. */
|
||||
for (uint32_t k = 1; k < len && ecma_is_value_empty (ret_value); k++)
|
||||
@@ -766,7 +757,6 @@ ecma_builtin_array_prototype_object_shift (ecma_value_t this_arg) /**< this argu
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (first_value);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
}
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
|
||||
|
||||
@@ -62,21 +62,17 @@ ecma_builtin_boolean_prototype_object_to_string (ecma_value_t this_arg) /**< thi
|
||||
ecma_builtin_boolean_prototype_object_value_of (this_arg),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *ret_str_p;
|
||||
|
||||
if (ecma_is_value_true (value_of_ret))
|
||||
{
|
||||
ret_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_TRUE);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_boolean (value_of_ret));
|
||||
|
||||
ret_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_FALSE);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_FALSE);
|
||||
}
|
||||
|
||||
ret_value = ecma_make_string_value (ret_str_p);
|
||||
|
||||
ECMA_FINALIZE (value_of_ret);
|
||||
|
||||
return ret_value;
|
||||
|
||||
@@ -192,8 +192,7 @@ ecma_builtin_date_prototype_dispatch_get (uint16_t builtin_routine_id, /**< buil
|
||||
{
|
||||
if (ecma_number_is_nan (date_num))
|
||||
{
|
||||
ecma_string_t *nan_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAN);
|
||||
return ecma_make_string_value (nan_str_p);
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
|
||||
}
|
||||
|
||||
switch (builtin_routine_id)
|
||||
@@ -624,8 +623,7 @@ ecma_builtin_date_prototype_dispatch_routine (uint16_t builtin_routine_id, /**<
|
||||
|
||||
if (ecma_number_is_nan (*prim_value_p))
|
||||
{
|
||||
ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INVALID_DATE_UL);
|
||||
return ecma_make_string_value (magic_str_p);
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING_INVALID_DATE_UL);
|
||||
}
|
||||
|
||||
switch (builtin_routine_id)
|
||||
|
||||
@@ -74,9 +74,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
|
||||
|
||||
if (ecma_is_value_undefined (name_get_ret_value))
|
||||
{
|
||||
ecma_string_t *error_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_ERROR_UL);
|
||||
|
||||
name_to_str_completion = ecma_make_string_value (error_magic_string_p);
|
||||
name_to_str_completion = ecma_make_magic_string_value (LIT_MAGIC_STRING_ERROR_UL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,9 +95,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
|
||||
|
||||
if (ecma_is_value_undefined (msg_get_ret_value))
|
||||
{
|
||||
ecma_string_t *empty_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
msg_to_str_completion = ecma_make_string_value (empty_magic_string_p);
|
||||
msg_to_str_completion = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -68,8 +68,7 @@ ecma_builtin_function_prototype_object_to_string (ecma_value_t this_arg) /**< th
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *function_to_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__FUNCTION_TO_STRING);
|
||||
ret_value = ecma_make_string_value (function_to_string_p);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__FUNCTION_TO_STRING);
|
||||
}
|
||||
return ret_value;
|
||||
} /* ecma_builtin_function_prototype_object_to_string */
|
||||
|
||||
@@ -72,7 +72,7 @@ ecma_builtin_function_helper_get_function_arguments (const ecma_value_t *argumen
|
||||
|
||||
if (arguments_list_len <= 1)
|
||||
{
|
||||
return ecma_make_string_value (ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY));
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
|
||||
ecma_value_t final_str = ecma_op_to_string (arguments_list_p[0]);
|
||||
@@ -146,7 +146,7 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p,
|
||||
else
|
||||
{
|
||||
/* Very unlikely code path, not optimized. */
|
||||
function_body_value = ecma_make_string_value (ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY));
|
||||
function_body_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
|
||||
ecma_string_t *arguments_str_p = ecma_get_string_from_value (arguments_value);
|
||||
|
||||
@@ -207,7 +207,6 @@ ecma_builtin_helper_json_create_non_formatted_json (lit_utf8_byte_t left_bracket
|
||||
|
||||
/* 10.a.i */
|
||||
properties_str_p = ecma_builtin_helper_json_create_separated_properties (partial_p, comma_str_p);
|
||||
ecma_deref_ecma_string (comma_str_p);
|
||||
|
||||
/* 10.a.ii */
|
||||
ecma_string_t *result_str_p = ecma_new_ecma_string_from_code_unit (left_bracket);
|
||||
|
||||
@@ -131,8 +131,7 @@ ecma_builtin_helper_get_to_locale_string_at_index (ecma_object_t *obj_p, /**< th
|
||||
|
||||
if (ecma_is_value_undefined (index_value) || ecma_is_value_null (index_value))
|
||||
{
|
||||
ecma_string_t *return_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
ret_value = ecma_make_string_value (return_string_p);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -856,11 +856,10 @@ ecma_builtin_json_parse (ecma_value_t this_arg, /**< 'this' argument */
|
||||
if (ecma_op_is_callable (arg2))
|
||||
{
|
||||
ecma_object_t *object_p = ecma_op_create_object_object_noarg ();
|
||||
ecma_string_t *name_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
ecma_property_value_t *prop_value_p;
|
||||
prop_value_p = ecma_create_named_data_property (object_p,
|
||||
name_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY),
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
NULL);
|
||||
|
||||
@@ -869,9 +868,8 @@ ecma_builtin_json_parse (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
ret_value = ecma_builtin_json_walk (ecma_get_object_from_value (arg2),
|
||||
object_p,
|
||||
name_p);
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY));
|
||||
ecma_deref_object (object_p);
|
||||
ecma_deref_ecma_string (name_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1143,7 +1141,6 @@ ecma_builtin_json_stringify (ecma_value_t this_arg, /**< 'this' argument */
|
||||
ECMA_FINALIZE (str_val);
|
||||
|
||||
ecma_deref_object (obj_wrapper_p);
|
||||
ecma_deref_ecma_string (empty_str_p);
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (context.gap_str_p);
|
||||
@@ -1413,8 +1410,7 @@ ecma_builtin_json_str (ecma_string_t *key_p, /**< property key*/
|
||||
else
|
||||
{
|
||||
/* 9.b */
|
||||
ecma_string_t *null_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NULL);
|
||||
ret_value = ecma_make_string_value (null_str_p);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_NULL);
|
||||
}
|
||||
}
|
||||
/* 10. */
|
||||
@@ -1695,9 +1691,7 @@ ecma_builtin_json_array (ecma_object_t *obj_p, /**< the array object*/
|
||||
/* 8.b */
|
||||
if (ecma_is_value_undefined (str_val))
|
||||
{
|
||||
ecma_string_t *null_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NULL);
|
||||
ecma_append_to_values_collection (partial_p, ecma_make_string_value (null_str_p), 0);
|
||||
ecma_deref_ecma_string (null_str_p);
|
||||
ecma_append_to_values_collection (partial_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_NULL), 0);
|
||||
}
|
||||
/* 8.c */
|
||||
else
|
||||
|
||||
@@ -590,8 +590,7 @@ ecma_builtin_number_prototype_object_to_fixed (ecma_value_t this_arg, /**< this
|
||||
/* 4. */
|
||||
if (ecma_number_is_nan (this_num))
|
||||
{
|
||||
ecma_string_t *nan_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAN);
|
||||
ret_value = ecma_make_string_value (nan_str_p);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -609,7 +608,7 @@ ecma_builtin_number_prototype_object_to_fixed (ecma_value_t this_arg, /**< this
|
||||
lit_magic_string_id_t id = (is_negative ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL
|
||||
: LIT_MAGIC_STRING_INFINITY_UL);
|
||||
|
||||
ret_value = ecma_make_string_value (ecma_get_magic_string (id));
|
||||
ret_value = ecma_make_magic_string_value (id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -721,8 +720,7 @@ ecma_builtin_number_prototype_object_to_exponential (ecma_value_t this_arg, /**<
|
||||
/* 3. */
|
||||
if (ecma_number_is_nan (this_num))
|
||||
{
|
||||
ecma_string_t *nan_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAN);
|
||||
ret_value = ecma_make_string_value (nan_str_p);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -740,7 +738,7 @@ ecma_builtin_number_prototype_object_to_exponential (ecma_value_t this_arg, /**<
|
||||
lit_magic_string_id_t id = (is_negative ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL
|
||||
: LIT_MAGIC_STRING_INFINITY_UL);
|
||||
|
||||
ret_value = ecma_make_string_value (ecma_get_magic_string (id));
|
||||
ret_value = ecma_make_magic_string_value (id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -858,8 +856,7 @@ ecma_builtin_number_prototype_object_to_precision (ecma_value_t this_arg, /**< t
|
||||
/* 4. */
|
||||
if (ecma_number_is_nan (this_num))
|
||||
{
|
||||
ecma_string_t *nan_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAN);
|
||||
ret_value = ecma_make_string_value (nan_str_p);
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -877,7 +874,7 @@ ecma_builtin_number_prototype_object_to_precision (ecma_value_t this_arg, /**< t
|
||||
lit_magic_string_id_t id = (is_negative ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL
|
||||
: LIT_MAGIC_STRING_INFINITY_UL);
|
||||
|
||||
ret_value = ecma_make_string_value (ecma_get_magic_string (id));
|
||||
ret_value = ecma_make_magic_string_value (id);
|
||||
}
|
||||
/* 8. */
|
||||
else if (arg_num < 1.0 || arg_num >= 22.0)
|
||||
|
||||
@@ -79,19 +79,18 @@ ecma_builtin_promise_reject_or_resolve (ecma_value_t this_arg, /**< "this" argum
|
||||
return capability;
|
||||
}
|
||||
|
||||
ecma_string_t *str;
|
||||
ecma_string_t *property_str_p;
|
||||
|
||||
if (is_resolve)
|
||||
{
|
||||
str = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
|
||||
property_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
|
||||
property_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
|
||||
}
|
||||
|
||||
ecma_value_t func = ecma_op_object_get (ecma_get_object_from_value (capability), str);
|
||||
ecma_deref_ecma_string (str);
|
||||
ecma_value_t func = ecma_op_object_get (ecma_get_object_from_value (capability), property_str_p);
|
||||
|
||||
ecma_value_t call_ret = ecma_op_function_call (ecma_get_object_from_value (func),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
@@ -107,9 +106,8 @@ ecma_builtin_promise_reject_or_resolve (ecma_value_t this_arg, /**< "this" argum
|
||||
|
||||
ecma_free_value (call_ret);
|
||||
|
||||
ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
|
||||
ecma_value_t promise_new = ecma_op_object_get (ecma_get_object_from_value (capability), str_promise);
|
||||
ecma_deref_ecma_string (str_promise);
|
||||
ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
|
||||
ecma_value_t promise_new = ecma_op_object_get (ecma_get_object_from_value (capability), promise_str_p);
|
||||
ecma_free_value (capability);
|
||||
|
||||
return promise_new;
|
||||
@@ -128,9 +126,8 @@ inline static ecma_value_t
|
||||
ecma_builtin_promise_reject_abrupt (ecma_value_t capability) /**< reject description */
|
||||
{
|
||||
ecma_value_t reason = JERRY_CONTEXT (error_value);
|
||||
ecma_string_t *str_reject = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
|
||||
ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability), str_reject);
|
||||
ecma_deref_ecma_string (str_reject);
|
||||
ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
|
||||
ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability), reject_str_p);
|
||||
|
||||
ecma_value_t call_ret = ecma_op_function_call (ecma_get_object_from_value (reject),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
@@ -145,9 +142,8 @@ ecma_builtin_promise_reject_abrupt (ecma_value_t capability) /**< reject descrip
|
||||
|
||||
ecma_free_value (call_ret);
|
||||
|
||||
ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
|
||||
ecma_value_t promise_new = ecma_op_object_get (ecma_get_object_from_value (capability), str_promise);
|
||||
ecma_deref_ecma_string (str_promise);
|
||||
ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
|
||||
ecma_value_t promise_new = ecma_op_object_get (ecma_get_object_from_value (capability), promise_str_p);
|
||||
|
||||
return promise_new;
|
||||
} /* ecma_builtin_promise_reject_abrupt */
|
||||
@@ -210,28 +206,28 @@ ecma_builtin_promise_do_race (ecma_value_t array, /**< the array for race */
|
||||
ecma_length_t len = (ecma_length_t) ecma_get_integer_from_value (len_value);
|
||||
ecma_fast_free_value (len_value);
|
||||
|
||||
ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
|
||||
ecma_string_t *str_resolve = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
|
||||
ecma_string_t *str_reject = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
|
||||
ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
|
||||
ecma_string_t *resolve_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
|
||||
ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
|
||||
|
||||
ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability),
|
||||
str_resolve);
|
||||
resolve_str_p);
|
||||
ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability),
|
||||
str_reject);
|
||||
reject_str_p);
|
||||
|
||||
for (ecma_length_t index = 0; index <= len; index++)
|
||||
{
|
||||
/* b-d. */
|
||||
if (index == len)
|
||||
{
|
||||
ret = ecma_op_object_get (ecma_get_object_from_value (capability), str_promise);
|
||||
ret = ecma_op_object_get (ecma_get_object_from_value (capability), promise_str_p);
|
||||
break;
|
||||
}
|
||||
|
||||
/* e. */
|
||||
ecma_string_t *str_index = ecma_new_ecma_string_from_uint32 (index);
|
||||
ecma_value_t array_item = ecma_op_object_get (array_p, str_index);
|
||||
ecma_deref_ecma_string (str_index);
|
||||
ecma_string_t *index_to_str_p = ecma_new_ecma_string_from_uint32 (index);
|
||||
ecma_value_t array_item = ecma_op_object_get (array_p, index_to_str_p);
|
||||
ecma_deref_ecma_string (index_to_str_p);
|
||||
|
||||
/* h. */
|
||||
ecma_value_t next_promise = ecma_builtin_promise_resolve (ctor, array_item);
|
||||
@@ -260,9 +256,6 @@ ecma_builtin_promise_do_race (ecma_value_t array, /**< the array for race */
|
||||
|
||||
ecma_free_value (reject);
|
||||
ecma_free_value (resolve);
|
||||
ecma_deref_ecma_string (str_promise);
|
||||
ecma_deref_ecma_string (str_resolve);
|
||||
ecma_deref_ecma_string (str_reject);
|
||||
|
||||
JERRY_ASSERT (!ecma_is_value_empty (ret));
|
||||
|
||||
@@ -323,8 +316,8 @@ ecma_builtin_promise_all_handler (const ecma_value_t function, /**< the function
|
||||
ecma_value_t ret = ECMA_VALUE_UNDEFINED;
|
||||
/* 1. */
|
||||
ecma_object_t *function_p = ecma_get_object_from_value (function);
|
||||
ecma_string_t *str_already_called = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_ALREADY_CALLED);
|
||||
ecma_value_t already_called = ecma_op_object_get (function_p, str_already_called);
|
||||
ecma_string_t *already_called_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_ALREADY_CALLED);
|
||||
ecma_value_t already_called = ecma_op_object_get (function_p, already_called_str_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (already_called));
|
||||
|
||||
@@ -332,46 +325,43 @@ ecma_builtin_promise_all_handler (const ecma_value_t function, /**< the function
|
||||
if (ecma_is_value_true (already_called))
|
||||
{
|
||||
ecma_fast_free_value (already_called);
|
||||
ecma_deref_ecma_string (str_already_called);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 3. */
|
||||
ecma_op_object_put (function_p,
|
||||
str_already_called,
|
||||
already_called_str_p,
|
||||
ecma_make_boolean_value (true),
|
||||
false);
|
||||
|
||||
ecma_string_t *str_index = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_INDEX);
|
||||
ecma_string_t *str_value = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_VALUE);
|
||||
ecma_string_t *str_capability = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
|
||||
ecma_string_t *str_remaining = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REMAINING_ELEMENT);
|
||||
ecma_string_t *str_index_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_INDEX);
|
||||
ecma_string_t *str_value_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_VALUE);
|
||||
ecma_string_t *str_capability_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
|
||||
ecma_string_t *str_remaining_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REMAINING_ELEMENT);
|
||||
|
||||
/* 4-7. */
|
||||
ecma_value_t index_val = ecma_op_object_get (function_p, str_index);
|
||||
ecma_value_t value_array = ecma_op_object_get (function_p, str_value);
|
||||
ecma_value_t capability = ecma_op_object_get (function_p, str_capability);
|
||||
ecma_value_t remaining = ecma_op_object_get (function_p, str_remaining);
|
||||
ecma_value_t index_val = ecma_op_object_get (function_p, str_index_p);
|
||||
ecma_value_t value_array = ecma_op_object_get (function_p, str_value_p);
|
||||
ecma_value_t capability = ecma_op_object_get (function_p, str_capability_p);
|
||||
ecma_value_t remaining = ecma_op_object_get (function_p, str_remaining_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_integer_number (index_val));
|
||||
|
||||
/* 8. */
|
||||
ecma_string_t *index_str = ecma_new_ecma_string_from_uint32 ((uint32_t) ecma_get_integer_from_value (index_val));
|
||||
ecma_string_t *index_to_str_p = ecma_new_ecma_string_from_uint32 ((uint32_t) ecma_get_integer_from_value (index_val));
|
||||
|
||||
ecma_op_object_put (ecma_get_object_from_value (value_array),
|
||||
index_str,
|
||||
index_to_str_p,
|
||||
argv[0],
|
||||
false);
|
||||
ecma_deref_ecma_string (index_str);
|
||||
ecma_deref_ecma_string (index_to_str_p);
|
||||
|
||||
/* 9-10. */
|
||||
if (ecma_builtin_promise_remaining_inc_or_dec (remaining, false) == 0)
|
||||
{
|
||||
ecma_string_t *str_resolve = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
|
||||
ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability),
|
||||
str_resolve);
|
||||
ecma_deref_ecma_string (str_resolve);
|
||||
ecma_string_t *resolve_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
|
||||
ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability), resolve_str_p);
|
||||
|
||||
ret = ecma_op_function_call (ecma_get_object_from_value (resolve),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
&value_array,
|
||||
@@ -384,11 +374,6 @@ ecma_builtin_promise_all_handler (const ecma_value_t function, /**< the function
|
||||
ecma_free_value (value_array);
|
||||
ecma_fast_free_value (index_val);
|
||||
ecma_fast_free_value (already_called);
|
||||
ecma_deref_ecma_string (str_already_called);
|
||||
ecma_deref_ecma_string (str_index);
|
||||
ecma_deref_ecma_string (str_value);
|
||||
ecma_deref_ecma_string (str_capability);
|
||||
ecma_deref_ecma_string (str_remaining);
|
||||
|
||||
return ret;
|
||||
} /* ecma_builtin_promise_all_handler */
|
||||
@@ -419,21 +404,21 @@ ecma_builtin_promise_do_all (ecma_value_t array, /**< the array for all */
|
||||
ecma_length_t len = (ecma_length_t) ecma_get_integer_from_value (len_value);
|
||||
ecma_fast_free_value (len_value);
|
||||
|
||||
ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
|
||||
ecma_string_t *str_resolve = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
|
||||
ecma_string_t *str_reject = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
|
||||
ecma_string_t *str_already_called = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_ALREADY_CALLED);
|
||||
ecma_string_t *str_index = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_INDEX);
|
||||
ecma_string_t *str_value = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_VALUE);
|
||||
ecma_string_t *str_capability = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
|
||||
ecma_string_t *str_remaining = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REMAINING_ELEMENT);
|
||||
ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
|
||||
ecma_string_t *resolve_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
|
||||
ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
|
||||
ecma_string_t *already_called_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_ALREADY_CALLED);
|
||||
ecma_string_t *index_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_INDEX);
|
||||
ecma_string_t *value_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_VALUE);
|
||||
ecma_string_t *capability_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
|
||||
ecma_string_t *remaining_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REMAINING_ELEMENT);
|
||||
|
||||
ecma_value_t undefined_val = ECMA_VALUE_UNDEFINED;
|
||||
/* String '1' indicates [[Resolve]] and '2' indicates [[Reject]]. */
|
||||
ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability),
|
||||
str_resolve);
|
||||
resolve_str_p);
|
||||
ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability),
|
||||
str_reject);
|
||||
reject_str_p);
|
||||
/* 3. */
|
||||
ecma_value_t result_array_length_val = ecma_make_uint32_value (0);
|
||||
ecma_value_t value_array = ecma_op_create_array_object (&result_array_length_val, 1, true);
|
||||
@@ -467,18 +452,18 @@ ecma_builtin_promise_do_all (ecma_value_t array, /**< the array for all */
|
||||
}
|
||||
|
||||
/* iv. */
|
||||
ret = ecma_op_object_get (ecma_get_object_from_value (capability), str_promise);
|
||||
ret = ecma_op_object_get (ecma_get_object_from_value (capability), promise_str_p);
|
||||
break;
|
||||
}
|
||||
|
||||
/* e. h. */
|
||||
ecma_string_t *index_str = ecma_new_ecma_string_from_uint32 (index);
|
||||
ecma_value_t array_item = ecma_op_object_get (array_p, index_str);
|
||||
ecma_string_t *index_to_str_p = ecma_new_ecma_string_from_uint32 (index);
|
||||
ecma_value_t array_item = ecma_op_object_get (array_p, index_to_str_p);
|
||||
ecma_op_object_put (ecma_get_object_from_value (value_array),
|
||||
index_str,
|
||||
index_to_str_p,
|
||||
undefined_val,
|
||||
false);
|
||||
ecma_deref_ecma_string (index_str);
|
||||
ecma_deref_ecma_string (index_to_str_p);
|
||||
/* i. */
|
||||
ecma_value_t next_promise = ecma_builtin_promise_resolve (ctor, array_item);
|
||||
ecma_free_value (array_item);
|
||||
@@ -495,27 +480,27 @@ ecma_builtin_promise_do_all (ecma_value_t array, /**< the array for all */
|
||||
res_ele_p = ecma_op_create_external_function_object (ecma_builtin_promise_all_handler);
|
||||
/* l. */
|
||||
ecma_op_object_put (res_ele_p,
|
||||
str_already_called,
|
||||
already_called_str_p,
|
||||
ecma_make_boolean_value (false),
|
||||
false);
|
||||
/* m. */
|
||||
ecma_op_object_put (res_ele_p,
|
||||
str_index,
|
||||
index_str_p,
|
||||
ecma_make_uint32_value (index),
|
||||
false);
|
||||
/* n. */
|
||||
ecma_op_object_put (res_ele_p,
|
||||
str_value,
|
||||
value_str_p,
|
||||
value_array,
|
||||
false);
|
||||
/* o. */
|
||||
ecma_op_object_put (res_ele_p,
|
||||
str_capability,
|
||||
capability_str_p,
|
||||
capability,
|
||||
false);
|
||||
/* p. */
|
||||
ecma_op_object_put (res_ele_p,
|
||||
str_remaining,
|
||||
remaining_str_p,
|
||||
remaining,
|
||||
false);
|
||||
|
||||
@@ -543,14 +528,6 @@ ecma_builtin_promise_do_all (ecma_value_t array, /**< the array for all */
|
||||
ecma_free_value (resolve);
|
||||
ecma_free_value (remaining);
|
||||
ecma_free_value (value_array);
|
||||
ecma_deref_ecma_string (str_already_called);
|
||||
ecma_deref_ecma_string (str_index);
|
||||
ecma_deref_ecma_string (str_value);
|
||||
ecma_deref_ecma_string (str_capability);
|
||||
ecma_deref_ecma_string (str_remaining);
|
||||
ecma_deref_ecma_string (str_resolve);
|
||||
ecma_deref_ecma_string (str_reject);
|
||||
ecma_deref_ecma_string (str_promise);
|
||||
|
||||
JERRY_ASSERT (!ecma_is_value_empty (ret));
|
||||
|
||||
|
||||
@@ -89,13 +89,11 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this argument
|
||||
/* Get source. */
|
||||
ecma_string_t *magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SOURCE);
|
||||
ecma_value_t source_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p);
|
||||
ecma_deref_ecma_string (magic_string_p);
|
||||
ecma_string_t *pattern_string_p = ecma_get_string_from_value (source_value);
|
||||
|
||||
/* Get flags. */
|
||||
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL);
|
||||
ecma_value_t global_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p);
|
||||
ecma_deref_ecma_string (magic_string_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (global_value));
|
||||
|
||||
@@ -106,7 +104,6 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this argument
|
||||
|
||||
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_IGNORECASE_UL);
|
||||
ecma_value_t ignore_case_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p);
|
||||
ecma_deref_ecma_string (magic_string_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ignore_case_value));
|
||||
|
||||
@@ -117,7 +114,6 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this argument
|
||||
|
||||
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MULTILINE);
|
||||
ecma_value_t multiline_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p);
|
||||
ecma_deref_ecma_string (magic_string_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (multiline_value));
|
||||
|
||||
@@ -280,15 +276,11 @@ ecma_builtin_regexp_prototype_exec (ecma_value_t this_arg, /**< this argument */
|
||||
if (bytecode_p == NULL)
|
||||
{
|
||||
/* Missing bytecode means empty RegExp: '/(?:)/', so always return empty string. */
|
||||
ecma_string_t *capture_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
ecma_value_t arguments_list[1];
|
||||
arguments_list[0] = ecma_make_string_value (capture_str_p);
|
||||
arguments_list[0] = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
ret_value = ecma_op_create_array_object (arguments_list, 1, false);
|
||||
|
||||
ecma_deref_ecma_string (capture_str_p);
|
||||
|
||||
re_set_result_array_properties (ecma_get_object_from_value (ret_value),
|
||||
ecma_get_string_from_value (input_str_value),
|
||||
1,
|
||||
@@ -364,7 +356,6 @@ ecma_builtin_regexp_prototype_to_string (ecma_value_t this_arg) /**< this argume
|
||||
/* Get RegExp source from the source property */
|
||||
ecma_string_t *magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SOURCE);
|
||||
ecma_value_t source_value = ecma_op_object_get_own_data_prop (obj_p, magic_string_p);
|
||||
ecma_deref_ecma_string (magic_string_p);
|
||||
|
||||
ecma_string_t *output_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_SLASH_CHAR);
|
||||
ecma_string_t *source_str_p = ecma_get_string_from_value (source_value);
|
||||
@@ -379,7 +370,6 @@ ecma_builtin_regexp_prototype_to_string (ecma_value_t this_arg) /**< this argume
|
||||
/* Check the global flag */
|
||||
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL);
|
||||
ecma_value_t global_value = ecma_op_object_get_own_data_prop (obj_p, magic_string_p);
|
||||
ecma_deref_ecma_string (magic_string_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (global_value));
|
||||
|
||||
@@ -391,7 +381,6 @@ ecma_builtin_regexp_prototype_to_string (ecma_value_t this_arg) /**< this argume
|
||||
/* Check the ignoreCase flag */
|
||||
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_IGNORECASE_UL);
|
||||
ecma_value_t ignore_case_value = ecma_op_object_get_own_data_prop (obj_p, magic_string_p);
|
||||
ecma_deref_ecma_string (magic_string_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ignore_case_value));
|
||||
|
||||
@@ -403,7 +392,6 @@ ecma_builtin_regexp_prototype_to_string (ecma_value_t this_arg) /**< this argume
|
||||
/* Check the multiline flag */
|
||||
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MULTILINE);
|
||||
ecma_value_t multiline_value = ecma_op_object_get_own_data_prop (obj_p, magic_string_p);
|
||||
ecma_deref_ecma_string (magic_string_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (multiline_value));
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ ecma_builtin_string_prototype_object_char_at (ecma_value_t this_arg, /**< this a
|
||||
/* 5 */
|
||||
if (index_num < 0 || index_num >= len || !len)
|
||||
{
|
||||
ret_value = ecma_make_string_value (ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY));
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -446,13 +446,11 @@ ecma_builtin_string_prototype_object_match (ecma_value_t this_arg, /**< this arg
|
||||
else
|
||||
{
|
||||
/* 8.a. */
|
||||
ecma_string_t *index_zero_string_p = ecma_new_ecma_string_from_uint32 (0);
|
||||
|
||||
ecma_string_t *last_index_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
|
||||
ecma_string_t *index_zero_string_p = ecma_get_ecma_string_from_uint32 (0);
|
||||
|
||||
ECMA_TRY_CATCH (put_value,
|
||||
ecma_op_object_put (regexp_obj_p,
|
||||
last_index_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
|
||||
ecma_make_integer_value (0),
|
||||
true),
|
||||
ret_value);
|
||||
@@ -503,7 +501,7 @@ ecma_builtin_string_prototype_object_match (ecma_value_t this_arg, /**< this arg
|
||||
/* 8.f.iii.2.a. */
|
||||
ECMA_TRY_CATCH (index_put_value,
|
||||
ecma_op_object_put (regexp_obj_p,
|
||||
last_index_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
|
||||
ecma_make_number_value (this_index + 1),
|
||||
true),
|
||||
ret_value);
|
||||
@@ -575,9 +573,6 @@ ecma_builtin_string_prototype_object_match (ecma_value_t this_arg, /**< this arg
|
||||
ECMA_FINALIZE (new_array_value);
|
||||
|
||||
ECMA_FINALIZE (put_value);
|
||||
|
||||
ecma_deref_ecma_string (last_index_string_p);
|
||||
ecma_deref_ecma_string (index_zero_string_p);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (global_value);
|
||||
@@ -671,14 +666,12 @@ ecma_builtin_string_prototype_object_replace_match (ecma_builtin_replace_search_
|
||||
JERRY_ASSERT (ecma_is_value_object (match_value));
|
||||
|
||||
ecma_object_t *match_object_p = ecma_get_object_from_value (match_value);
|
||||
ecma_string_t *zero_string_p = ecma_new_ecma_string_from_uint32 (0);
|
||||
|
||||
ECMA_TRY_CATCH (index_value,
|
||||
ecma_op_object_get_by_magic_id (match_object_p, LIT_MAGIC_STRING_INDEX),
|
||||
ret_value);
|
||||
|
||||
ECMA_TRY_CATCH (result_string_value,
|
||||
ecma_op_object_get (match_object_p, zero_string_p),
|
||||
ecma_op_object_get (match_object_p, ecma_get_ecma_string_from_uint32 (0)),
|
||||
ret_value);
|
||||
|
||||
/* We directly call the built-in exec, so
|
||||
@@ -701,8 +694,6 @@ ecma_builtin_string_prototype_object_replace_match (ecma_builtin_replace_search_
|
||||
|
||||
ECMA_FINALIZE (result_string_value);
|
||||
ECMA_FINALIZE (index_value);
|
||||
|
||||
ecma_deref_ecma_string (zero_string_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1082,18 +1073,16 @@ ecma_builtin_string_prototype_object_replace_loop (ecma_builtin_replace_search_c
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *last_index_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
|
||||
ecma_object_t *regexp_obj_p = ecma_get_object_from_value (context_p->regexp_or_search_string);
|
||||
|
||||
ECMA_TRY_CATCH (put_value,
|
||||
ecma_op_object_put (regexp_obj_p,
|
||||
last_index_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
|
||||
ecma_make_uint32_value (context_p->match_end + 1),
|
||||
true),
|
||||
ret_value);
|
||||
|
||||
ECMA_FINALIZE (put_value);
|
||||
ecma_deref_ecma_string (last_index_string_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1244,17 +1233,14 @@ ecma_builtin_string_prototype_object_replace (ecma_value_t this_arg, /**< this a
|
||||
|
||||
if (context.is_global)
|
||||
{
|
||||
ecma_string_t *last_index_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
|
||||
|
||||
ECMA_TRY_CATCH (put_value,
|
||||
ecma_op_object_put (regexp_obj_p,
|
||||
last_index_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
|
||||
ecma_make_integer_value (0),
|
||||
true),
|
||||
ret_value);
|
||||
|
||||
ECMA_FINALIZE (put_value);
|
||||
ecma_deref_ecma_string (last_index_string_p);
|
||||
}
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
@@ -1554,9 +1540,10 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_arg, /**< this arg
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
|
||||
ecma_value_t regexp_value = ecma_copy_value_if_not_object (separator);
|
||||
ecma_string_t *substr_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
ecma_value_t match_result;
|
||||
match_result = ecma_regexp_exec_helper (regexp_value, ecma_make_string_value (substr_str_p), true);
|
||||
match_result = ecma_regexp_exec_helper (regexp_value,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY),
|
||||
true);
|
||||
should_return = !ecma_is_value_null (match_result);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (match_result))
|
||||
@@ -1564,7 +1551,6 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_arg, /**< this arg
|
||||
match_result = JERRY_CONTEXT (error_value);
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (substr_str_p);
|
||||
ecma_free_value (match_result);
|
||||
#else
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("REGEXP separator is disabled in split method."));
|
||||
@@ -1663,11 +1649,10 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_arg, /**< this arg
|
||||
else
|
||||
{
|
||||
ecma_object_t *match_obj_p = ecma_get_object_from_value (match_result);
|
||||
ecma_string_t *zero_str_p = ecma_new_ecma_string_from_uint32 (0);
|
||||
ecma_string_t *zero_str_p = ecma_get_ecma_string_from_uint32 (0);
|
||||
ecma_string_t *magic_index_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX);
|
||||
ecma_property_value_t *index_prop_value_p;
|
||||
|
||||
|
||||
if (separator_is_regexp)
|
||||
{
|
||||
index_prop_value_p = ecma_get_named_data_property (match_obj_p, magic_index_str_p);
|
||||
@@ -1691,26 +1676,21 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_arg, /**< this arg
|
||||
magic_index_str_p,
|
||||
ECMA_PROPERTY_FLAG_WRITABLE,
|
||||
NULL);
|
||||
|
||||
ecma_named_data_property_assign_value (match_obj_p,
|
||||
index_prop_value_p,
|
||||
ecma_make_uint32_value (curr_pos));
|
||||
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (magic_index_str_p);
|
||||
|
||||
ecma_value_t match_comp_value = ecma_op_object_get (match_obj_p, zero_str_p);
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (match_comp_value));
|
||||
|
||||
ecma_string_t *match_str_p = ecma_get_string_from_value (match_comp_value);
|
||||
ecma_length_t match_str_length = ecma_string_get_length (match_str_p);
|
||||
|
||||
ecma_string_t *magic_empty_str_p = ecma_new_ecma_string_from_magic_string_id (LIT_MAGIC_STRING__EMPTY);
|
||||
separator_is_empty = ecma_compare_ecma_strings (magic_empty_str_p, match_str_p);
|
||||
separator_is_empty = ecma_string_is_empty (match_str_p);
|
||||
|
||||
ecma_deref_ecma_string (magic_empty_str_p);
|
||||
ecma_free_value (match_comp_value);
|
||||
ecma_deref_ecma_string (zero_str_p);
|
||||
|
||||
ecma_number_t index_num = ecma_get_number_from_value (index_prop_value_p->value);
|
||||
JERRY_ASSERT (index_num >= 0);
|
||||
|
||||
@@ -59,47 +59,45 @@ ecma_builtin_string_object_from_char_code (ecma_value_t this_arg, /**< 'this' ar
|
||||
ecma_length_t args_number) /**< number of arguments */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
ecma_string_t *ret_string_p = NULL;
|
||||
|
||||
if (args_number == 0)
|
||||
{
|
||||
ret_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
else
|
||||
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
ecma_string_t *ret_string_p = NULL;
|
||||
lit_utf8_size_t utf8_buf_size = args_number * LIT_CESU8_MAX_BYTES_IN_CODE_UNIT;
|
||||
|
||||
JMEM_DEFINE_LOCAL_ARRAY (utf8_buf_p,
|
||||
utf8_buf_size,
|
||||
lit_utf8_byte_t);
|
||||
|
||||
lit_utf8_size_t utf8_buf_used = 0;
|
||||
|
||||
for (ecma_length_t arg_index = 0;
|
||||
arg_index < args_number && ecma_is_value_empty (ret_value);
|
||||
arg_index++)
|
||||
{
|
||||
lit_utf8_size_t utf8_buf_size = args_number * LIT_CESU8_MAX_BYTES_IN_CODE_UNIT;
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, args[arg_index], ret_value);
|
||||
|
||||
JMEM_DEFINE_LOCAL_ARRAY (utf8_buf_p,
|
||||
utf8_buf_size,
|
||||
lit_utf8_byte_t);
|
||||
uint32_t uint32_char_code = ecma_number_to_uint32 (arg_num);
|
||||
ecma_char_t code_unit = (uint16_t) uint32_char_code;
|
||||
|
||||
lit_utf8_size_t utf8_buf_used = 0;
|
||||
JERRY_ASSERT (utf8_buf_used <= utf8_buf_size - LIT_UTF8_MAX_BYTES_IN_CODE_UNIT);
|
||||
utf8_buf_used += lit_code_unit_to_utf8 (code_unit, utf8_buf_p + utf8_buf_used);
|
||||
JERRY_ASSERT (utf8_buf_used <= utf8_buf_size);
|
||||
|
||||
for (ecma_length_t arg_index = 0;
|
||||
arg_index < args_number && ecma_is_value_empty (ret_value);
|
||||
arg_index++)
|
||||
{
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, args[arg_index], ret_value);
|
||||
|
||||
uint32_t uint32_char_code = ecma_number_to_uint32 (arg_num);
|
||||
ecma_char_t code_unit = (uint16_t) uint32_char_code;
|
||||
|
||||
JERRY_ASSERT (utf8_buf_used <= utf8_buf_size - LIT_UTF8_MAX_BYTES_IN_CODE_UNIT);
|
||||
utf8_buf_used += lit_code_unit_to_utf8 (code_unit, utf8_buf_p + utf8_buf_used);
|
||||
JERRY_ASSERT (utf8_buf_used <= utf8_buf_size);
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
}
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
ret_string_p = ecma_new_ecma_string_from_utf8 (utf8_buf_p, utf8_buf_used);
|
||||
}
|
||||
|
||||
JMEM_FINALIZE_LOCAL_ARRAY (utf8_buf_p);
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
}
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
ret_string_p = ecma_new_ecma_string_from_utf8 (utf8_buf_p, utf8_buf_used);
|
||||
}
|
||||
|
||||
JMEM_FINALIZE_LOCAL_ARRAY (utf8_buf_p);
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
ret_value = ecma_make_string_value (ret_string_p);
|
||||
@@ -123,10 +121,7 @@ ecma_builtin_string_dispatch_call (const ecma_value_t *arguments_list_p, /**< ar
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ecma_string_t *str_p = ecma_new_ecma_string_from_magic_string_id (LIT_MAGIC_STRING__EMPTY);
|
||||
ecma_value_t str_value = ecma_make_string_value (str_p);
|
||||
|
||||
ret_value = str_value;
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -223,8 +223,7 @@ ecma_builtin_init_object (ecma_builtin_id_t obj_builtin_id, /**< built-in ID */
|
||||
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;
|
||||
ecma_string_t *prim_prop_str_value_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
ext_object_p->u.class_prop.u.value = ecma_make_string_value (prim_prop_str_value_p);
|
||||
ext_object_p->u.class_prop.u.value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_STRING_BUILTIN */
|
||||
@@ -624,7 +623,7 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
}
|
||||
case ECMA_BUILTIN_PROPERTY_STRING:
|
||||
{
|
||||
value = ecma_make_string_value (ecma_get_magic_string (curr_property_p->value));
|
||||
value = ecma_make_magic_string_value (curr_property_p->value);
|
||||
break;
|
||||
}
|
||||
case ECMA_BUILTIN_PROPERTY_OBJECT:
|
||||
@@ -731,9 +730,9 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in
|
||||
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
|
||||
/* 'length' property is non-enumerable (ECMA-262 v5, 15) */
|
||||
ecma_string_t *name_p = ecma_new_ecma_length_string ();
|
||||
ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), 0);
|
||||
ecma_deref_ecma_string (name_p);
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -776,7 +775,9 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in
|
||||
|
||||
if (!(*bitset_p & bit_for_index) || ecma_op_object_has_own_property (object_p, name_p))
|
||||
{
|
||||
ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), 0);
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (curr_property_p->magic_string_id),
|
||||
0);
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (name_p);
|
||||
|
||||
Reference in New Issue
Block a user