njs_generate_for_in_object(njs_vm_t *vm, njs_generator_t *generator,
    njs_parser_node_t *node)
{
    njs_parser_node_t          *foreach, *name;
    njs_generator_loop_ctx_t   *ctx;
    njs_vmcode_prop_foreach_t  *prop_foreach;

    ctx = generator->context;

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

    if (name != NULL) {
        ctx->var->init = 1;
    }

    njs_generate_code(generator, njs_vmcode_prop_foreach_t, prop_foreach,
                      NJS_VMCODE_PROPERTY_FOREACH, 2, foreach);
    ctx->jump_offset = njs_code_offset(generator, prop_foreach);
    prop_foreach->object = foreach->right->index;

    ctx->index = njs_generate_temp_index_get(vm, generator, foreach->right);
    if (njs_slow_path(ctx->index == NJS_INDEX_ERROR)) {
        return NJS_ERROR;
    }

    prop_foreach->next = ctx->index;

    /* The loop body. */

    ctx->loop_offset = njs_code_offset(generator, generator->code_end);

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

    return njs_generator_after(vm, generator,
                               njs_queue_first(&generator->stack), node,
                               njs_generate_for_in_body, ctx, 0);
}
njs_generate_for_in_object(njs_vm_t *vm, njs_generator_t *generator,
    njs_parser_node_t *node)
{
    njs_parser_node_t          *foreach, *name;
    njs_generator_loop_ctx_t   *ctx;
    njs_vmcode_prop_foreach_t  *prop_foreach;

    ctx = generator->context;

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

    if (name != NULL) {
        ctx->var->init = 1;
    }

    njs_generate_code(generator, njs_vmcode_prop_foreach_t, prop_foreach,
                      NJS_VMCODE_PROPERTY_FOREACH, 2, foreach);
    ctx->jump_offset = njs_code_offset(generator, prop_foreach);
    prop_foreach->object = foreach->right->index;

    ctx->index = njs_generate_temp_index_get(vm, generator, foreach->right);
    if (njs_slow_path(ctx->index == NJS_INDEX_ERROR)) {
        return NJS_ERROR;
    }

    prop_foreach->next = ctx->index;

     

    ctx->loop_offset = njs_code_offset(generator, generator->code_end);

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

    return njs_generator_after(vm, generator,
                               njs_queue_first(&generator->stack), node,
                               njs_generate_for_in_body, ctx, 0);
}