Improve float number handling and conversion (#4820)

Fixes #4739.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai
2021-12-03 12:58:37 +01:00
committed by GitHub
parent a1c1d42710
commit 81d2319144
30 changed files with 1022 additions and 1603 deletions
+32 -8
View File
@@ -335,6 +335,35 @@ lit_char_is_binary_digit (ecma_char_t c) /** code unit */
} /* lit_char_is_binary_digit */
#endif /* JERRY_ESNEXT */
/**
* @return radix value
*/
uint8_t
lit_char_to_radix (lit_utf8_byte_t c) /** code unit */
{
switch (LEXER_TO_ASCII_LOWERCASE (c))
{
case LIT_CHAR_LOWERCASE_X:
{
return 16;
}
#if JERRY_ESNEXT
case LIT_CHAR_LOWERCASE_O:
{
return 8;
}
case LIT_CHAR_LOWERCASE_B:
{
return 2;
}
#endif /* JERRY_ESNEXT */
default:
{
return 10;
}
}
} /* lit_char_to_radix */
/**
* UnicodeEscape abstract method
*
@@ -370,14 +399,9 @@ lit_char_hex_to_int (ecma_char_t c) /**< code unit, corresponding to
{
return (uint32_t) (c - LIT_CHAR_ASCII_DIGITS_BEGIN);
}
else if (c >= LIT_CHAR_ASCII_LOWERCASE_LETTERS_HEX_BEGIN && c <= LIT_CHAR_ASCII_LOWERCASE_LETTERS_HEX_END)
{
return (uint32_t) (c - LIT_CHAR_ASCII_LOWERCASE_LETTERS_HEX_BEGIN + 10);
}
else
{
return (uint32_t) (c - LIT_CHAR_ASCII_UPPERCASE_LETTERS_HEX_BEGIN + 10);
}
const uint32_t hex_offset = 10 - (LIT_CHAR_LOWERCASE_A % 32);
return (c % 32) + hex_offset;
} /* lit_char_hex_to_int */
/**
+1
View File
@@ -229,6 +229,7 @@ bool lit_char_is_hex_digit (ecma_char_t c);
#if JERRY_ESNEXT
bool lit_char_is_binary_digit (ecma_char_t c);
#endif /* JERRY_ESNEXT */
uint8_t lit_char_to_radix (lit_utf8_byte_t c);
void lit_char_unicode_escape (ecma_stringbuilder_t *builder_p, ecma_char_t c);
uint32_t lit_char_hex_to_int (ecma_char_t c);
size_t lit_code_point_to_cesu8_bytes (uint8_t *dst_p, lit_code_point_t code_point);