Implement Object.prototype.__proto__ accessor property (#3546)

We are using the already existing Object.getPrototypeOf and
Object.setProtoypeOf methods

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2020-03-27 14:46:51 +01:00
committed by GitHub
parent 94b8b4bb7b
commit 4240b740aa
13 changed files with 205 additions and 7 deletions
+18
View File
@@ -847,6 +847,10 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
parser_stack_push_uint8 (context_p, PARSER_OBJECT_PROPERTY_START);
#endif /* !ENABLED (JERRY_ES2015) */
#if ENABLED (JERRY_ES2015)
bool proto_seen = false;
#endif /* ENABLED (JERRY_ES2015) */
while (true)
{
lexer_expect_object_literal_id (context_p, LEXER_OBJ_IDENT_NO_OPTS);
@@ -991,6 +995,20 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
#endif /* ENABLED (JERRY_ES2015) */
default:
{
#if ENABLED (JERRY_ES2015)
if ((context_p->token.lit_location.type == LEXER_IDENT_LITERAL
|| context_p->token.lit_location.type == LEXER_STRING_LITERAL)
&& lexer_compare_literal_to_string (context_p, "__proto__", 9))
{
if (proto_seen)
{
parser_raise_error (context_p, PARSER_ERR_DUPLICATED_PROTO);
}
proto_seen = true;
}
#endif /* ENABLED (JERRY_ES2015) */
uint16_t literal_index = context_p->lit_object.index;
#if ENABLED (JERRY_ES2015)