Implement yield* operation in generator functions. (#3407)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2019-12-05 13:50:53 +01:00
committed by Dániel Bátyai
parent 1829d2df55
commit 1a4972fc3f
13 changed files with 476 additions and 143 deletions
+2
View File
@@ -658,6 +658,8 @@
VM_OC_CREATE_GENERATOR) \
CBC_OPCODE (CBC_EXT_YIELD, CBC_NO_FLAG, 0, \
VM_OC_YIELD | VM_OC_GET_STACK) \
CBC_OPCODE (CBC_EXT_YIELD_ITERATOR, CBC_NO_FLAG, 0, \
VM_OC_YIELD | VM_OC_GET_STACK) \
CBC_OPCODE (CBC_EXT_RETURN, CBC_NO_FLAG, -1, \
VM_OC_EXT_RETURN | VM_OC_GET_STACK) \
\
+9 -1
View File
@@ -1563,8 +1563,16 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
parser_check_assignment_expr (context_p);
lexer_next_token (context_p);
cbc_ext_opcode_t opcode = CBC_EXT_YIELD;
if (!lexer_check_yield_no_arg (context_p))
{
if (context_p->token.type == LEXER_MULTIPLY)
{
lexer_next_token (context_p);
opcode = CBC_EXT_YIELD_ITERATOR;
}
parser_parse_expression (context_p, PARSE_EXPR_NO_COMMA);
}
else
@@ -1572,7 +1580,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
parser_emit_cbc (context_p, CBC_PUSH_UNDEFINED);
}
parser_emit_cbc_ext (context_p, CBC_EXT_YIELD);
parser_emit_cbc_ext (context_p, opcode);
return (context_p->token.type != LEXER_RIGHT_PAREN
&& context_p->token.type != LEXER_COMMA);
+4
View File
@@ -648,6 +648,10 @@ scanner_scan_primary_expression (parser_context_t *context_p, /**< context */
scanner_context_p->mode = SCAN_MODE_PRIMARY_EXPRESSION_END;
}
if (context_p->token.type == LEXER_MULTIPLY)
{
return SCAN_NEXT_TOKEN;
}
return SCAN_KEEP_TOKEN;
}
#endif /* ENABLED (JERRY_ES2015) */