summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authorMatt Valentine-House <matt@eightbitraptor.com>2023-03-16 22:26:34 +0000
committerMatt Valentine-House <matt@eightbitraptor.com>2023-03-17 19:20:40 +0000
commit22b349294b923990eba299bcf17aa6b1543df700 (patch)
tree1c69d17149db37c49fcfd700d74e7b23bfc64766 /enumerator.c
parent405966e239d9c443f987e7e8f2cec460ffa2da38 (diff)
downloadruby-22b349294b923990eba299bcf17aa6b1543df700.tar.gz
Implement declarative references for enumerator
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c51
1 files changed, 15 insertions, 36 deletions
diff --git a/enumerator.c b/enumerator.c
index b2f8855503..b33c171371 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -188,6 +188,18 @@ struct enumerator {
int kw_splat;
};
+RUBY_REFERENCES_START(enumerator_refs)
+ REF_EDGE(enumerator, obj),
+ REF_EDGE(enumerator, args),
+ REF_EDGE(enumerator, fib),
+ REF_EDGE(enumerator, dst),
+ REF_EDGE(enumerator, lookahead),
+ REF_EDGE(enumerator, feedvalue),
+ REF_EDGE(enumerator, stop_exc),
+ REF_EDGE(enumerator, size),
+ REF_EDGE(enumerator, procs),
+RUBY_REFERENCES_END
+
static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer;
struct generator {
@@ -237,39 +249,6 @@ struct enum_product {
VALUE rb_cArithSeq;
-/*
- * Enumerator
- */
-static void
-enumerator_mark(void *p)
-{
- struct enumerator *ptr = p;
- rb_gc_mark_movable(ptr->obj);
- rb_gc_mark_movable(ptr->args);
- rb_gc_mark_movable(ptr->fib);
- rb_gc_mark_movable(ptr->dst);
- rb_gc_mark_movable(ptr->lookahead);
- rb_gc_mark_movable(ptr->feedvalue);
- rb_gc_mark_movable(ptr->stop_exc);
- rb_gc_mark_movable(ptr->size);
- rb_gc_mark_movable(ptr->procs);
-}
-
-static void
-enumerator_compact(void *p)
-{
- struct enumerator *ptr = p;
- ptr->obj = rb_gc_location(ptr->obj);
- ptr->args = rb_gc_location(ptr->args);
- ptr->fib = rb_gc_location(ptr->fib);
- ptr->dst = rb_gc_location(ptr->dst);
- ptr->lookahead = rb_gc_location(ptr->lookahead);
- ptr->feedvalue = rb_gc_location(ptr->feedvalue);
- ptr->stop_exc = rb_gc_location(ptr->stop_exc);
- ptr->size = rb_gc_location(ptr->size);
- ptr->procs = rb_gc_location(ptr->procs);
-}
-
#define enumerator_free RUBY_TYPED_DEFAULT_FREE
static size_t
@@ -281,12 +260,12 @@ enumerator_memsize(const void *p)
static const rb_data_type_t enumerator_data_type = {
"enumerator",
{
- enumerator_mark,
+ REFS_LIST_PTR(enumerator_refs),
enumerator_free,
enumerator_memsize,
- enumerator_compact,
+ NULL,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, NULL, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_DECL_MARKING
};
static struct enumerator *