Encapsulate RCLASS_ATTACHED_OBJECT

Right now the attached object is stored as an instance variable
and all the call sites that either get or set it have to know how it's
stored.

It's preferable to hide this implementation detail behind accessors
so that it is easier to change how it's stored.
This commit is contained in:
Jean Boussier 2023-02-15 10:42:52 +01:00 committed by Jean Boussier
parent bac4d2eefa
commit 7413079dae
Notes: git 2023-02-15 14:24:43 +00:00
13 changed files with 44 additions and 29 deletions

View file

@ -11,6 +11,7 @@
#include "eval_intern.h"
#include "internal.h"
#include "internal/class.h"
#include "internal/error.h"
#include "internal/vm.h"
#include "iseq.h"
@ -1746,7 +1747,7 @@ rb_profile_frame_classpath(VALUE frame)
klass = RBASIC(klass)->klass;
}
else if (FL_TEST(klass, FL_SINGLETON)) {
klass = rb_ivar_get(klass, id__attached__);
klass = RCLASS_ATTACHED_OBJECT(klass);
if (!RB_TYPE_P(klass, T_CLASS) && !RB_TYPE_P(klass, T_MODULE))
return rb_sprintf("#<%s:%p>", rb_class2name(rb_obj_class(klass)), (void*)klass);
}