当前位置: 首页>>代码示例>>C#>>正文


C# LocalSymbol.AsReadOnlyWrap方法代码示例

本文整理汇总了C#中LocalSymbol.AsReadOnlyWrap方法的典型用法代码示例。如果您正苦于以下问题:C# LocalSymbol.AsReadOnlyWrap方法的具体用法?C# LocalSymbol.AsReadOnlyWrap怎么用?C# LocalSymbol.AsReadOnlyWrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LocalSymbol的用法示例。


在下文中一共展示了LocalSymbol.AsReadOnlyWrap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RewriteArguments


//.........这里部分代码省略.........
                {
                    refKinds.Add(RefKind.None);
                }
            }

            ArrayBuilder<BoundAssignmentOperator> storesToTemps = null;
            ArrayBuilder<BoundExpression> paramArray = null;

            if (expanded)
            {
                paramArray = ArrayBuilder<BoundExpression>.GetInstance();
            }

            for (int a = 0; a < rewrittenArguments.Count; ++a)
            {
                var argument = rewrittenArguments[a];
                var p = (argsToParamsOpt.IsNotNull) ? argsToParamsOpt[a] : a;
                var refKind = argumentRefKinds.RefKinds(a);
                Debug.Assert(arguments[p] == null);
                if (expanded && p == parameterCount - 1)
                {
                    paramArray.Add(argument);
                    Debug.Assert(refKind == RefKind.None);
                }
                else if (IsSafeForReordering(argument, refKind))
                {
                    arguments[p] = argument;
                    if (refKinds != null)
                    {
                        refKinds[p] = refKind;
                    }
                }
                else
                {
                    if (storesToTemps == null)
                    {
                        storesToTemps = ArrayBuilder<BoundAssignmentOperator>.GetInstance(rewrittenArguments.Count);
                    }

                    var tempStore = TempHelpers.StoreToTemp(argument, refKind, containingSymbol);
                    storesToTemps.Add(tempStore.Item1);
                    arguments[p] = tempStore.Item2;
                }
            }

            if (expanded)
            {
                var paramArrayType = parameters[parameterCount - 1].Type;
                var arrayArgs = paramArray.ToReadOnlyAndFree();

                var int32Type = method.ContainingAssembly.GetPrimitiveType(Microsoft.Cci.PrimitiveTypeCode.Int32);

                arguments[parameterCount - 1] = new BoundArrayCreation(
                            null,
                            null,
                            ReadOnlyArray.Singleton<BoundExpression>(
                                new BoundLiteral(null, null, ConstantValue.Create(arrayArgs.Count), int32Type)),
                            new BoundArrayInitialization(null, null, arrayArgs),
                            paramArrayType);
            }

            for (int p = 0; p < parameterCount; ++p)
            {
                if (arguments[p] == null)
                {
                    Debug.Assert(parameters[p].IsOptional);

                    // UNDONE: Add optional arguments.
                }
            }

            if (storesToTemps != null)
            {
                int tempsNeeded = MergeArgumentsAndSideEffects(storesToTemps, arguments);

                if (tempsNeeded > 0)
                {
                    var temps = new LocalSymbol[tempsNeeded];
                    for (int i = 0, j = 0; i < storesToTemps.Count; i++)
                    {
                        var s = storesToTemps[i];
                        if (s != null)
                        {
                            temps[j++] = ((BoundLocal)s.Left).LocalSymbol;
                        }
                    }

                    temporaries = temps.AsReadOnlyWrap();
                }

                storesToTemps.Free();
            }

            // * The rewritten list of names is now null because the arguments have been reordered.
            // * The args-to-params map is now null because every argument exactly matches its parameter.
            // * The call is no longer in its expanded form.

            argumentRefKinds = refKinds == null ? ReadOnlyArray<RefKind>.Null : refKinds.AsReadOnly<RefKind>();
            rewrittenArguments = arguments.AsReadOnlyWrap();
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:101,代码来源:CallRewriter.cs


注:本文中的LocalSymbol.AsReadOnlyWrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。