@@ -95,42 +95,6 @@ lexer_hex_to_code_point (const uint8_t *source_p, /**< current source position *
9595
9696#if ENABLED (JERRY_ESNEXT )
9797
98- /**
99- * Find a string literal in the literal pool matching with the given buffer's content
100- *
101- * @return PARSER_INVALID_LITERAL_INDEX - if the literal is not present in the literal pool
102- * literal's index in the pool - otherwise
103- */
104- static uint16_t
105- parser_find_string_literal (parser_context_t * context_p , /**< context */
106- lexer_literal_t * * out_literal_p , /**< [out] found literal */
107- uint8_t * buffer_p , /**< character buffer */
108- lit_utf8_size_t size ) /**< buffer's size */
109- {
110- JERRY_ASSERT (out_literal_p != NULL );
111- JERRY_ASSERT (buffer_p != NULL );
112-
113- uint16_t literal_index = 0 ;
114- lexer_literal_t * literal_p ;
115- parser_list_iterator_t literal_iterator ;
116- parser_list_iterator_init (& context_p -> literal_pool , & literal_iterator );
117-
118- while ((literal_p = (lexer_literal_t * ) parser_list_iterator_next (& literal_iterator )) != NULL )
119- {
120- if (literal_p -> type == LEXER_STRING_LITERAL
121- && literal_p -> prop .length == size
122- && memcmp (literal_p -> u .char_p , buffer_p , size ) == 0 )
123- {
124- * out_literal_p = literal_p ;
125- return literal_index ;
126- }
127-
128- literal_index ++ ;
129- }
130-
131- return PARSER_INVALID_LITERAL_INDEX ;
132- } /* parser_find_string_literal */
133-
13498/**
13599 * Parse hexadecimal character sequence enclosed in braces
136100 *
@@ -3104,56 +3068,14 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
31043068 re_compiled_code_t * re_bytecode_p = re_compile_bytecode (pattern_str_p , current_flags );
31053069 ecma_deref_ecma_string (pattern_str_p );
31063070
3107- lexer_literal_t * literal_p = NULL ;
3108- uint8_t literal_type = LEXER_REGEXP_LITERAL ;
3109-
31103071 if (JERRY_UNLIKELY (re_bytecode_p == NULL ))
31113072 {
3112- #if ENABLED (JERRY_ESNEXT )
3113- ecma_value_t error = jcontext_take_exception ();
3114- ecma_property_t * prop_p = ecma_find_named_property (ecma_get_object_from_value (error ),
3115- ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE ));
3116- const char default_msg [] = "Invalid regular expression" ;
3117- lit_utf8_byte_t * buffer_p = (lit_utf8_byte_t * ) default_msg ;
3118- lit_utf8_size_t size = sizeof (buffer_p ) - 1 ;
3119-
3120- if (prop_p != NULL )
3121- {
3122- ecma_string_t * message_p = ecma_get_string_from_value (ECMA_PROPERTY_VALUE_PTR (prop_p )-> value );
3123- JERRY_ASSERT (!ECMA_IS_DIRECT_STRING (message_p ));
3124- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (message_p ) == ECMA_STRING_CONTAINER_HEAP_ASCII_STRING );
3125- buffer_p = ECMA_ASCII_STRING_GET_BUFFER (message_p );
3126- size = ECMA_ASCII_STRING_GET_SIZE (message_p );
3127- }
3128-
3129- uint16_t literal_index = parser_find_string_literal (context_p , & literal_p , buffer_p , size );
3130-
3131- if (literal_index != PARSER_INVALID_LITERAL_INDEX )
3132- {
3133- ecma_free_value (error );
3134- context_p -> lit_object .literal_p = literal_p ;
3135- context_p -> lit_object .index = literal_index ;
3136- return ;
3137- }
3138-
3139- literal_p = (lexer_literal_t * ) parser_list_append (context_p , & context_p -> literal_pool );
3140- literal_p -> u .char_p = (uint8_t * ) jmem_heap_alloc_block (size );
3141- memcpy ((uint8_t * ) literal_p -> u .char_p , buffer_p , size );
3142- literal_type = LEXER_STRING_LITERAL ;
3143- length = size ;
3144-
3145- ecma_free_value (error );
3146- #else /* !ENABLED (JERRY_ESNEXT) */
31473073 parser_raise_error (context_p , PARSER_ERR_INVALID_REGEXP );
3148- #endif /* ENABLED (JERRY_ESNEXT) */
3149- }
3150- else
3151- {
3152- literal_p = (lexer_literal_t * ) parser_list_append (context_p , & context_p -> literal_pool );
3153- literal_p -> u .bytecode_p = (ecma_compiled_code_t * ) re_bytecode_p ;
31543074 }
31553075
3156- literal_p -> type = literal_type ;
3076+ lexer_literal_t * literal_p = (lexer_literal_t * ) parser_list_append (context_p , & context_p -> literal_pool );
3077+ literal_p -> u .bytecode_p = (ecma_compiled_code_t * ) re_bytecode_p ;
3078+ literal_p -> type = LEXER_REGEXP_LITERAL ;
31573079 literal_p -> prop .length = (prop_length_t ) length ;
31583080 literal_p -> status_flags = 0 ;
31593081
0 commit comments