本文整理汇总了C#中ImmutableArray.RefKinds方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.RefKinds方法的具体用法?C# ImmutableArray.RefKinds怎么用?C# ImmutableArray.RefKinds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.RefKinds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildStoresToTemps
// This fills in the arguments, refKinds and storesToTemps arrays.
private void BuildStoresToTemps(
bool expanded,
ImmutableArray<int> argsToParamsOpt,
ImmutableArray<RefKind> argumentRefKinds,
ImmutableArray<BoundExpression> rewrittenArguments,
/* out */ BoundExpression[] arguments,
/* out */ ArrayBuilder<RefKind> refKinds,
/* out */ ArrayBuilder<BoundAssignmentOperator> storesToTemps)
{
Debug.Assert(refKinds.Count == arguments.Length);
Debug.Assert(storesToTemps.Count == 0);
for (int a = 0; a < rewrittenArguments.Length; ++a)
{
BoundExpression argument = rewrittenArguments[a];
int p = (!argsToParamsOpt.IsDefault) ? argsToParamsOpt[a] : a;
RefKind refKind = argumentRefKinds.RefKinds(a);
Debug.Assert(arguments[p] == null);
if (expanded && p == arguments.Length - 1)
{
// Unfortunately, we violate the specification and allow:
// M(int q, params int[] x) ... M(x : X(), q : Q());
// which means that we cannot bail out just because
// an argument of an expanded-form call corresponds to
// the parameter array. We need to make sure that the
// side effects of X() and Q() continue to happen in the right
// order here.
//
// Fortunately, we do disallow M(x : 123, x : 345, x : 456).
//
// Here's what we'll do. If all the remaining arguments
// correspond to elements in the parameter array then
// we can bail out here without creating any temporaries.
// The next step in the call rewriter will deal with gathering
// up the elements.
//
// However, if there are other elements after this one
// that do not correspond to elements in the parameter array
// then we need to create a temporary as usual. The step that
// produces the parameter array will need to deal with that
// eventuality.
bool canBail = true;
for (int remainingArgument = a + 1; remainingArgument < rewrittenArguments.Length; ++remainingArgument)
{
int remainingParameter = (!argsToParamsOpt.IsDefault) ? argsToParamsOpt[remainingArgument] : remainingArgument;
if (remainingParameter != arguments.Length - 1)
{
canBail = false;
break;
}
}
if (canBail)
{
return;
}
}
if (IsSafeForReordering(argument, refKind))
{
arguments[p] = argument;
refKinds[p] = refKind;
}
else
{
BoundAssignmentOperator assignment;
var temp = _factory.StoreToTemp(argument, out assignment, refKind: refKind);
storesToTemps.Add(assignment);
arguments[p] = temp;
}
}
}