Implement for-await-of statement. (#3946)
AsyncIteratorClose has not supported yet. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -466,7 +466,36 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
register_p++;
|
||||
}
|
||||
|
||||
register_p += executable_object_p->frame_ctx.context_depth;
|
||||
if (executable_object_p->frame_ctx.context_depth > 0)
|
||||
{
|
||||
ecma_value_t *context_end_p = register_p;
|
||||
|
||||
register_p += executable_object_p->frame_ctx.context_depth;
|
||||
|
||||
ecma_value_t *context_top_p = register_p;
|
||||
|
||||
do
|
||||
{
|
||||
uint32_t offsets = vm_get_context_value_offsets (context_top_p);
|
||||
|
||||
while (VM_CONTEXT_HAS_NEXT_OFFSET (offsets))
|
||||
{
|
||||
int32_t offset = VM_CONTEXT_GET_NEXT_OFFSET (offsets);
|
||||
|
||||
if (ecma_is_value_object (context_top_p[offset]))
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (context_top_p[offset]));
|
||||
}
|
||||
|
||||
offsets >>= VM_CONTEXT_OFFSET_SHIFT;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (context_top_p >= context_end_p + offsets);
|
||||
context_top_p -= offsets;
|
||||
}
|
||||
while (context_top_p > context_end_p);
|
||||
}
|
||||
|
||||
register_end_p = executable_object_p->frame_ctx.stack_top_p;
|
||||
|
||||
while (register_p < register_end_p)
|
||||
|
||||
@@ -1865,18 +1865,50 @@ typedef enum
|
||||
ECMA_EXECUTABLE_OBJECT_COMPLETED = (1u << 0), /**< executable object is completed and cannot be resumed */
|
||||
ECMA_EXECUTABLE_OBJECT_RUNNING = (1u << 1), /**< executable object is currently running */
|
||||
/* Generator specific flags. */
|
||||
ECMA_GENERATOR_ITERATE_AND_YIELD = (1u << 2), /**< the generator performs a yield* operation */
|
||||
ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD = (1u << 2), /**< the executable object performs
|
||||
* an await or a yield* operation */
|
||||
ECMA_ASYNC_GENERATOR_CALLED = (1u << 3), /**< the async generator was executed before */
|
||||
/* This must be the last generator specific flag. */
|
||||
ECMA_ASYNC_YIELD_ITERATOR_STATE_SHIFT = 4, /**< shift for async yield iterator state */
|
||||
ECMA_AWAIT_STATE_SHIFT = 4, /**< shift for await states */
|
||||
} ecma_executable_object_flags_t;
|
||||
|
||||
/**
|
||||
* Async function states after an await is completed.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_AWAIT_YIELD_NEXT, /**< wait for an iterator result object */
|
||||
ECMA_AWAIT_YIELD_NEXT_RETURN, /**< wait for an iterator result object after a return operation */
|
||||
ECMA_AWAIT_YIELD_RETURN, /**< wait for the argument passed to return operation */
|
||||
ECMA_AWAIT_YIELD_NEXT_VALUE, /**< wait for the value property of an iterator result object */
|
||||
ECMA_AWAIT_YIELD_OPERATION, /**< wait for the generator operation (next/throw/return) */
|
||||
ECMA_AWAIT_YIELD_CLOSE, /**< wait for the result of iterator close operation */
|
||||
/* After adding new ECMA_AWAIT_YIELD items, the ECMA_AWAIT_YIELD_END should be updated. */
|
||||
ECMA_AWAIT_FOR_NEXT, /**< wait for an iterator result object of for-await-of statement */
|
||||
} ecma_await_states_t;
|
||||
|
||||
/**
|
||||
* Checks whether the executable object is waiting for resuming.
|
||||
*/
|
||||
#define ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED(extra_info) \
|
||||
(!((extra_info) & (ECMA_EXECUTABLE_OBJECT_COMPLETED | ECMA_EXECUTABLE_OBJECT_RUNNING)))
|
||||
|
||||
/**
|
||||
* Last item of yield* related await states.
|
||||
*/
|
||||
#define ECMA_AWAIT_YIELD_END ECMA_AWAIT_YIELD_CLOSE
|
||||
|
||||
/**
|
||||
* Helper macro for ECMA_EXECUTABLE_OBJECT_RESUME_EXEC.
|
||||
*/
|
||||
#define ECMA_EXECUTABLE_OBJECT_RESUME_EXEC_MASK ((uint16_t) ~ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
|
||||
|
||||
/**
|
||||
* Resume execution of the byte code.
|
||||
*/
|
||||
#define ECMA_EXECUTABLE_OBJECT_RESUME_EXEC(executable_object_p) \
|
||||
((executable_object_p)->extended_object.u.class_prop.extra_info &= ECMA_EXECUTABLE_OBJECT_RESUME_EXEC_MASK)
|
||||
|
||||
/**
|
||||
* Enqueued task of an AsyncGenerator.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user