????????????? while ????? module ??????????ancestors?????????????????? module?????? for ??????? module ???????????? klass ?????????校??????????????????????????? module ???? c ?? c ????????
????????? module ??????????????????????校????? superclass_seen ?????卸????????????????????????????????????????????????????宓�???????????????????????
?????????????????? 31 ?写?????????????? rb_include_class_new ???????榇�?????????????include class???????? c ????????????????????????????????? c ??????????????? rb_include_class_new ????????未???????????
VALUE
rb_include_class_new(VALUE module?? VALUE super)
{
VALUE klass = class_alloc(T_ICLASS?? rb_cClass);
if (BUILTIN_TYPE(module) == T_ICLASS) {
module = RBASIC(module)->klass;
}
if (!RCLASS_IV_TBL(module)) {
RCLASS_IV_TBL(module) = st_init_numtable();
}
if (!RCLASS_CONST_TBL(module)) {
RCLASS_CONST_TBL(module) = st_init_numtable();
}
RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
RCLASS_CONST_TBL(klass) = RCLASS_CONST_TBL(module);
RCLASS_M_TBL(klass) = RCLASS_M_TBL(RCLASS_ORIGIN(module));
RCLASS_SUPER(klass) = super;
if (RB_TYPE_P(module?? T_ICLASS)) {
RBASIC(klass)->klass = RBASIC(module)->klass;
}
else {
RBASIC(klass)->klass = module;
}
OBJ_INFECT(klass?? module);
OBJ_INFECT(klass?? super);
return (VALUE)klass;
}
?????? 4 ?校?class_alloc ???????????????????????? T_ICLASS ?????????????????Ruby ???????????????????????????械??????????????????????????卸??????????????? klass ?????椋�????????????????????
?????? 17 ???懈? RCLASS_ORIGIN ??????????????????????????Ruby ????校??煤????????锟�?
????#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin)
???????????????????????? origin ?????????????????????????????????????????????械???????????????????????????????Ruby ?????????????????????
?????????些???????????????????????????????????????????????未?????????????????????????????????
????A = Module.new
????B = Module.new
????module C
????include A?? B    # Inclusion is done by this line
????end
????????????? C ?? include ????????????? Module#include ???????????????????? append_features ?? included ???????????????????? Module#append_features ?????????
???????????????????椋琑uby ???????????????????????????椋�???????????????????????????????????????????????榇�?????????????????? C ?????????小?
????????????????????????些????????????????椤�????????????????????????????? Refinement ????????????????????????????????????
????????????????????????????????????????????????????????校???????????????????????????