Implement function.toString operation (#4752)
May increase the memory consumtpion heavily. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -741,6 +741,9 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
decoded_length = 2 * 3;
|
||||
status_flags = LEXER_LIT_LOCATION_HAS_ESCAPE;
|
||||
#if JERRY_FUNCTION_TO_STRING
|
||||
context_p->global_status_flags |= ECMA_PARSE_INTERNAL_HAS_4_BYTE_MARKER;
|
||||
#endif /* JERRY_FUNCTION_TO_STRING */
|
||||
}
|
||||
#else /* !JERRY_ESNEXT */
|
||||
if (code_point < LIT_UTF8_4_BYTE_MARKER)
|
||||
@@ -1171,6 +1174,9 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
raw_length_adjust += 2;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
column++;
|
||||
#if JERRY_FUNCTION_TO_STRING
|
||||
context_p->global_status_flags |= ECMA_PARSE_INTERNAL_HAS_4_BYTE_MARKER;
|
||||
#endif /* JERRY_FUNCTION_TO_STRING */
|
||||
continue;
|
||||
}
|
||||
else if (*source_p == LIT_CHAR_TAB)
|
||||
@@ -1605,6 +1611,11 @@ lexer_next_token (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
size_t length;
|
||||
|
||||
#if JERRY_ESNEXT && JERRY_FUNCTION_TO_STRING
|
||||
/* Needed by arrow functions with expression body */
|
||||
context_p->function_end_p = context_p->source_p;
|
||||
#endif /* JERRY_ESNEXT && JERRY_FUNCTION_TO_STRING */
|
||||
|
||||
lexer_skip_spaces (context_p);
|
||||
|
||||
context_p->token.keyword_type = LEXER_EOS;
|
||||
@@ -3069,7 +3080,7 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (lit_is_valid_utf8_string (regex_start_p, length));
|
||||
JERRY_ASSERT (lit_is_valid_utf8_string (regex_start_p, length, false));
|
||||
pattern_str_p = ecma_new_ecma_string_from_utf8_converted_to_cesu8 (regex_start_p, length);
|
||||
}
|
||||
|
||||
@@ -3189,6 +3200,13 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
JERRY_ASSERT ((ident_opts & LEXER_OBJ_IDENT_CLASS_IDENTIFIER)
|
||||
|| !(ident_opts & LEXER_OBJ_IDENT_CLASS_NO_STATIC));
|
||||
|
||||
#if JERRY_FUNCTION_TO_STRING
|
||||
if (ident_opts & LEXER_OBJ_IDENT_SET_FUNCTION_START)
|
||||
{
|
||||
context_p->function_start_p = context_p->source_p;
|
||||
}
|
||||
#endif /* JERRY_FUNCTION_TO_STRING */
|
||||
|
||||
if (lexer_parse_identifier (context_p, LEXER_PARSE_NO_OPTS))
|
||||
{
|
||||
if (!(ident_opts & (LEXER_OBJ_IDENT_ONLY_IDENTIFIERS | LEXER_OBJ_IDENT_OBJECT_PATTERN)))
|
||||
@@ -3253,6 +3271,10 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
#if JERRY_ESNEXT
|
||||
case LIT_CHAR_LEFT_SQUARE:
|
||||
{
|
||||
#if JERRY_FUNCTION_TO_STRING
|
||||
const uint8_t *function_start_p = context_p->function_start_p;
|
||||
#endif /* JERRY_FUNCTION_TO_STRING */
|
||||
|
||||
lexer_consume_next_character (context_p);
|
||||
|
||||
lexer_next_token (context_p);
|
||||
@@ -3262,6 +3284,10 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_RIGHT_SQUARE_EXPECTED);
|
||||
}
|
||||
|
||||
#if JERRY_FUNCTION_TO_STRING
|
||||
context_p->function_start_p = function_start_p;
|
||||
#endif /* JERRY_FUNCTION_TO_STRING */
|
||||
return;
|
||||
}
|
||||
case LIT_CHAR_ASTERISK:
|
||||
@@ -3277,7 +3303,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
case LIT_CHAR_DOT:
|
||||
{
|
||||
if ((ident_opts & ((uint32_t) ~LEXER_OBJ_IDENT_OBJECT_PATTERN))
|
||||
if ((ident_opts & ((uint32_t) ~(LEXER_OBJ_IDENT_OBJECT_PATTERN | LEXER_OBJ_IDENT_SET_FUNCTION_START)))
|
||||
|| context_p->source_p + 2 >= context_p->source_end_p
|
||||
|| context_p->source_p[1] != LIT_CHAR_DOT
|
||||
|| context_p->source_p[2] != LIT_CHAR_DOT)
|
||||
|
||||
Reference in New Issue
Block a user