20 changes: 7 additions & 13 deletions jerry-core/parser/js/js-parser-module.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
const lexer_lit_location_t lexer_default_literal =
{
(const uint8_t *) "*default*", 9, LEXER_IDENT_LITERAL, false
(const uint8_t *) "*default*", 9, LEXER_IDENT_LITERAL, LEXER_LIT_LOCATION_IS_ASCII
};

/**
Expand Down Expand Up @@ -89,9 +89,7 @@ parser_module_append_export_name (parser_context_t *context_p) /**< parser conte
}

context_p->module_identifier_lit_p = context_p->lit_object.literal_p;

ecma_string_t *name_p = ecma_new_ecma_string_from_utf8 (context_p->lit_object.literal_p->u.char_p,
context_p->lit_object.literal_p->prop.length);
ecma_string_t *name_p = parser_new_ecma_string_from_literal (context_p->lit_object.literal_p);

if (parser_module_check_duplicate_export (context_p, name_p))
{
Expand Down Expand Up @@ -250,13 +248,11 @@ parser_module_parse_export_clause (parser_context_t *context_p) /**< parser cont
lexer_next_token (context_p);
}

lexer_literal_t *literal_p = PARSER_GET_LITERAL (local_name_index);
local_name_p = ecma_new_ecma_string_from_utf8 (literal_p->u.char_p, literal_p->prop.length);
local_name_p = parser_new_ecma_string_from_literal (PARSER_GET_LITERAL (local_name_index));

if (export_name_index != PARSER_MAXIMUM_NUMBER_OF_LITERALS)
{
lexer_literal_t *as_literal_p = PARSER_GET_LITERAL (export_name_index);
export_name_p = ecma_new_ecma_string_from_utf8 (as_literal_p->u.char_p, as_literal_p->prop.length);
export_name_p = parser_new_ecma_string_from_literal (PARSER_GET_LITERAL (export_name_index));
}
else
{
Expand Down Expand Up @@ -353,13 +349,11 @@ parser_module_parse_import_clause (parser_context_t *context_p) /**< parser cont
lexer_next_token (context_p);
}

lexer_literal_t *literal_p = PARSER_GET_LITERAL (import_name_index);
import_name_p = ecma_new_ecma_string_from_utf8 (literal_p->u.char_p, literal_p->prop.length);
import_name_p = parser_new_ecma_string_from_literal (PARSER_GET_LITERAL (import_name_index));

if (local_name_index != PARSER_MAXIMUM_NUMBER_OF_LITERALS)
{
lexer_literal_t *as_literal_p = PARSER_GET_LITERAL (local_name_index);
local_name_p = ecma_new_ecma_string_from_utf8 (as_literal_p->u.char_p, as_literal_p->prop.length);
local_name_p = parser_new_ecma_string_from_literal (PARSER_GET_LITERAL (local_name_index));
}
else
{
Expand Down Expand Up @@ -460,7 +454,7 @@ parser_module_handle_module_specifier (parser_context_t *context_p, /**< parser
lexer_next_token (context_p);

/* The lexer_next_token may throw an error, so the path is constructed after its call. */
ecma_string_t *path_string_p = ecma_new_ecma_string_from_utf8 (path_p->u.char_p, path_p->prop.length);
ecma_string_t *path_string_p = parser_new_ecma_string_from_literal (path_p);

ecma_module_node_t *node_p = JERRY_CONTEXT (module_current_p)->imports_p;
ecma_module_node_t *last_node_p = NULL;
Expand Down
17 changes: 7 additions & 10 deletions jerry-core/parser/js/js-parser-statm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */

if (context_p->token.type == LEXER_KEYW_AWAIT)
{
if (JERRY_UNLIKELY (context_p->token.lit_location.has_escape))
if (JERRY_UNLIKELY (context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE))
{
parser_raise_error (context_p, PARSER_ERR_INVALID_KEYWORD);
}
Expand All @@ -1188,7 +1188,7 @@ parser_parse_for_statement_start (parser_context_t *context_p) /**< context */
#if JERRY_ESNEXT
if (context_p->token.type == LEXER_LITERAL
&& context_p->token.keyword_type == LEXER_KEYW_AWAIT
&& !context_p->token.lit_location.has_escape)
&& !(context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE))
{
parser_raise_error (context_p, PARSER_ERR_FOR_AWAIT_NO_ASYNC);
}
Expand Down Expand Up @@ -2447,8 +2447,7 @@ parser_parse_import_statement (parser_context_t *context_p) /**< parser context
/* Handle ImportedDefaultBinding */
lexer_construct_literal_object (context_p, &context_p->token.lit_location, LEXER_IDENT_LITERAL);

ecma_string_t *local_name_p = ecma_new_ecma_string_from_utf8 (context_p->lit_object.literal_p->u.char_p,
context_p->lit_object.literal_p->prop.length);
ecma_string_t *local_name_p = parser_new_ecma_string_from_literal (context_p->lit_object.literal_p);

if (parser_module_check_duplicate_import (context_p, local_name_p))
{
Expand Down Expand Up @@ -2496,8 +2495,7 @@ parser_parse_import_statement (parser_context_t *context_p) /**< parser context

lexer_construct_literal_object (context_p, &context_p->token.lit_location, LEXER_IDENT_LITERAL);

ecma_string_t *local_name_p = ecma_new_ecma_string_from_utf8 (context_p->lit_object.literal_p->u.char_p,
context_p->lit_object.literal_p->prop.length);
ecma_string_t *local_name_p = parser_new_ecma_string_from_literal (context_p->lit_object.literal_p);

if (parser_module_check_duplicate_import (context_p, local_name_p))
{
Expand Down Expand Up @@ -2598,8 +2596,8 @@ parser_parse_export_statement (parser_context_t *context_p) /**< context */
parser_parse_expression_statement (context_p, PARSE_EXPR_NO_COMMA | PARSE_EXPR_HAS_LITERAL);
}

ecma_string_t *name_p = ecma_new_ecma_string_from_utf8 (context_p->module_identifier_lit_p->u.char_p,
context_p->module_identifier_lit_p->prop.length);
ecma_string_t *name_p = parser_new_ecma_string_from_literal (context_p->module_identifier_lit_p);

ecma_string_t *export_name_p = ecma_get_magic_string (LIT_MAGIC_STRING_DEFAULT);

if (parser_module_check_duplicate_export (context_p, export_name_p))
Expand Down Expand Up @@ -2637,8 +2635,7 @@ parser_parse_export_statement (parser_context_t *context_p) /**< context */
lexer_construct_literal_object (context_p, &context_p->token.lit_location, LEXER_NEW_IDENT_LITERAL);

lexer_literal_t *literal_p = PARSER_GET_LITERAL (context_p->lit_object.index);
ecma_string_t *export_name_p = ecma_new_ecma_string_from_utf8 (literal_p->u.char_p,
literal_p->prop.length);
ecma_string_t *export_name_p = parser_new_ecma_string_from_literal (literal_p);

if (parser_module_check_duplicate_export (context_p, export_name_p))
{
Expand Down
14 changes: 10 additions & 4 deletions jerry-core/parser/js/js-parser-tagged-template-literal.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ parser_tagged_template_literal_append_strings (parser_context_t *context_p, /**<
{
lexer_lit_location_t *lit_loc_p = &context_p->token.lit_location;

if (lit_loc_p->length == 0 && !lit_loc_p->has_escape)
if (lit_loc_p->length == 0 && !(lit_loc_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE))
{
ecma_builtin_helper_def_prop_by_index (template_obj_p,
prop_idx,
Expand All @@ -64,10 +64,13 @@ parser_tagged_template_literal_append_strings (parser_context_t *context_p, /**<
LEXER_STRING_NO_OPTS);

ecma_string_t *raw_str_p;
ecma_string_t *cooked_str_p = ecma_new_ecma_string_from_utf8 (source_p, lit_loc_p->length);
ecma_string_t *cooked_str_p = ((lit_loc_p->status_flags & LEXER_FLAG_ASCII)
? ecma_new_ecma_string_from_ascii (source_p, lit_loc_p->length)
: ecma_new_ecma_string_from_utf8 (source_p, lit_loc_p->length));

parser_free_allocated_buffer (context_p);

if (lit_loc_p->has_escape)
if (lit_loc_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)
{
context_p->source_p = context_p->token.lit_location.char_p - 1;
lexer_parse_string (context_p, LEXER_STRING_RAW);
Expand All @@ -76,7 +79,10 @@ parser_tagged_template_literal_append_strings (parser_context_t *context_p, /**<
local_byte_array,
LEXER_STRING_RAW);

raw_str_p = ecma_new_ecma_string_from_utf8 (source_p, lit_loc_p->length);
raw_str_p = ((lit_loc_p->status_flags & LEXER_FLAG_ASCII)
? ecma_new_ecma_string_from_ascii (source_p, lit_loc_p->length)
: ecma_new_ecma_string_from_utf8 (source_p, lit_loc_p->length));

parser_free_allocated_buffer (context_p);
}
else
Expand Down
25 changes: 25 additions & 0 deletions jerry-core/parser/js/js-parser-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#include "js-parser-internal.h"
#include "ecma-helpers.h"

#if JERRY_PARSER

Expand Down Expand Up @@ -650,6 +651,30 @@ parser_emit_cbc_backward_branch (parser_context_t *context_p, /**< context */
#undef PARSER_CHECK_LAST_POSITION
#undef PARSER_APPEND_TO_BYTE_CODE

/**
* Helper function for parser.
*
* @return a new string based on encode.
*/
ecma_string_t *
parser_new_ecma_string_from_literal (lexer_literal_t *literal_p) /**< literal */
{
JERRY_ASSERT (literal_p != NULL);

ecma_string_t *new_string = NULL;

if (literal_p->status_flags & LEXER_FLAG_ASCII)
{
new_string = ecma_new_ecma_string_from_ascii (literal_p->u.char_p, literal_p->prop.length);
}
else
{
new_string = ecma_new_ecma_string_from_utf8 (literal_p->u.char_p, literal_p->prop.length);
}

return new_string;
} /* parser_new_ecma_string_from_literal */

/**
* Set a branch to the current byte code position
*/
Expand Down
10 changes: 7 additions & 3 deletions jerry-core/parser/js/js-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ parser_compute_indicies (parser_context_t *context_p, /**< context */
if (char_p != NULL)
{
literal_p->u.value = ecma_find_or_create_literal_string (char_p,
literal_p->prop.length);
literal_p->prop.length,
(literal_p->status_flags & LEXER_FLAG_ASCII) != 0);

if (!(literal_p->status_flags & LEXER_FLAG_SOURCE_PTR))
{
Expand Down Expand Up @@ -1274,7 +1275,8 @@ parser_post_processing (parser_context_t *context_p) /**< context */
uint32_t source_data = literal_p->u.source_data;
const uint8_t *char_p = context_p->source_end_p - (source_data & 0xfffff);
ecma_value_t lit_value = ecma_find_or_create_literal_string (char_p,
source_data >> 20);
source_data >> 20,
(literal_p->status_flags & LEXER_FLAG_ASCII) != 0);
literal_pool_p[literal_p->prop.index] = lit_value;
}
}
Expand Down Expand Up @@ -2896,7 +2898,9 @@ parser_compiled_code_set_function_name (parser_context_t *context_p, /**< contex
memcpy (name_buffer_p + 4, name_lit_p->u.char_p, name_lit_p->prop.length);
}

*func_name_start_p = ecma_find_or_create_literal_string (name_buffer_p, name_length);
*func_name_start_p = ecma_find_or_create_literal_string (name_buffer_p,
name_length,
(status_flags & LEXER_FLAG_ASCII) != 0);

if (name_buffer_p != name_lit_p->u.char_p)
{
Expand Down
36 changes: 20 additions & 16 deletions jerry-core/parser/js/js-scanner-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,18 @@ scanner_scope_find_lexical_declaration (parser_context_t *context_p, /**< contex
return false;
}

if (JERRY_LIKELY (!literal_p->has_escape))
if (JERRY_LIKELY (!(literal_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)))
{
name_p = ecma_new_ecma_string_from_utf8 (literal_p->char_p, literal_p->length);
name_p = parser_new_ecma_string_from_literal ((lexer_literal_t *) literal_p);
}
else
{
uint8_t *destination_p = (uint8_t *) scanner_malloc (context_p, literal_p->length);

lexer_convert_ident_to_cesu8 (destination_p, literal_p->char_p, literal_p->length);

name_p = ecma_new_ecma_string_from_utf8 (destination_p, literal_p->length);
name_p = parser_new_ecma_string_from_literal ((lexer_literal_t *) literal_p);

scanner_free (destination_p, literal_p->length);
}

Expand Down Expand Up @@ -1114,7 +1115,7 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
}
#endif /* JERRY_ESNEXT */

if (literal_p->has_escape)
if (literal_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)
{
type |= SCANNER_STREAM_HAS_ESCAPE;
}
Expand Down Expand Up @@ -1384,13 +1385,13 @@ scanner_add_custom_literal (parser_context_t *context_p, /**< context */
const uint8_t *char_p = literal_location_p->char_p;
prop_length_t length = literal_location_p->length;

if (JERRY_LIKELY (!literal_location_p->has_escape))
if (JERRY_LIKELY (!(literal_location_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)))
{
while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
{
if (literal_p->length == length)
{
if (JERRY_LIKELY (!literal_p->has_escape))
if (JERRY_LIKELY (!(literal_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)))
{
if (memcmp (literal_p->char_p, char_p, length) == 0)
{
Expand All @@ -1401,7 +1402,7 @@ scanner_add_custom_literal (parser_context_t *context_p, /**< context */
{
/* The non-escaped version is preferred. */
literal_p->char_p = char_p;
literal_p->has_escape = 0;
literal_p->status_flags = LEXER_LIT_LOCATION_NO_OPTS;
return literal_p;
}
}
Expand Down Expand Up @@ -1494,13 +1495,13 @@ scanner_append_argument (parser_context_t *context_p, /**< context */

JERRY_ASSERT (SCANNER_LITERAL_POOL_MAY_HAVE_ARGUMENTS (literal_pool_p->status_flags));

if (JERRY_LIKELY (!context_p->token.lit_location.has_escape))
if (JERRY_LIKELY (!(context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)))
{
while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
{
if (literal_p->length == length)
{
if (JERRY_LIKELY (!literal_p->has_escape))
if (JERRY_LIKELY (!(literal_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)))
{
if (memcmp (literal_p->char_p, char_p, length) == 0)
{
Expand Down Expand Up @@ -1603,7 +1604,7 @@ scanner_detect_invalid_var (parser_context_t *context_p, /**< context */
parser_list_iterator_init (&literal_pool_p->literal_pool, &literal_iterator);
lexer_lit_location_t *literal_p;

if (JERRY_LIKELY (!context_p->token.lit_location.has_escape))
if (JERRY_LIKELY (!(context_p->token.lit_location.status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)))
{
while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
{
Expand All @@ -1614,7 +1615,7 @@ scanner_detect_invalid_var (parser_context_t *context_p, /**< context */
&& (literal_p->type & SCANNER_LITERAL_IS_LOCAL) != SCANNER_LITERAL_IS_LOCAL
&& literal_p->length == length)
{
if (JERRY_LIKELY (!literal_p->has_escape))
if (JERRY_LIKELY (!(literal_p->status_flags & LEXER_LIT_LOCATION_HAS_ESCAPE)))
{
if (memcmp (literal_p->char_p, char_p, length) == 0)
{
Expand Down Expand Up @@ -1862,7 +1863,7 @@ scanner_append_hole (parser_context_t *context_p, scanner_context_t *scanner_con
literal_p->char_p = NULL;
literal_p->length = 0;
literal_p->type = SCANNER_LITERAL_IS_ARG;
literal_p->has_escape = 0;
literal_p->status_flags = LEXER_LIT_LOCATION_NO_OPTS;
} /* scanner_append_hole */

#endif /* JERRY_ESNEXT */
Expand Down Expand Up @@ -2203,7 +2204,7 @@ scanner_try_scan_new_target (parser_context_t *context_p) /**< parser/scanner co
*/
const lexer_lit_location_t lexer_arguments_literal =
{
(const uint8_t *) "arguments", 9, LEXER_IDENT_LITERAL, false
(const uint8_t *) "arguments", 9, LEXER_IDENT_LITERAL, LEXER_LIT_LOCATION_IS_ASCII
};

/**
Expand Down Expand Up @@ -2279,7 +2280,8 @@ scanner_check_variables (parser_context_t *context_p) /**< context */

literal.length = data_p[1];
literal.type = LEXER_IDENT_LITERAL;
literal.has_escape = (data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? 1 : 0;
literal.status_flags = ((data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? LEXER_LIT_LOCATION_HAS_ESCAPE
: LEXER_LIT_LOCATION_NO_OPTS);

lexer_construct_literal_object (context_p, &literal, LEXER_NEW_IDENT_LITERAL);
literal.char_p += data_p[1];
Expand Down Expand Up @@ -2524,7 +2526,8 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
{
literal.length = data_p[1];
literal.type = LEXER_IDENT_LITERAL;
literal.has_escape = (data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? 1 : 0;
literal.status_flags = ((data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? LEXER_LIT_LOCATION_HAS_ESCAPE
: LEXER_LIT_LOCATION_NO_OPTS);

/* Literal must be exists. */
lexer_construct_literal_object (context_p, &literal, LEXER_IDENT_LITERAL);
Expand All @@ -2549,7 +2552,8 @@ scanner_create_variables (parser_context_t *context_p, /**< context */

literal.length = data_p[1];
literal.type = LEXER_IDENT_LITERAL;
literal.has_escape = (data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? 1 : 0;
literal.status_flags = ((data_p[0] & SCANNER_STREAM_HAS_ESCAPE) ? LEXER_LIT_LOCATION_HAS_ESCAPE
: LEXER_LIT_LOCATION_NO_OPTS);

lexer_construct_literal_object (context_p, &literal, LEXER_NEW_IDENT_LITERAL);
literal.char_p += data_p[1];
Expand Down
12 changes: 6 additions & 6 deletions tests/unit-core/test-literal-storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ main (void)
{
lengths[j] = (lit_utf8_size_t) (rand () % max_characters_in_string + 1);
generate_string (strings[j], lengths[j]);
ecma_find_or_create_literal_string (strings[j], lengths[j]);
ecma_find_or_create_literal_string (strings[j], lengths[j], false);
strings[j][lengths[j]] = '\0';
ptrs[j] = strings[j];
TEST_ASSERT (ptrs[j]);
Expand All @@ -89,7 +89,7 @@ main (void)
ptrs[j] = lit_get_magic_string_utf8 (msi);
TEST_ASSERT (ptrs[j]);
lengths[j] = (lit_utf8_size_t) lit_zt_utf8_string_size (ptrs[j]);
ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
ecma_find_or_create_literal_string (ptrs[j], lengths[j], false);
}
else
{
Expand All @@ -100,16 +100,16 @@ main (void)
}

/* Add empty string. */
ecma_find_or_create_literal_string (NULL, 0);
ecma_find_or_create_literal_string (NULL, 0, false);

for (uint32_t j = 0; j < test_sub_iters; j++)
{
ecma_value_t lit1;
ecma_value_t lit2;
if (ptrs[j])
{
lit1 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
lit2 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
lit1 = ecma_find_or_create_literal_string (ptrs[j], lengths[j], false);
lit2 = ecma_find_or_create_literal_string (ptrs[j], lengths[j], false);
TEST_ASSERT (ecma_is_value_string (lit1));
TEST_ASSERT (ecma_is_value_string (lit2));
TEST_ASSERT (lit1 == lit2);
Expand All @@ -125,7 +125,7 @@ main (void)
}

/* Check empty string exists. */
TEST_ASSERT (ecma_find_or_create_literal_string (NULL, 0) != JMEM_CP_NULL);
TEST_ASSERT (ecma_find_or_create_literal_string (NULL, 0, false) != JMEM_CP_NULL);
}

ecma_finalize_lit_storage ();
Expand Down
16 changes: 8 additions & 8 deletions tests/unit-core/test-stringbuilder.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ main (void)
ecma_stringbuilder_append_raw (&builder, string_data, sizeof (string_data) - 1);
ecma_string_t *result_p = ecma_stringbuilder_finalize (&builder);

ecma_string_t *str_p = ecma_new_ecma_string_from_utf8 (string_data, sizeof (string_data) - 1);
ecma_string_t *str_p = ecma_new_ecma_string_from_ascii (string_data, sizeof (string_data) - 1);
TEST_ASSERT (ecma_compare_ecma_strings (result_p, str_p));
ecma_deref_ecma_string (result_p);
ecma_deref_ecma_string (str_p);
Expand All @@ -57,15 +57,15 @@ main (void)
ecma_stringbuilder_append_char (&builder, LIT_CHAR_LOWERCASE_A);
ecma_string_t *result_p = ecma_stringbuilder_finalize (&builder);

ecma_string_t *str_p = ecma_new_ecma_string_from_utf8 (string_data, sizeof (string_data) - 1);
ecma_string_t *str_p = ecma_new_ecma_string_from_ascii (string_data, sizeof (string_data) - 1);
TEST_ASSERT (ecma_compare_ecma_strings (result_p, str_p));
ecma_deref_ecma_string (result_p);
ecma_deref_ecma_string (str_p);
}

{
static const lit_utf8_byte_t string_data[] = "A simple string";
ecma_string_t *str_p = ecma_new_ecma_string_from_utf8 (string_data, sizeof (string_data) - 1);
ecma_string_t *str_p = ecma_new_ecma_string_from_ascii (string_data, sizeof (string_data) - 1);

ecma_stringbuilder_t builder = ecma_stringbuilder_create ();
ecma_stringbuilder_append (&builder, str_p);
Expand Down Expand Up @@ -94,7 +94,7 @@ main (void)
ecma_stringbuilder_append_char (&builder, LIT_CHAR_LOWERCASE_C);
ecma_string_t *result_p = ecma_stringbuilder_finalize (&builder);

ecma_string_t *str_p = ecma_new_ecma_string_from_utf8 (string_data, sizeof (string_data) - 1);
ecma_string_t *str_p = ecma_new_ecma_string_from_ascii (string_data, sizeof (string_data) - 1);
TEST_ASSERT (ecma_compare_ecma_strings (result_p, str_p));
ecma_deref_ecma_string (result_p);
ecma_deref_ecma_string (str_p);
Expand Down Expand Up @@ -125,7 +125,7 @@ main (void)
ecma_string_t *result_p = ecma_stringbuilder_finalize (&builder);

static const lit_utf8_byte_t expected_data[] = "1abc234string";
ecma_string_t *str_p = ecma_new_ecma_string_from_utf8 (expected_data, sizeof (expected_data) - 1);
ecma_string_t *str_p = ecma_new_ecma_string_from_ascii (expected_data, sizeof (expected_data) - 1);
TEST_ASSERT (ecma_compare_ecma_strings (result_p, str_p));
ecma_deref_ecma_string (result_p);
ecma_deref_ecma_string (str_p);
Expand Down Expand Up @@ -177,14 +177,14 @@ main (void)
ecma_stringbuilder_append_char (&builder, LIT_CHAR_1);
ecma_stringbuilder_append_raw (&builder, string_data, sizeof (string_data) - 1);

ecma_string_t *another_string = ecma_new_ecma_string_from_utf8 (string_data, sizeof (string_data) - 1);
ecma_string_t *another_string = ecma_new_ecma_string_from_ascii (string_data, sizeof (string_data) - 1);

ecma_stringbuilder_append (&builder, uint_str_p);
ecma_stringbuilder_append_magic (&builder, LIT_MAGIC_STRING_STRING);
ecma_string_t *result_p = ecma_stringbuilder_finalize (&builder);

static const lit_utf8_byte_t expected_data[] = "1abc234string";
ecma_string_t *str_p = ecma_new_ecma_string_from_utf8 (expected_data, sizeof (expected_data) - 1);
ecma_string_t *str_p = ecma_new_ecma_string_from_ascii (expected_data, sizeof (expected_data) - 1);
TEST_ASSERT (ecma_compare_ecma_strings (result_p, str_p));
ecma_deref_ecma_string (result_p);
ecma_deref_ecma_string (str_p);
Expand All @@ -201,7 +201,7 @@ main (void)
ecma_string_t *result_p = ecma_stringbuilder_finalize (&builder);

static const lit_utf8_byte_t expected_data[] = "234abcstring";
ecma_string_t *str_p = ecma_new_ecma_string_from_utf8 (expected_data, sizeof (expected_data) - 1);
ecma_string_t *str_p = ecma_new_ecma_string_from_ascii (expected_data, sizeof (expected_data) - 1);
TEST_ASSERT (ecma_compare_ecma_strings (result_p, str_p));
ecma_deref_ecma_string (result_p);
ecma_deref_ecma_string (str_p);
Expand Down