Add literal property to the byte code list. (#2397)

Initializing a property with a constant is frequent in object initializers.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-06-20 09:06:59 +02:00
committed by GitHub
parent 7f56756e11
commit acdbbf2261
4 changed files with 14 additions and 4 deletions
+9 -1
View File
@@ -430,7 +430,15 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */
lexer_next_token (context_p);
parser_parse_expression (context_p, PARSE_EXPR_NO_COMMA);
parser_emit_cbc_literal (context_p, CBC_SET_PROPERTY, literal_index);
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
{
context_p->last_cbc_opcode = CBC_SET_LITERAL_PROPERTY;
context_p->last_cbc.value = literal_index;
}
else
{
parser_emit_cbc_literal (context_p, CBC_SET_PROPERTY, literal_index);
}
}
if (context_p->token.type == LEXER_RIGHT_BRACE)