Methods shouldn't have prototype property (#3964)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
This commit is contained in:
committed by
GitHub
parent
b82bd76175
commit
c76736eadf
@@ -880,6 +880,7 @@ typedef enum
|
||||
|
||||
/* The following functions has no prototype (see CBC_FUNCTION_HAS_PROTOTYPE) */
|
||||
CBC_FUNCTION_ACCESSOR, /**< property accessor function */
|
||||
CBC_FUNCTION_METHOD, /**< method */
|
||||
|
||||
/* The following functions are arrow function (see CBC_FUNCTION_IS_ARROW) */
|
||||
CBC_FUNCTION_ARROW, /**< arrow function */
|
||||
|
||||
@@ -743,7 +743,7 @@ parser_parse_class_literal (parser_context_t *context_p, /**< context */
|
||||
parse_class_method:
|
||||
; /* Empty statement to make compiler happy. */
|
||||
uint16_t literal_index = context_p->lit_object.index;
|
||||
uint16_t function_literal_index = lexer_construct_function_object (context_p, status_flags);
|
||||
uint16_t function_literal_index = lexer_construct_function_object (context_p, status_flags | PARSER_IS_METHOD);
|
||||
|
||||
parser_emit_cbc_literal (context_p,
|
||||
CBC_PUSH_LITERAL,
|
||||
@@ -915,7 +915,8 @@ parser_parse_object_method (parser_context_t *context_p) /**< context */
|
||||
context_p->source_p--;
|
||||
context_p->column--;
|
||||
uint16_t function_literal_index = lexer_construct_function_object (context_p, (PARSER_FUNCTION_CLOSURE
|
||||
| PARSER_ALLOW_SUPER));
|
||||
| PARSER_ALLOW_SUPER
|
||||
| PARSER_IS_METHOD));
|
||||
|
||||
parser_emit_cbc_literal (context_p,
|
||||
CBC_PUSH_LITERAL,
|
||||
|
||||
@@ -74,11 +74,11 @@ typedef enum
|
||||
PARSER_ALLOW_SUPER_CALL = (1u << 22), /**< allow super constructor call
|
||||
* Note: PARSER_CLASS_CONSTRUCTOR must be present */
|
||||
PARSER_ALLOW_NEW_TARGET = (1u << 23), /**< allow new.target parsing in the current context */
|
||||
|
||||
PARSER_IS_METHOD = (1u << 24), /**< method is parsed */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
PARSER_MODULE_DEFAULT_CLASS_OR_FUNC = (1u << 24), /**< parsing a function or class default export */
|
||||
PARSER_MODULE_STORE_IDENT = (1u << 25), /**< store identifier of the current export statement */
|
||||
PARSER_MODULE_DEFAULT_CLASS_OR_FUNC = (1u << 25), /**< parsing a function or class default export */
|
||||
PARSER_MODULE_STORE_IDENT = (1u << 26), /**< store identifier of the current export statement */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
PARSER_HAS_LATE_LIT_INIT = (1u << 30), /**< there are identifier or string literals which construction
|
||||
* is postponed after the local parser data is freed */
|
||||
|
||||
@@ -1405,6 +1405,10 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_CONSTRUCTOR);
|
||||
}
|
||||
else if (context_p->status_flags & PARSER_IS_METHOD)
|
||||
{
|
||||
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_METHOD);
|
||||
}
|
||||
else
|
||||
{
|
||||
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_NORMAL);
|
||||
|
||||
Reference in New Issue
Block a user