Exemple #1
0
        static void RecurseParameters(AstNodeList parameterList, AstNode node)
        {
            if (node != null)
            {
                // if this is a comma operator, then we need to
                var binOp = node as BinaryExpression;
                if (binOp != null && binOp.OperatorToken == JSToken.Comma)
                {
                    // there are two or more parameters - recurse the list so we get them added left to right,
                    // converting each one to a binding object
                    RecurseParameters(parameterList, binOp.Operand1);

                    // comma operators can flatten lots of commas to an element on the left, and subsequent
                    // elements in a list on the right.
                    var rightList = binOp.Operand2 as AstNodeList;
                    if (rightList != null)
                    {
                        foreach (var listItem in rightList.Children)
                        {
                            parameterList.Append(ConvertToParameter(listItem, parameterList.Count));
                        }
                    }
                    else
                    {
                        // nope, just a single item
                        parameterList.Append(ConvertToParameter(binOp.Operand2, parameterList.Count));
                    }
                }
                else
                {
                    // nope; single operand to convert to a parameter
                    parameterList.Append(ConvertToParameter(node, 0));
                }
            }
        }