@@ -2222,22 +2222,6 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
2222
2222
parser_raise_error (context_p , PARSER_ERR_IDENTIFIER_EXPECTED );
2223
2223
} /* lexer_expect_identifier */
2224
2224
2225
- /**
2226
- * Description of "get" literal string.
2227
- */
2228
- static const lexer_lit_location_t lexer_get_literal =
2229
- {
2230
- (const uint8_t * ) "get" , 3 , LEXER_IDENT_LITERAL , false
2231
- };
2232
-
2233
- /**
2234
- * Description of "set" literal string.
2235
- */
2236
- static const lexer_lit_location_t lexer_set_literal =
2237
- {
2238
- (const uint8_t * ) "set" , 3 , LEXER_IDENT_LITERAL , false
2239
- };
2240
-
2241
2225
/**
2242
2226
* Next token must be an identifier.
2243
2227
*/
@@ -2266,12 +2250,12 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
2266
2250
if (context_p -> source_p < context_p -> source_end_p
2267
2251
&& context_p -> source_p [0 ] != LIT_CHAR_COLON )
2268
2252
{
2269
- if (lexer_compare_identifier_to_current (context_p , & lexer_get_literal ))
2253
+ if (lexer_compare_raw_identifier_to_current (context_p , "get" , 3 ))
2270
2254
{
2271
2255
context_p -> token .type = LEXER_PROPERTY_GETTER ;
2272
2256
return ;
2273
2257
}
2274
- else if (lexer_compare_identifier_to_current (context_p , & lexer_set_literal ))
2258
+ else if (lexer_compare_raw_identifier_to_current (context_p , "set" , 3 ))
2275
2259
{
2276
2260
context_p -> token .type = LEXER_PROPERTY_SETTER ;
2277
2261
return ;
@@ -2348,11 +2332,11 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
2348
2332
if (context_p -> source_p < context_p -> source_end_p
2349
2333
&& context_p -> source_p [0 ] != LIT_CHAR_COLON )
2350
2334
{
2351
- if (lexer_compare_identifier_to_current (context_p , & lexer_get_literal ))
2335
+ if (lexer_compare_raw_identifier_to_current (context_p , "get" , 3 ))
2352
2336
{
2353
2337
context_p -> token .type = LEXER_PROPERTY_GETTER ;
2354
2338
}
2355
- else if (lexer_compare_identifier_to_current (context_p , & lexer_set_literal ))
2339
+ else if (lexer_compare_raw_identifier_to_current (context_p , "set" , 3 ))
2356
2340
{
2357
2341
context_p -> token .type = LEXER_PROPERTY_SETTER ;
2358
2342
}
@@ -2376,14 +2360,16 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
2376
2360
} /* lexer_scan_identifier */
2377
2361
2378
2362
/**
2379
- * Compares the given identifier to that which is the current token
2380
- * in the parser context.
2363
+ * Compares the current identifier in the context to the parameter identifier
2364
+ *
2365
+ * Note:
2366
+ * Escape sequences are allowed.
2381
2367
*
2382
2368
* @return true if the input identifiers are the same
2383
2369
*/
2384
2370
bool
2385
- lexer_compare_identifier_to_current (parser_context_t * context_p , /**< context */
2386
- const lexer_lit_location_t * right ) /**< identifier */
2371
+ lexer_compare_identifier_to_current (parser_context_t * context_p , /**< context */
2372
+ const lexer_lit_location_t * right ) /**< identifier */
2387
2373
{
2388
2374
lexer_lit_location_t * left = & context_p -> token .lit_location ;
2389
2375
const uint8_t * left_p ;
@@ -2424,9 +2410,9 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< co
2424
2410
2425
2411
if (* left_p == LIT_CHAR_BACKSLASH && * right_p == LIT_CHAR_BACKSLASH )
2426
2412
{
2427
- uint16_t left_chr = lexer_hex_to_character (context_p , left_p , 6 );
2413
+ uint16_t left_chr = lexer_hex_to_character (context_p , left_p + 2 , 4 );
2428
2414
2429
- if (left_chr != lexer_hex_to_character (context_p , right_p , 6 ))
2415
+ if (left_chr != lexer_hex_to_character (context_p , right_p + 2 , 4 ))
2430
2416
{
2431
2417
return false;
2432
2418
}
@@ -2446,7 +2432,7 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< co
2446
2432
right_p = swap_p ;
2447
2433
}
2448
2434
2449
- utf8_len = lit_char_to_utf8_bytes (utf8_buf , lexer_hex_to_character (context_p , left_p , 6 ));
2435
+ utf8_len = lit_char_to_utf8_bytes (utf8_buf , lexer_hex_to_character (context_p , left_p + 2 , 4 ));
2450
2436
JERRY_ASSERT (utf8_len > 0 );
2451
2437
count -= utf8_len ;
2452
2438
offset = 0 ;
@@ -2468,6 +2454,29 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< co
2468
2454
return true;
2469
2455
} /* lexer_compare_identifier_to_current */
2470
2456
2457
+ /**
2458
+ * Compares the current identifier in the context to the parameter identifier
2459
+ *
2460
+ * Note:
2461
+ * Escape sequences are not allowed.
2462
+ *
2463
+ * @return true if the input identifiers are the same
2464
+ */
2465
+ bool
2466
+ lexer_compare_raw_identifier_to_current (parser_context_t * context_p , /**< context */
2467
+ const char * right_ident_p , /**< identifier */
2468
+ size_t right_ident_length ) /**< identifier length */
2469
+ {
2470
+ lexer_lit_location_t * left = & context_p -> token .lit_location ;
2471
+
2472
+ if (left -> length != right_ident_length || left -> has_escape )
2473
+ {
2474
+ return 0 ;
2475
+ }
2476
+
2477
+ return memcmp (left -> char_p , right_ident_p , right_ident_length ) == 0 ;
2478
+ } /* lexer_compare_raw_identifier_to_current */
2479
+
2471
2480
/**
2472
2481
* @}
2473
2482
* @}
0 commit comments