Пример #1
0
        internal static Class rb_make_metaclass(Basic obj, Class super) //status: done
        {
            Class klass = new Class("meta->" + (obj is Class ? ((Class)obj)._name : "??"), super, Type.Singleton);
            obj.my_class = klass;
            klass.attached = obj;

            if (obj is Class && ((Class)obj)._type == Type.Singleton)
            {
                klass.my_class = klass;
                klass.super = ((Class)obj).super.class_real().my_class;
            }
            else
            {
                Class metasuper = super.class_real().my_class;

                if (metasuper != null)
                    klass.my_class = metasuper;
            }

            return klass;
        }
Пример #2
0
        private static Class singleton_class(Basic obj) //status: done
        {
            Class singleton;

            if (obj.my_class._type == Type.Singleton && obj.my_class.attached == obj)
                singleton = obj.my_class;
            else
                singleton = rb_make_metaclass(obj, obj.my_class);

            if (obj.Tainted)
                singleton.Tainted = true;
            else
                singleton.Tainted = false;

            if (obj.Frozen)
                singleton.Frozen = true;

            return singleton;
        }