@@ -90,6 +90,40 @@ lexer_hex_to_character (parser_context_t *context_p, /**< context */
90
90
return (ecma_char_t ) result ;
91
91
} /* lexer_hex_to_character */
92
92
93
+ /**
94
+ * Parse hexadecimal character sequence
95
+ *
96
+ * @return character value
97
+ */
98
+ static ecma_char_t
99
+ lexer_unchecked_hex_to_character (const uint8_t * source_p , /**< current source position */
100
+ int length ) /**< source length */
101
+ {
102
+ uint32_t result = 0 ;
103
+
104
+ do
105
+ {
106
+ uint32_t byte = * source_p ++ ;
107
+
108
+ result <<= 4 ;
109
+
110
+ if (byte >= LIT_CHAR_0 && byte <= LIT_CHAR_9 )
111
+ {
112
+ result += byte - LIT_CHAR_0 ;
113
+ }
114
+ else
115
+ {
116
+ JERRY_ASSERT ((byte >= LIT_CHAR_LOWERCASE_A && byte <= LIT_CHAR_LOWERCASE_F )
117
+ || (byte >= LIT_CHAR_UPPERCASE_A && byte <= LIT_CHAR_UPPERCASE_F ));
118
+
119
+ result += LEXER_TO_ASCII_LOWERCASE (byte ) - (LIT_CHAR_LOWERCASE_A - 10 );
120
+ }
121
+ }
122
+ while (-- length > 0 );
123
+
124
+ return (ecma_char_t ) result ;
125
+ } /* lexer_unchecked_hex_to_character */
126
+
93
127
/**
94
128
* Skip space mode
95
129
*/
@@ -1513,7 +1547,7 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
1513
1547
if (* source_p == LIT_CHAR_BACKSLASH )
1514
1548
{
1515
1549
destination_p += lit_char_to_utf8_bytes (destination_p ,
1516
- lexer_hex_to_character ( context_p , source_p + 2 , 4 ));
1550
+ lexer_unchecked_hex_to_character ( source_p + 2 , 4 ));
1517
1551
source_p += 6 ;
1518
1552
continue ;
1519
1553
}
@@ -1628,9 +1662,8 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
1628
1662
JERRY_ASSERT (source_p + 1 + hex_part_length <= context_p -> source_end_p );
1629
1663
1630
1664
destination_p += lit_char_to_utf8_bytes (destination_p ,
1631
- lexer_hex_to_character (context_p ,
1632
- source_p + 1 ,
1633
- hex_part_length ));
1665
+ lexer_unchecked_hex_to_character (source_p + 1 ,
1666
+ hex_part_length ));
1634
1667
source_p += hex_part_length + 1 ;
1635
1668
continue ;
1636
1669
}
@@ -1731,11 +1764,12 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
1731
1764
literal_type ,
1732
1765
literal_p -> has_escape );
1733
1766
1767
+ JERRY_ASSERT (literal_type == context_p -> lit_object .literal_p -> type );
1768
+
1734
1769
context_p -> lit_object .type = LEXER_LITERAL_OBJECT_ANY ;
1735
1770
1736
1771
if (literal_type == LEXER_IDENT_LITERAL
1737
- && (context_p -> status_flags & PARSER_INSIDE_WITH )
1738
- && context_p -> lit_object .literal_p -> type == LEXER_IDENT_LITERAL )
1772
+ && (context_p -> status_flags & PARSER_INSIDE_WITH ))
1739
1773
{
1740
1774
context_p -> lit_object .literal_p -> status_flags |= LEXER_FLAG_NO_REG_STORE ;
1741
1775
}
@@ -2535,9 +2569,9 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< context *
2535
2569
2536
2570
if (* left_p == LIT_CHAR_BACKSLASH && * right_p == LIT_CHAR_BACKSLASH )
2537
2571
{
2538
- uint16_t left_chr = lexer_hex_to_character ( context_p , left_p + 2 , 4 );
2572
+ uint16_t left_chr = lexer_unchecked_hex_to_character ( left_p + 2 , 4 );
2539
2573
2540
- if (left_chr != lexer_hex_to_character ( context_p , right_p + 2 , 4 ))
2574
+ if (left_chr != lexer_unchecked_hex_to_character ( right_p + 2 , 4 ))
2541
2575
{
2542
2576
return false;
2543
2577
}
@@ -2557,7 +2591,7 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< context *
2557
2591
right_p = swap_p ;
2558
2592
}
2559
2593
2560
- utf8_len = lit_char_to_utf8_bytes (utf8_buf , lexer_hex_to_character ( context_p , left_p + 2 , 4 ));
2594
+ utf8_len = lit_char_to_utf8_bytes (utf8_buf , lexer_unchecked_hex_to_character ( left_p + 2 , 4 ));
2561
2595
JERRY_ASSERT (utf8_len > 0 );
2562
2596
count -= utf8_len ;
2563
2597
offset = 0 ;
0 commit comments