internal DMethodBody(Method orig)
 {
     this.orig = orig;
 }
Exemple #2
0
        internal Method mnew(Frame caller, object obj, string id, bool unbound)//author: Brian, status: done
        {
            RubyMethod method;
            Class klass = this;
            Class rKlass = klass;

        again:
            if (!klass.get_method(id, out method))
                throw new NameError("undefined method " + id).raise(caller);

            if (method.body is CallSuperMethodBody)
            {
                klass = klass.super;
                goto again;
            }

            while (rKlass != klass && (rKlass._type == Type.Singleton || rKlass._type == Type.IClass))
            {
                rKlass = rKlass.super;
            }

            if (klass._type == Type.IClass)
                klass = klass.my_class;

            Method m = new Method(obj, id, id, rKlass, this, method, unbound);
            Object.obj_infect(m, klass);
            return m;
        }
Exemple #3
0
        public override object Call1(Class last_class, object self, Frame caller, Proc block, object recv)
        {
            Method method = (Method)self;
            if (method.rklass != Class.CLASS_OF(recv))
            {
                if (method.rklass._type == Class.Type.Singleton)
                    throw new TypeError("singleton method called for a different object").raise(caller);

                if (!Object.rb_obj_is_kind_of(recv, method.rklass))
                {
                    throw new TypeError("bind argument must be an instance of " + method.rklass.classname()).raise(caller);
                }                
            }

            //Method boundMethod = new Method(recv, method.id, method.oid, Class.CLASS_OF(recv), method.body);
            Method boundMethod = new Method(recv, method.id, method.oid, Class.CLASS_OF(recv), method.oklass, method.body, false);
            return boundMethod;
        }
Exemple #4
0
        public override object Call0(Class last_class, object recv, Frame caller, Proc block)
        {
            Method self = (Method)recv;
            Method clone = new Method(self.recv, self.id, self.oid, self.rklass, self.oklass, self.body, (self.my_class == Ruby.Runtime.Init.rb_cUnboundMethod));
            Object.clone_setup(clone, self);

            return clone;
        }
Exemple #5
0
 public override object Call0(Class last_class, object self, Frame caller, Proc block)
 {
     Method orig = (Method)self;
     Method method = new Method(null, orig.id, orig.oid, orig.rklass, orig.oklass, orig.body, true);
     method.Tainted |= orig.Tainted;
     return method;
 }