Refactor ecma_op_to_string (#3171)

Similar to the ecma_op_to_object rework, in this new method we
return directly with the pointer to the ecma string, and we don't
wrap the result into an ecma_value_t

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2019-10-25 15:58:47 +02:00
committed by Robert Fancsik
parent b7aa21ebc7
commit 4b352758c1
25 changed files with 391 additions and 427 deletions
+3 -2
View File
@@ -292,10 +292,11 @@ static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< s
ecma_string_t *error_message_p = ecma_new_ecma_string_from_utf8 (error_prefix, sizeof (error_prefix) - 1);
literal = ecma_op_to_string (literal);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (literal));
ecma_string_t *literal_string_p = ecma_get_string_from_value (literal);
ecma_string_t *literal_string_p = ecma_op_to_string (literal);
JERRY_ASSERT (literal_string_p != NULL);
error_message_p = ecma_concat_ecma_strings (error_message_p, literal_string_p);
ecma_deref_ecma_string (literal_string_p);
+7 -1
View File
@@ -1288,7 +1288,13 @@ jerry_value_to_string (const jerry_value_t value) /**< input value */
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (error_value_msg_p)));
}
return jerry_return (ecma_op_to_string (value));
ecma_string_t *str_p = ecma_op_to_string (value);
if (JERRY_UNLIKELY (str_p == NULL))
{
return ecma_create_error_reference_from_context ();
}
return jerry_return (ecma_make_string_value (str_p));
} /* jerry_value_to_string */
/**