Exemple #1
0
        public static object EvaluateInSingleton(object self, BlockParam /*!*/ block)
        {
            // TODO: this is checked in method definition, if no method is defined it is ok.
            // => singleton is create in method definition also.
            if (!RubyUtils.CanCreateSingleton(self))
            {
                throw RubyExceptions.CreateTypeError("can't define singleton method for literals");
            }

            block.ModuleDeclaration = block.RubyContext.CreateSingletonClass(self);

            // TODO: flows Public visibility in the block
            // Flow "Singleton" method attribute? If we change method attribute
            object returnValue = RubyOps.Yield1(self, self, block);

            block.BlockJumped(returnValue);
            return(returnValue);
        }
Exemple #2
0
        public bool Yield(object[] /*!*/ args, out object blockResult)
        {
            ContractUtils.RequiresNotNull(args, "args");
            switch (args.Length)
            {
            case 0: blockResult = RubyOps.Yield0(Self, this); break;

            case 1: blockResult = RubyOps.Yield1(args[0], Self, this); break;

            case 2: blockResult = RubyOps.Yield2(args[0], args[1], Self, this); break;

            case 3: blockResult = RubyOps.Yield3(args[0], args[1], args[2], Self, this); break;

            case 4: blockResult = RubyOps.Yield4(args[0], args[1], args[2], args[3], Self, this); break;

            default: blockResult = RubyOps.YieldN(args, Self, this); break;
            }
            return(BlockJumped(blockResult));
        }
Exemple #3
0
 public bool Yield(object arg1, out object blockResult)
 {
     return(BlockJumped(blockResult = RubyOps.Yield1(arg1, null, Self, this)));
 }
Exemple #4
0
 private static object EvaluateInModuleNoJumpCheck(RubyModule /*!*/ self, BlockParam /*!*/ block)
 {
     block.ModuleDeclaration = self;
     return(RubyOps.Yield1(self, self, block));
 }