Esempio n. 1
0
        internal void TransformToCall(AstGenerator /*!*/ gen, CallBuilder callBuilder)
        {
            if (_expressions != null)
            {
                foreach (var arg in _expressions)
                {
                    callBuilder.Add(arg.TransformRead(gen));
                }
            }

            if (_maplets != null)
            {
                callBuilder.Add(gen.TransformToHashConstructor(_maplets));
            }

            if (_array != null)
            {
                callBuilder.SplattedArgument = _array.TransformRead(gen);
            }
        }
Esempio n. 2
0
        // arguments: complex arguments (expressions, maplets, splat, block) 
        // singleArgument: siple argument (complex are not used)
        // assignmentRhsArgument: rhs of the assignment: target.method=(rhs)
        internal static MSA.Expression/*!*/ TransformRead(Expression/*!*/ node, AstGenerator/*!*/ gen, bool hasImplicitSelf, 
            string/*!*/ methodName, MSA.Expression/*!*/ transformedTarget,
            Arguments arguments, Block block, MSA.Expression singleArgument, MSA.Expression assignmentRhsArgument) {

            Debug.Assert(assignmentRhsArgument == null || block == null, "Block not allowed in assignment");
            Debug.Assert(singleArgument == null || arguments == null && assignmentRhsArgument == null);
            Assert.NotNull(gen, transformedTarget);
            Assert.NotEmpty(methodName);

            // Pass args in this order:
            // 1. instance
            // 2. block (if present)
            // 3. passed args: normal args, maplets, array
            // 4. RHS of assignment (if present)

            CallBuilder callBuilder = new CallBuilder(gen);
            callBuilder.Instance = transformedTarget;
            
            MSA.Expression blockArgVariable = null;
            MSA.Expression transformedBlock = null;

            if (block != null) {
                blockArgVariable = gen.CurrentScope.DefineHiddenVariable("#block-def", typeof(Proc));
                transformedBlock = block.Transform(gen);
                callBuilder.Block = blockArgVariable;
            }

            if (arguments != null) {
                arguments.TransformToCall(gen, callBuilder);
            } else if (singleArgument != null) {
                callBuilder.Add(singleArgument);
            }

            MSA.Expression rhsVariable = null;
            if (assignmentRhsArgument != null) {
                rhsVariable = gen.CurrentScope.DefineHiddenVariable("#rhs", assignmentRhsArgument.Type);
                callBuilder.RhsArgument = Ast.Assign(rhsVariable, assignmentRhsArgument);
            }

            var dynamicSite = callBuilder.MakeCallAction(methodName, hasImplicitSelf);
            if (gen.Context.CallSiteCreated != null) {
                gen.Context.CallSiteCreated(node, dynamicSite);
            }

            MSA.Expression result = gen.DebugMark(dynamicSite, methodName);

            if (block != null) {
                result = gen.DebugMark(MakeCallWithBlockRetryable(gen, result, blockArgVariable, transformedBlock, block.IsDefinition),
                    "#RB: method call with a block ('" + methodName + "')");
            }

            if (assignmentRhsArgument != null) {
                result = AstFactory.Block(result, rhsVariable);
            }

            return result;
        }
Esempio n. 3
0
        internal void TransformToCall(AstGenerator/*!*/ gen, CallBuilder callBuilder) {
            if (_expressions != null) {
                foreach (var arg in _expressions) {
                    callBuilder.Add(arg.TransformRead(gen));
                }
            }

            if (_maplets != null) {
                callBuilder.Add(gen.TransformToHashConstructor(_maplets));
            }

            if (_array != null) {
                callBuilder.SplattedArgument = _array.TransformRead(gen);
            }
        }
Esempio n. 4
0
        internal void TransformToCall(AstGenerator/*!*/ gen, CallBuilder callBuilder) {
            if (_expressions != null) {
                foreach (var arg in _expressions) {
                    callBuilder.Add(arg.TransformRead(gen));
                }
            }

            if (_maplets != null) {
                callBuilder.Add(gen.TransformToHashConstructor(_maplets));
            }

            if (_array != null) {
                callBuilder.SplattedArgument = 
                    Ast.Dynamic(SplatAction.Make(gen.Context), typeof(IList), _array.TransformRead(gen));
            }
        }
Esempio n. 5
0
        // arguments: complex arguments (expressions, maplets, splat, block)
        // singleArgument: siple argument (complex are not used)
        // assignmentRhsArgument: rhs of the assignment: target.method=(rhs)
        internal static MSA.Expression /*!*/ TransformRead(Expression /*!*/ node, AstGenerator /*!*/ gen, bool hasImplicitSelf,
                                                           string /*!*/ methodName, MSA.Expression /*!*/ transformedTarget,
                                                           Arguments arguments, Block block, MSA.Expression singleArgument, MSA.Expression assignmentRhsArgument)
        {
            Debug.Assert(assignmentRhsArgument == null || block == null, "Block not allowed in assignment");
            Debug.Assert(singleArgument == null || arguments == null && assignmentRhsArgument == null);
            Assert.NotNull(gen, transformedTarget);
            Assert.NotEmpty(methodName);

            // Pass args in this order:
            // 1. instance
            // 2. block (if present)
            // 3. passed args: normal args, maplets, array
            // 4. RHS of assignment (if present)

            CallBuilder callBuilder = new CallBuilder(gen);

            callBuilder.Instance = transformedTarget;

            MSA.Expression blockArgVariable = null;
            MSA.Expression transformedBlock = null;

            if (block != null)
            {
                blockArgVariable  = gen.CurrentScope.DefineHiddenVariable("#block-def", typeof(Proc));
                transformedBlock  = block.Transform(gen);
                callBuilder.Block = blockArgVariable;
            }

            if (arguments != null)
            {
                arguments.TransformToCall(gen, callBuilder);
            }
            else if (singleArgument != null)
            {
                callBuilder.Add(singleArgument);
            }

            MSA.Expression rhsVariable = null;
            if (assignmentRhsArgument != null)
            {
                rhsVariable             = gen.CurrentScope.DefineHiddenVariable("#rhs", assignmentRhsArgument.Type);
                callBuilder.RhsArgument = Ast.Assign(rhsVariable, assignmentRhsArgument);
            }

            var dynamicSite = callBuilder.MakeCallAction(methodName, hasImplicitSelf);

            gen.TraceCallSite(node, dynamicSite);

            MSA.Expression result = gen.DebugMark(dynamicSite, methodName);

            if (block != null)
            {
                result = gen.DebugMark(MakeCallWithBlockRetryable(gen, result, blockArgVariable, transformedBlock, block.IsDefinition),
                                       "#RB: method call with a block ('" + methodName + "')");
            }

            if (assignmentRhsArgument != null)
            {
                result = AstFactory.Block(result, rhsVariable);
            }

            return(result);
        }