mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
This commit is contained in:
+26
-6
@@ -759,17 +759,29 @@ MRB_API mrb_value
|
||||
mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
|
||||
{
|
||||
struct RClass * cls = c;
|
||||
mrb_value v;
|
||||
|
||||
while (c) {
|
||||
if (c->iv) {
|
||||
iv_tbl *t = c->iv;
|
||||
mrb_value v;
|
||||
|
||||
if (iv_get(mrb, t, sym, &v))
|
||||
return v;
|
||||
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
|
||||
return v;
|
||||
}
|
||||
c = c->super;
|
||||
}
|
||||
if (cls && cls->tt == MRB_TT_SCLASS) {
|
||||
mrb_value klass;
|
||||
|
||||
klass = mrb_obj_iv_get(mrb, (struct RObject *)cls,
|
||||
mrb_intern_lit(mrb, "__attached__"));
|
||||
c = mrb_class_ptr(klass);
|
||||
if (c->tt == MRB_TT_CLASS) {
|
||||
while (c) {
|
||||
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
|
||||
return v;
|
||||
}
|
||||
c = c->super;
|
||||
}
|
||||
}
|
||||
}
|
||||
mrb_name_error(mrb, sym, "uninitialized class variable %S in %S",
|
||||
mrb_sym2str(mrb, sym), mrb_obj_value(cls));
|
||||
/* not reached */
|
||||
@@ -914,6 +926,14 @@ mrb_vm_const_get(mrb_state *mrb, mrb_sym sym)
|
||||
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
|
||||
return v;
|
||||
}
|
||||
if (c->tt == MRB_TT_SCLASS) {
|
||||
mrb_value klass;
|
||||
klass = mrb_obj_iv_get(mrb, (struct RObject *)c,
|
||||
mrb_intern_lit(mrb, "__attached__"));
|
||||
c2 = mrb_class_ptr(klass);
|
||||
if (c2->tt == MRB_TT_CLASS)
|
||||
c = c2;
|
||||
}
|
||||
c2 = c;
|
||||
for (;;) {
|
||||
c2 = mrb_class_outer_module(mrb, c2);
|
||||
|
||||
@@ -2208,15 +2208,6 @@ RETRY_TRY_BLOCK:
|
||||
}
|
||||
else {
|
||||
p = mrb_proc_new(mrb, irep->reps[GETARG_b(i)]);
|
||||
if (c & OP_L_METHOD) {
|
||||
if (p->target_class->tt == MRB_TT_SCLASS) {
|
||||
mrb_value klass;
|
||||
klass = mrb_obj_iv_get(mrb,
|
||||
(struct RObject *)p->target_class,
|
||||
mrb_intern_lit(mrb, "__attached__"));
|
||||
p->target_class = mrb_class_ptr(klass);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c & OP_L_STRICT) p->flags |= MRB_PROC_STRICT;
|
||||
regs[GETARG_A(i)] = mrb_obj_value(p);
|
||||
|
||||
Reference in New Issue
Block a user