njs_generate_for_in_statement(njs_vm_t *vm, njs_generator_t *generator,
    njs_parser_node_t *node)
{
    njs_int_t                 ret;
    njs_parser_node_t         *foreach, *name;
    njs_generator_loop_ctx_t  ctx;

    ret = njs_generate_start_block(vm, generator, NJS_GENERATOR_LOOP,
                                   &node->name);
    if (njs_slow_path(ret != NJS_OK)) {
        return ret;
    }

    /* The object. */

    foreach = node->left;
    name = foreach->left->right;

    if (name != NULL) {
        name = name->left;

        ret = njs_generate_variable_wo_dest(vm, generator, name,
                                            NJS_DECLARATION, &ctx.var);
        if (njs_slow_path(ret != NJS_OK)) {
            return NJS_ERROR;
        }

        foreach->left->index = name->index;

        njs_generator_next(generator, njs_generate, foreach->right);

        return njs_generator_after(vm, generator,
                                   njs_queue_first(&generator->stack), node,
                                   njs_generate_for_in_object,
                                   &ctx, sizeof(njs_generator_loop_ctx_t));
    }

    njs_generator_next(generator, njs_generate, foreach->left);

    ret = njs_generator_after(vm, generator,
                              njs_queue_first(&generator->stack), node,
                              njs_generate_for_in_object,
                              &ctx, sizeof(njs_generator_loop_ctx_t));
    if (njs_slow_path(ret != NJS_OK)) {
        return ret;
    }

    return njs_generator_after(vm, generator,
                               njs_queue_first(&generator->stack),
                               foreach->right, njs_generate, NULL, 0);
}
njs_generate_for_in_statement(njs_vm_t *vm, njs_generator_t *generator,
    njs_parser_node_t *node)
{
    njs_int_t                 ret;
    njs_parser_node_t         *foreach, *name;
    njs_generator_loop_ctx_t  ctx;

    ret = njs_generate_start_block(vm, generator, NJS_GENERATOR_LOOP,
                                   &node->name);
    if (njs_slow_path(ret != NJS_OK)) {
        return ret;
    }

     

    foreach = node->left;
    name = foreach->left->right;

    if (name != NULL) {
        name = name->left;

        ret = njs_generate_variable_wo_dest(vm, generator, name,
                                            NJS_DECLARATION, &ctx.var);
        if (njs_slow_path(ret != NJS_OK)) {
            return NJS_ERROR;
        }

        foreach->left->index = name->index;

        njs_generator_next(generator, njs_generate, foreach->right);

        return njs_generator_after(vm, generator,
                                   njs_queue_first(&generator->stack), node,
                                   njs_generate_for_in_object,
                                   &ctx, sizeof(njs_generator_loop_ctx_t));
    }

    njs_generator_next(generator, njs_generate, foreach->left);

    ret = njs_generator_after(vm, generator,
                              njs_queue_first(&generator->stack), node,
                              njs_generate_for_in_object,
                              &ctx, sizeof(njs_generator_loop_ctx_t));
    if (njs_slow_path(ret != NJS_OK)) {
        return ret;
    }

    return njs_generator_after(vm, generator,
                               njs_queue_first(&generator->stack),
                               foreach->right, njs_generate, NULL, 0);
}