Esempio n. 1
0
        public static Proc /*!*/ CreateNew(CallSiteStorage <Func <CallSite, object, object> > /*!*/ storage,
                                           RubyScope /*!*/ scope, RubyClass /*!*/ self)
        {
            RubyMethodScope methodScope = scope.GetInnerMostMethodScope();

            if (methodScope == null || methodScope.BlockParameter == null)
            {
                throw RubyExceptions.CreateArgumentError("tried to create Proc object without a block");
            }

            var proc = methodScope.BlockParameter;

            // an instance of Proc class, the identity is preserved:
            if (self.GetUnderlyingSystemType() == typeof(Proc))
            {
                return(proc);
            }

            // an instance of a Proc subclass:
            var result = new Proc.Subclass(self, proc);

            var initialize = storage.GetCallSite("initialize", new RubyCallSignature(0, RubyCallFlags.HasImplicitSelf));

            initialize.Target(initialize, result);

            return(result);
        }
Esempio n. 2
0
        public static Proc /*!*/ CreateNew(RubyScope /*!*/ scope, RubyClass /*!*/ self)
        {
            RubyMethodScope methodScope = scope.GetInnerMostMethodScope();

            if (methodScope == null || methodScope.BlockParameter == null)
            {
                throw RubyExceptions.CreateArgumentError("tried to create Proc object without a block");
            }

            return(CreateNew(self, methodScope.BlockParameter));
        }