Exemplo n.º 1
0
        /// <summary>
        /// From control flow perspective it "calls" the proc.
        /// </summary>
        internal static void SetProcCallRule(
            MetaObjectBuilder /*!*/ metaBuilder,
            Expression /*!*/ procExpression,    // proc object
            Expression /*!*/ selfExpression,    // self passed to the proc
            Expression callingMethodExpression, // RubyLambdaMethodInfo passed to the proc via BlockParam
            CallArguments /*!*/ args            // user arguments passed to the proc
            )
        {
            var bfcVariable    = metaBuilder.GetTemporary(typeof(BlockParam), "#bfc");
            var resultVariable = metaBuilder.GetTemporary(typeof(object), "#result");

            metaBuilder.Result = AstFactory.Block(
                Ast.Assign(bfcVariable,
                           (callingMethodExpression != null) ?
                           Methods.CreateBfcForMethodProcCall.OpCall(
                               AstUtils.Convert(procExpression, typeof(Proc)),
                               callingMethodExpression
                               ) :
                           Methods.CreateBfcForProcCall.OpCall(
                               AstUtils.Convert(procExpression, typeof(Proc))
                               )
                           ),
                Ast.Assign(resultVariable, AstFactory.YieldExpression(
                               args.GetSimpleArgumentExpressions(),
                               args.GetSplattedArgumentExpression(),
                               args.GetRhsArgumentExpression(),
                               bfcVariable,
                               selfExpression
                               )),
                Methods.MethodProcCall.OpCall(bfcVariable, resultVariable),
                resultVariable
                );
        }
Exemplo n.º 2
0
        /// <summary>
        /// OldCallAction on Proc target.
        /// From control flow perspective it "yields" to the proc.
        /// </summary>
        internal void SetCallActionRule(MetaObjectBuilder /*!*/ metaBuilder, CallArguments /*!*/ args)
        {
            Assert.NotNull(metaBuilder, args);
            Debug.Assert(!args.Signature.HasBlock);

            var convertedTarget = AstUtils.Convert(args.TargetExpression, typeof(BlockParam));

            // test for target type:
            metaBuilder.AddTypeRestriction(args.Target.GetType(), args.TargetExpression);

            metaBuilder.Result = AstFactory.YieldExpression(
                args.GetSimpleArgumentExpressions(),
                args.GetSplattedArgumentExpression(),
                args.GetRhsArgumentExpression(),
                convertedTarget,                              // block param
                Ast.Property(convertedTarget, SelfProperty)   // self
                );
        }
Exemplo n.º 3
0
        /// <summary>
        /// From control flow perspective it "calls" the proc.
        /// </summary>
        internal static void BuildCall(
            MetaObjectBuilder /*!*/ metaBuilder,
            Expression /*!*/ procExpression,     // proc object
            Expression /*!*/ selfExpression,     // self passed to the proc
            CallArguments /*!*/ args             // user arguments passed to the proc
            )
        {
            var bfcVariable = metaBuilder.GetTemporary(typeof(BlockParam), "#bfc");

            metaBuilder.Result = Ast.Block(
                Ast.Assign(bfcVariable, Methods.CreateBfcForProcCall.OpCall(AstUtils.Convert(procExpression, typeof(Proc)))),
                Methods.MethodProcCall.OpCall(bfcVariable,
                                              AstFactory.YieldExpression(
                                                  args.RubyContext,
                                                  args.GetSimpleArgumentExpressions(),
                                                  args.GetSplattedArgumentExpression(),
                                                  args.GetRhsArgumentExpression(),
                                                  bfcVariable,
                                                  selfExpression
                                                  )
                                              )
                );
        }