170 #define enumerator_free RUBY_TYPED_DEFAULT_FREE 208 #define proc_entry_free RUBY_TYPED_DEFAULT_FREE 228 struct proc_entry *ptr;
404 rb_warn(
"Enumerator.new without a block is deprecated; use Object#to_enum");
467 obj, meth, argc, argv, size_fn,
Qnil);
474 const VALUE *argv = 0;
528 #if SIZEOF_INT < SIZEOF_LONG 547 struct MEMO *memo = (
struct MEMO *)m;
991 VALUE eobj, str, cname;
1043 VALUE method, eargs;
1047 if (!
NIL_P(method)) {
1060 eargs = default_args;
1070 VALUE arg = *argv++;
1126 receiver = (*size)(
proc, receiver);
1153 #define yielder_free RUBY_TYPED_DEFAULT_FREE 1158 return sizeof(
struct yielder);
1261 #define generator_free RUBY_TYPED_DEFAULT_FREE 1276 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
1337 "wrong argument type %"PRIsVALUE" (expected Proc)",
1341 rb_warn(
"given block not used");
1443 #define memo_value v2 1444 #define memo_flags u3.state 1445 #define LAZY_MEMO_BREAK 1 1446 #define LAZY_MEMO_PACKED 2 1447 #define LAZY_MEMO_BREAK_P(memo) ((memo)->memo_flags & LAZY_MEMO_BREAK) 1448 #define LAZY_MEMO_PACKED_P(memo) ((memo)->memo_flags & LAZY_MEMO_PACKED) 1449 #define LAZY_MEMO_SET_BREAK(memo) ((memo)->memo_flags |= LAZY_MEMO_BREAK) 1450 #define LAZY_MEMO_SET_VALUE(memo, value) MEMO_V2_SET(memo, value) 1451 #define LAZY_MEMO_SET_PACKED(memo) ((memo)->memo_flags |= LAZY_MEMO_PACKED) 1452 #define LAZY_MEMO_RESET_PACKED(memo) ((memo)->memo_flags &= ~LAZY_MEMO_PACKED) 1467 for (i = 0; i <
RARRAY_LEN(procs_array); i++) {
1470 if (!(*entry->
fn->
proc)(proc, result, memos, i)) {
1482 return result->memo_value;
1501 struct generator *gen_ptr;
1506 obj = old_gen_ptr->
obj;
1602 VALUE new_generator;
1622 new_e->
obj = new_generator;
1623 new_e->
procs = new_procs;
1680 obj, meth, argc, argv, size_fn,
Qnil);
1734 const VALUE *argv = &result->memo_value;
1743 static struct MEMO *
1857 static struct MEMO *
1861 if (!
RTEST(chain))
return 0;
1879 static struct MEMO *
1883 if (
RTEST(chain))
return 0;
1901 static struct MEMO *
1906 if (!
RTEST(chain))
return 0;
1910 static struct MEMO *
1916 if (!
RTEST(chain))
return 0;
1946 if (!
RTEST(result)) {
1958 if (!
RTEST(result)) {
2050 for (i = 0; i <
argc; i++) {
2053 for (; i <
argc; i++) {
2071 static struct MEMO *
2126 static struct MEMO *
2155 if (
NIL_P(receiver))
2159 return LONG2FIX(len < 0 ? 0 : len);
2164 static struct MEMO *
2203 static struct MEMO *
2215 if (
RTEST(drop))
return 0;
static VALUE append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args)
static VALUE lazy_drop(VALUE obj, VALUE n)
static VALUE next_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, obj))
static VALUE lazy_zip_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, zip_args))
static void enumerator_mark(void *p)
VALUE rb_ary_entry(VALUE ary, long offset)
static VALUE next_i(VALUE curr, VALUE obj)
VALUE rb_proc_call_with_block(VALUE, int argc, const VALUE *argv, VALUE)
#define RUBY_TYPED_FREE_IMMEDIATELY
static struct MEMO * lazy_reject_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
static VALUE rb_cGenerator
static VALUE enumerator_rewind(VALUE obj)
static struct MEMO * lazy_drop_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
static VALUE lazy_generator_init(VALUE enumerator, VALUE procs)
static VALUE lazy_reject(VALUE obj)
static VALUE lazy_grep(VALUE obj, VALUE pattern)
VALUE rb_yield_values(int n,...)
static VALUE call_next(VALUE obj)
static unsigned int hash(str, len) register const char *str
static void generator_mark(void *p)
static struct MEMO * lazy_map_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
static VALUE enumerator_peek_values(VALUE obj)
static VALUE yielder_new(void)
static VALUE generator_init_copy(VALUE obj, VALUE orig)
static size_t generator_memsize(const void *p)
static VALUE enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn, VALUE size)
static VALUE enumerator_enum_size(VALUE obj, VALUE args, VALUE eobj)
VALUE rb_enumerator_size_func(VALUE, VALUE, VALUE)
VALUE rb_fiber_resume(VALUE fibval, int argc, const VALUE *argv)
static VALUE lazy_uniq_iter(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
static VALUE yielder_allocate(VALUE klass)
#define OBJ_INIT_COPY(obj, orig)
int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val)
#define TypedData_Get_Struct(obj, type, data_type, sval)
static VALUE lazy_size(VALUE self)
static VALUE yielder_init(VALUE obj, VALUE proc)
ID rb_frame_this_func(void)
static VALUE lazy_zip_arrays_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, arrays))
VALUE rb_ary_push(VALUE ary, VALUE item)
SSL_METHOD *(* func)(void)
static const rb_data_type_t generator_data_type
static const lazyenum_funcs lazy_select_funcs
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
static VALUE enumerator_next_values(VALUE obj)
VALUE rb_fiber_alive_p(VALUE fibval)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_ivar_get(VALUE, ID)
VALUE rb_fiber_current(void)
static const rb_data_type_t yielder_data_type
VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
static VALUE enum_size(VALUE self)
static VALUE enumerator_next(VALUE obj)
void rb_include_module(VALUE klass, VALUE module)
static VALUE enumerator_block_call(VALUE obj, rb_block_call_func *func, VALUE arg)
VALUE rb_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE)
void rb_gc_mark(VALUE ptr)
static struct MEMO * lazy_grep_iter_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
static VALUE lazy_init_iterator(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
static VALUE lazy_to_enum(int argc, VALUE *argv, VALUE self)
#define MEMO_NEW(a, b, c)
static VALUE lazy_uniq_func(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
static VALUE yielder_yield(VALUE obj, VALUE args)
VALUE rb_ary_cat(VALUE ary, const VALUE *argv, long len)
static VALUE lazy_init_block(VALUE val, VALUE m, int argc, VALUE *argv)
VALUE rb_str_buf_append(VALUE, VALUE)
static VALUE generator_initialize(int argc, VALUE *argv, VALUE obj)
#define LAZY_MEMO_SET_VALUE(memo, value)
static VALUE generator_allocate(VALUE klass)
static VALUE enumerator_with_object(VALUE obj, VALUE memo)
void InitVM_Enumerator(void)
rb_enumerator_size_func * size_fn
static VALUE lazy_flat_map(VALUE obj)
static struct MEMO * lazy_grep_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
void rb_exc_raise(VALUE mesg)
static VALUE lazy_map(VALUE obj)
static struct enumerator * enumerator_ptr(VALUE obj)
static const lazyenum_funcs lazy_reject_funcs
#define RB_TYPE_P(obj, type)
static VALUE lazy_take_size(VALUE entry, VALUE receiver)
static VALUE lazy_init_yielder(VALUE val, VALUE m, int argc, VALUE *argv)
static VALUE enumerable_lazy(VALUE obj)
VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
static struct MEMO * lazy_take_while_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
static VALUE get_next_values(VALUE obj, struct enumerator *e)
static VALUE lazy_flat_map_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, yielder))
static VALUE enumerator_each(int argc, VALUE *argv, VALUE obj)
static VALUE enumerator_with_index(int argc, VALUE *argv, VALUE obj)
VALUE rb_enumeratorize_with_size(VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn)
int rb_block_given_p(void)
static VALUE lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo, const lazyenum_funcs *fn)
static struct MEMO * lazy_select_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
static VALUE obj_to_enum(int argc, VALUE *argv, VALUE obj)
RUBY_EXTERN VALUE rb_cObject
static VALUE lazy_grep_v_iter(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
static VALUE lazyenum_size(VALUE self, VALUE args, VALUE eobj)
VALUE rb_str_buf_cat2(VALUE, const char *)
static const lazyenum_funcs lazy_map_funcs
static VALUE lazyenum_yield_values(VALUE proc_entry, struct MEMO *result)
RUBY_EXTERN VALUE rb_mKernel
static VALUE enumerator_peek_values_m(VALUE obj)
#define LAZY_MEMO_RESET_PACKED(memo)
static VALUE enumerator_size(VALUE obj)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
static void next_init(VALUE obj, struct enumerator *e)
static size_t proc_entry_memsize(const void *p)
void rb_ary_store(VALUE ary, long idx, VALUE val)
lazyenum_size_func * size
struct MEMO * lazyenum_proc_func(VALUE, struct MEMO *, VALUE, long)
static struct generator * generator_ptr(VALUE obj)
VALUE rb_fiber_new(VALUE(*func)(ANYARGS), VALUE obj)
static VALUE stop_result(VALUE self)
#define ALLOCV_N(type, v, n)
static VALUE lazy_init_block_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
static const rb_data_type_t proc_entry_data_type
static const lazyenum_funcs lazy_drop_funcs
static VALUE lazy_take_while(VALUE obj)
static VALUE lazy_select(VALUE obj)
#define MEMCPY(p1, p2, type, n)
static VALUE lazy_flat_map_proc(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
#define LAZY_MEMO_SET_BREAK(memo)
static VALUE generator_init(VALUE obj, VALUE proc)
static VALUE lazy_receiver_size(VALUE generator, VALUE args, VALUE lazy)
static VALUE yielder_yield_push(VALUE obj, VALUE args)
VALUE rb_int_succ(VALUE num)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
static VALUE lazy_super(int argc, VALUE *argv, VALUE lazy)
static VALUE lazy_map_size(VALUE entry, VALUE receiver)
#define RARRAY_CONST_PTR(a)
VALUE rb_obj_is_proc(VALUE)
static VALUE lazy_take(VALUE obj, VALUE n)
VALUE rb_sprintf(const char *format,...)
#define MEMO_V1_SET(m, v)
VALUE rb_class_path(VALUE)
VALUE rb_fiber_yield(int argc, const VALUE *argv)
static VALUE lazy_to_enum_i(VALUE self, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn)
static VALUE enumerator_each_with_index(VALUE obj)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
VALUE rb_ivar_set(VALUE, ID, VALUE)
VALUE lazyenum_size_func(VALUE, VALUE)
static VALUE lazy_grep_v(VALUE obj, VALUE pattern)
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
VALUE rb_obj_hide(VALUE obj)
static size_t enumerator_memsize(const void *p)
VALUE rb_rescue2(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2,...)
VALUE rb_check_funcall(VALUE, ID, int, const VALUE *)
VALUE rb_call_super(int, const VALUE *)
VALUE rb_proc_call(VALUE, VALUE)
static VALUE enumerator_initialize(int argc, VALUE *argv, VALUE obj)
#define RARRAY_LENINT(ary)
static VALUE generator_each(int argc, VALUE *argv, VALUE obj)
#define LAZY_MEMO_BREAK_P(memo)
static VALUE lazy_lazy(VALUE obj)
static VALUE lazy_initialize(int argc, VALUE *argv, VALUE self)
static const lazyenum_funcs lazy_grep_funcs
int rb_respond_to(VALUE, ID)
register unsigned int len
VALUE rb_ary_new_from_values(long n, const VALUE *elts)
VALUE rb_yield_values2(int n, const VALUE *argv)
#define UNLIMITED_ARGUMENTS
static VALUE lazy_uniq_i(VALUE i, VALUE hash, int argc, const VALUE *argv, VALUE yielder)
VALUE rb_enum_values_pack(int argc, const VALUE *argv)
static VALUE inspect_enumerator(VALUE obj, VALUE dummy, int recur)
#define RARRAY_AREF(a, i)
static VALUE lazy_uniq(VALUE obj)
VALUE rb_block_proc(void)
lazyenum_proc_func * proc
static VALUE next_stopped(VALUE obj)
static struct MEMO * lazy_take_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
VALUE rb_check_array_type(VALUE ary)
static VALUE enumerator_with_object_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, memo))
static struct proc_entry * proc_entry_ptr(VALUE proc_entry)
static void yielder_mark(void *p)
VALUE rb_enumeratorize(VALUE obj, VALUE meth, int argc, const VALUE *argv)
static VALUE lazyenum_yield(VALUE proc_entry, struct MEMO *result)
static struct MEMO * lazy_drop_while_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_index)
VALUE rb_proc_new(VALUE(*)(ANYARGS), VALUE)
void Init_Enumerator(void)
#define LAZY_MEMO_PACKED_P(memo)
#define TypedData_Make_Struct(klass, type, data_type, sval)
VALUE rb_ary_dup(VALUE ary)
static VALUE enumerator_allocate(VALUE klass)
static VALUE lazy_set_method(VALUE lazy, VALUE args, rb_enumerator_size_func *size_fn)
static VALUE enumerator_init_copy(VALUE obj, VALUE orig)
static const lazyenum_funcs lazy_drop_while_funcs
static VALUE lazy_flat_map_to_ary(VALUE obj, VALUE yielder)
static const rb_data_type_t enumerator_data_type
static VALUE lazy_drop_size(VALUE proc_entry, VALUE receiver)
static VALUE yielder_initialize(VALUE obj)
const lazyenum_funcs * fn
static VALUE ary2sv(VALUE args, int dup)
static const lazyenum_funcs lazy_take_while_funcs
static VALUE lazy_grep_v_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
static VALUE enumerator_peek(VALUE obj)
#define rb_check_frozen(obj)
static size_t yielder_memsize(const void *p)
static VALUE lazy_drop_while(VALUE obj)
static VALUE enumerator_inspect(VALUE obj)
static void proc_entry_mark(void *p)
static VALUE lazy_zip(int argc, VALUE *argv, VALUE obj)
static VALUE enumerator_with_index_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
static const lazyenum_funcs lazy_grep_iter_funcs
static VALUE yielder_yield_i(RB_BLOCK_CALL_FUNC_ARGLIST(obj, memo))
static void lazy_set_args(VALUE lazy, VALUE args)
static VALUE enumerator_feed(VALUE obj, VALUE v)
static struct yielder * yielder_ptr(VALUE obj)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_append(VALUE, VALUE)
static const lazyenum_funcs lazy_take_funcs
void rb_provide(const char *)
void rb_warn(const char *fmt,...)
static VALUE lazy_flat_map_each(VALUE obj, VALUE yielder)
VALUE rb_attr_get(VALUE, ID)
VALUE rb_obj_class(VALUE)