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:
Zoltan Herczeg
2020-06-25 17:11:16 +02:00
committed by GitHub
parent c12c60c550
commit f88489beef
28 changed files with 1258 additions and 111 deletions
@@ -181,12 +181,13 @@ ecma_op_get_iterator (ecma_value_t value, /**< value to get iterator from */
return value;
}
/* 2. */
bool has_method = !ecma_is_value_empty (method);
bool has_method = false;
if (!has_method)
/* 2. */
if (method == ECMA_VALUE_SYNC_ITERATOR)
{
/* 2.a */
has_method = true;
method = ecma_op_get_method_by_symbol_id (value, LIT_GLOBAL_SYMBOL_ITERATOR);
/* 2.b */
@@ -195,6 +196,17 @@ ecma_op_get_iterator (ecma_value_t value, /**< value to get iterator from */
return method;
}
}
else if (method == ECMA_VALUE_ASYNC_ITERATOR)
{
/* TODO: CreateAsyncFromSyncIterator should be supported. */
has_method = true;
method = ecma_op_get_method_by_symbol_id (value, LIT_GLOBAL_SYMBOL_ASYNC_ITERATOR);
if (ECMA_IS_VALUE_ERROR (method))
{
return method;
}
}
/* 3. */
if (!ecma_is_value_object (method) || !ecma_op_is_callable (method))
@@ -206,7 +218,7 @@ ecma_op_get_iterator (ecma_value_t value, /**< value to get iterator from */
ecma_object_t *method_obj_p = ecma_get_object_from_value (method);
ecma_value_t iterator = ecma_op_function_call (method_obj_p, value, NULL, 0);
if (!has_method)
if (has_method)
{
ecma_deref_object (method_obj_p);
}
@@ -239,7 +251,7 @@ ecma_op_get_iterator (ecma_value_t value, /**< value to get iterator from */
* @return iterator result object - if success
* raised error - otherwise
*/
static ecma_value_t
ecma_value_t
ecma_op_iterator_next (ecma_value_t iterator, /**< iterator value */
ecma_value_t value) /**< the routines's value argument */
{