Implement yield* operator (#3923)
Missing features: - caching next() method (this also true for normal generators) - automatic sync to async generator conversion JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -75,7 +75,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *executable_o
|
||||
{
|
||||
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_GENERATOR_ITERATE_AND_YIELD)
|
||||
{
|
||||
ecma_value_t iterator = executable_object_p->extended_object.u.class_prop.u.value;
|
||||
ecma_value_t iterator = executable_object_p->frame_ctx.block_result;
|
||||
|
||||
bool done = false;
|
||||
ecma_value_t result = ecma_op_iterator_do (resume_mode, iterator, arg, &done);
|
||||
@@ -102,6 +102,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *executable_o
|
||||
}
|
||||
|
||||
executable_object_p->extended_object.u.class_prop.extra_info &= (uint16_t) ~ECMA_GENERATOR_ITERATE_AND_YIELD;
|
||||
executable_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (arg))
|
||||
{
|
||||
@@ -137,7 +138,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *executable_o
|
||||
|
||||
if (byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR)
|
||||
{
|
||||
ecma_value_t iterator = ecma_op_get_iterator (value, ECMA_VALUE_EMPTY);
|
||||
ecma_value_t iterator = ecma_op_get_iterator (value, ECMA_VALUE_SYNC_ITERATOR);
|
||||
ecma_free_value (value);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (iterator))
|
||||
@@ -149,7 +150,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *executable_o
|
||||
|
||||
ecma_deref_object (ecma_get_object_from_value (iterator));
|
||||
executable_object_p->extended_object.u.class_prop.extra_info |= ECMA_GENERATOR_ITERATE_AND_YIELD;
|
||||
executable_object_p->extended_object.u.class_prop.u.value = iterator;
|
||||
executable_object_p->frame_ctx.block_result = iterator;
|
||||
arg = ECMA_VALUE_UNDEFINED;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* ECMA-262 v10, 19.4.2.1 */
|
||||
SYMBOL_VALUE (LIT_GLOBAL_SYMBOL_ASYNC_ITERATOR,
|
||||
LIT_MAGIC_STRING_ASYNC_ITERATOR)
|
||||
|
||||
/* ECMA-262 v6, 19.4.2.2 */
|
||||
SYMBOL_VALUE (LIT_GLOBAL_SYMBOL_HAS_INSTANCE,
|
||||
LIT_MAGIC_STRING_HAS_INSTANCE)
|
||||
|
||||
@@ -527,8 +527,9 @@ ecma_builtin_promise_race_or_all (ecma_value_t this_arg, /**< 'this' argument */
|
||||
return capability;
|
||||
}
|
||||
|
||||
ecma_value_t iterator = ecma_builtin_promise_reject_abrupt (ecma_op_get_iterator (iterable, ECMA_VALUE_EMPTY),
|
||||
capability);
|
||||
ecma_value_t iterator;
|
||||
iterator = ecma_builtin_promise_reject_abrupt (ecma_op_get_iterator (iterable, ECMA_VALUE_SYNC_ITERATOR),
|
||||
capability);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (iterator))
|
||||
{
|
||||
|
||||
@@ -41,6 +41,11 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_SYMBOL_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ECMA-262 v10, 19.4.2.1 */
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_ASYNC_ITERATOR,
|
||||
LIT_GLOBAL_SYMBOL_ASYNC_ITERATOR,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ECMA-262 v6, 19.4.2.2 */
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_HAS_INSTANCE,
|
||||
LIT_GLOBAL_SYMBOL_HAS_INSTANCE,
|
||||
|
||||
Reference in New Issue
Block a user