@@ -102,6 +102,10 @@ ecma_new_chars_collection (const lit_utf8_byte_t chars_buffer[], /**< utf-8 char
102
102
/* *
103
103
* Get length of a collection of ecma-chars
104
104
*
105
+ * NOTE:
106
+ * While chars collection holds a string in utf-8 encoding, this function acts as if the string was encoded in
107
+ * UTF-16 and returns number of 16-bit characters (code units) required for string representation in this format.
108
+ *
105
109
* @return number of UTF-16 code units in a collecton
106
110
*/
107
111
static ecma_length_t
@@ -151,7 +155,7 @@ ecma_get_chars_collection_length (const ecma_collection_header_t *header_p) /**<
151
155
JERRY_ASSERT (char_index == chars_number);
152
156
153
157
return length;
154
- } /* ecma_compare_chars_collection */
158
+ } /* ecma_get_chars_collection_length */
155
159
156
160
/* *
157
161
* Compare two collection of ecma-chars.
@@ -446,7 +450,7 @@ ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, /**< utf-8 stri
446
450
ecma_string_t *
447
451
ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit) /* *< code unit */
448
452
{
449
- lit_utf8_byte_t lit_utf8_bytes[MAX_BYTES_IN_CODE_UNIT ];
453
+ lit_utf8_byte_t lit_utf8_bytes[LIT_UTF8_MAX_BYTES_IN_CODE_UNIT ];
450
454
lit_utf8_size_t bytes_size = lit_code_unit_to_utf8 (code_unit, lit_utf8_bytes);
451
455
452
456
return ecma_new_ecma_string_from_utf8 (lit_utf8_bytes, bytes_size);
@@ -472,7 +476,7 @@ ecma_new_ecma_string_from_uint32 (uint32_t uint32_number) /**< UInt32-represente
472
476
FIXME (/* Use digit to char conversion routine */ );
473
477
const lit_utf8_byte_t digits[10 ] = { ' 0' , ' 1' , ' 2' , ' 3' , ' 4' , ' 5' , ' 6' , ' 7' , ' 8' , ' 9' };
474
478
const bool is_one_char_or_more = (uint32_number >= 10 );
475
- const lit_utf8_byte_t last_chars[ECMA_STRING_HASH_LAST_CHARS_COUNT ] =
479
+ const lit_utf8_byte_t last_chars[LIT_STRING_HASH_LAST_BYTES_COUNT ] =
476
480
{
477
481
is_one_char_or_more ? digits[digit_pl] : digits[digit_l],
478
482
is_one_char_or_more ? digits[digit_l] : (lit_utf8_byte_t ) ' \0 '
@@ -657,22 +661,22 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
657
661
ECMA_SET_NON_NULL_POINTER (string_desc_p->u .concatenation .string1_cp , string1_p);
658
662
ECMA_SET_NON_NULL_POINTER (string_desc_p->u .concatenation .string2_cp , string2_p);
659
663
660
- if (str2_size >= ECMA_STRING_HASH_LAST_CHARS_COUNT )
664
+ if (str2_size >= LIT_STRING_HASH_LAST_BYTES_COUNT )
661
665
{
662
666
string_desc_p->hash = string2_p->hash ;
663
667
}
664
668
else
665
669
{
666
- JERRY_STATIC_ASSERT (ECMA_STRING_HASH_LAST_CHARS_COUNT == 2 );
670
+ JERRY_STATIC_ASSERT (LIT_STRING_HASH_LAST_BYTES_COUNT == 2 );
667
671
JERRY_ASSERT (str2_size == 1 );
668
672
669
- lit_utf8_byte_t bytes_buf[ECMA_STRING_HASH_LAST_CHARS_COUNT ] =
673
+ lit_utf8_byte_t bytes_buf[LIT_STRING_HASH_LAST_BYTES_COUNT ] =
670
674
{
671
675
ecma_string_get_byte_at_pos (string1_p, str1_size - 1u ),
672
676
ecma_string_get_byte_at_pos (string2_p, 0 )
673
677
};
674
678
675
- string_desc_p->hash = lit_utf8_string_calc_hash_last_bytes (bytes_buf, ECMA_STRING_HASH_LAST_CHARS_COUNT );
679
+ string_desc_p->hash = lit_utf8_string_calc_hash_last_bytes (bytes_buf, LIT_STRING_HASH_LAST_BYTES_COUNT );
676
680
}
677
681
678
682
return string_desc_p;
@@ -1465,7 +1469,7 @@ ecma_string_get_size (const ecma_string_t *string_p) /**< ecma-string */
1465
1469
{
1466
1470
const uint32_t uint32_number = string_p->u .uint32_number ;
1467
1471
const int32_t max_uint32_len = 10 ;
1468
- const uint32_t nums_with_ascending_length[10 ] =
1472
+ const uint32_t nums_with_ascending_length[max_uint32_len ] =
1469
1473
{
1470
1474
1u ,
1471
1475
10u ,
@@ -1717,7 +1721,7 @@ ecma_is_ex_string_magic (const ecma_string_t *string_p, /**< ecma-string */
1717
1721
*
1718
1722
* @return calculated hash
1719
1723
*/
1720
- ecma_string_hash_t
1724
+ lit_string_hash_t
1721
1725
ecma_string_hash (const ecma_string_t *string_p) /* *< ecma-string to calculate hash for */
1722
1726
1723
1727
{
@@ -1741,7 +1745,7 @@ ecma_string_substr (const ecma_string_t *string_p, /**< pointer to an ecma strin
1741
1745
#endif
1742
1746
1743
1747
const ecma_length_t span = (start_pos > end_pos) ? 0 : end_pos - start_pos;
1744
- const lit_utf8_size_t utf8_str_size = MAX_BYTES_IN_CODE_UNIT * span;
1748
+ const lit_utf8_size_t utf8_str_size = LIT_UTF8_MAX_BYTES_IN_CODE_UNIT * span;
1745
1749
1746
1750
if (utf8_str_size)
1747
1751
{
@@ -1765,7 +1769,7 @@ ecma_string_substr (const ecma_string_t *string_p, /**< pointer to an ecma strin
1765
1769
{
1766
1770
ecma_char_t code_unit = lit_utf8_string_code_unit_at (utf8_str_p, buffer_size, start_pos + idx);
1767
1771
1768
- JERRY_ASSERT (utf8_str_size >= utf8_substr_buffer_offset + MAX_BYTES_IN_CODE_UNIT );
1772
+ JERRY_ASSERT (utf8_str_size >= utf8_substr_buffer_offset + LIT_UTF8_MAX_BYTES_IN_CODE_UNIT );
1769
1773
utf8_substr_buffer_offset += lit_code_unit_to_utf8 (code_unit, utf8_substr_buffer + utf8_substr_buffer_offset);
1770
1774
}
1771
1775
0 commit comments