本文整理汇总了C#中BoundSequence.Update方法的典型用法代码示例。如果您正苦于以下问题:C# BoundSequence.Update方法的具体用法?C# BoundSequence.Update怎么用?C# BoundSequence.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundSequence
的用法示例。
在下文中一共展示了BoundSequence.Update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitSequence
public override BoundNode VisitSequence(BoundSequence node)
{
ReadOnlyArray<BoundExpression> sideEffects = (ReadOnlyArray<BoundExpression>)this.VisitList(node.SideEffects);
BoundExpression value = (BoundExpression)this.Visit(node.Value);
TypeSymbol type = this.VisitType(node.Type);
if (!RequiresSpill(sideEffects) && value.Kind != BoundKind.SpillSequence)
{
return node.Update(node.Locals, sideEffects, value, type);
}
var spillBuilder = new SpillBuilder();
spillBuilder.Locals.AddRange(node.Locals);
foreach (var sideEffect in sideEffects)
{
spillBuilder.Statements.Add(
(sideEffect.Kind == BoundKind.SpillSequence)
? RewriteSpillSequenceAsBlock((BoundSpillSequence)sideEffect)
: F.ExpressionStatement(sideEffect));
}
BoundExpression newValue;
if (value.Kind == BoundKind.SpillSequence)
{
var awaitEffect = (BoundSpillSequence)value;
spillBuilder.AddSpill(awaitEffect);
newValue = awaitEffect.Value;
}
else
{
newValue = value;
}
return spillBuilder.BuildSequenceAndFree(F, newValue);
}
示例2: VisitSequence
public override BoundNode VisitSequence(BoundSequence node)
{
BoundSpillSequence2 ss2 = null;
var value = VisitExpression(ref ss2, node.Value);
BoundSpillSequence2 ss1 = null;
var sideEffects = VisitExpressionList(ref ss1, node.SideEffects, forceSpill: ss2 != null, sideEffectsOnly: true);
if (ss1 == null && ss2 == null)
{
return node.Update(node.Locals, sideEffects, value, node.Type);
}
if (ss1 == null) ss1 = new BoundSpillSequence2(); // possible if sideEffects is empty
ss1.AddRange(sideEffects, MakeExpressionStatement);
ss1.AddRange(node.Locals);
ss1.IncludeSequence(ss2);
return ss1.Update(value);
}
示例3: VisitSequence
//.........这里部分代码省略.........
{
// Normally we can only use stack for local scheduling if stack is not used for evaluation.
// In a context of a regular block that simply means that eval stack must be empty.
// Sequences, can be entered on a nonempty evaluation stack
// Ex:
// a.b = Seq{var y, y = 1, y} // a is on the stack for the duration of the sequence.
//
// However evaluation stack at the entry cannot be used inside the sequence, so such stack
// works as effective "empty" for locals declared in sequence.
// Therefore sequence locals can be stack scheduled at same stack as at the entry to the sequence.
// it may seem attractive to relax the stack requirement to be:
// "all uses must agree on stack depth".
// The following example illustrates a case where x is safely used at "declarationStack + 1"
// Ex:
// Seq{var x; y.a = Seq{x = 1; x}; y} // x is used while y is on the eval stack
//
// It is, however not safe assumption in general since eval stack may be accessed between usages.
// Ex:
// Seq{var x; y.a = Seq{x = 1; x}; y.z = x; y} // x blocks access to y
//
// There is one case where we want to tweak the "use at declaration stack" rule - in the case of
// compound assignment that involves ByRef operand captures (like: x[y]++ ) .
//
// Those cases produce specific sequences of the shapes:
//
// prefix: Seq{var temp, ref operand; operand initializers; *operand = Seq{temp = (T)(operand + 1); temp;} result: temp}
// postfix: Seq{var temp, ref operand; operand initializers; *operand = Seq{temp = operand; ; (T)(temp + 1);} result: temp}
//
// 1) temp is used as the result of the sequence (and that is the only reason why it is declared in the outer sequence).
// 2) all side-effects except the last one do not use the temp.
// 3) last side-effect is an indirect assignment of a sequence (and target does not involve the temp).
//
// Note that in a case of side-effects context, the result value will be ignored and therefore
// all usages of the nested temp will be confined to the nested sequence that is executed at +1 stack.
//
// We will detect such case and indicate +1 as the desired stack depth at local accesses.
//
var declarationStack = StackDepth();
var locals = node.Locals;
if (!locals.IsDefaultOrEmpty)
{
if (_context == ExprContext.Sideeffects)
{
foreach (var local in locals)
{
if (IsNestedLocalOfCompoundOperator(local, node))
{
// special case
DeclareLocal(local, declarationStack + 1);
}
else
{
DeclareLocal(local, declarationStack);
}
}
}
else
{
DeclareLocals(locals, declarationStack);
}
}
// rewrite operands
var origContext = _context;
var sideeffects = node.SideEffects;
ArrayBuilder<BoundExpression> rewrittenSideeffects = null;
if (!sideeffects.IsDefault)
{
for (int i = 0; i < sideeffects.Length; i++)
{
var sideeffect = sideeffects[i];
var rewrittenSideeffect = this.VisitExpression(sideeffect, ExprContext.Sideeffects);
if (rewrittenSideeffects == null && rewrittenSideeffect != sideeffect)
{
rewrittenSideeffects = ArrayBuilder<BoundExpression>.GetInstance();
rewrittenSideeffects.AddRange(sideeffects, i);
}
if (rewrittenSideeffects != null)
{
rewrittenSideeffects.Add(rewrittenSideeffect);
}
}
}
var value = this.VisitExpression(node.Value, origContext);
return node.Update(node.Locals,
rewrittenSideeffects != null ?
rewrittenSideeffects.ToImmutableAndFree() :
sideeffects,
value,
node.Type);
}
示例4: VisitSequence
public override BoundNode VisitSequence(BoundSequence node)
{
var newLocals = RewriteLocals(node.Locals);
var newSideEffects = VisitList<BoundExpression>(node.SideEffects);
var newValue = (BoundExpression)this.Visit(node.Value);
var newType = this.VisitType(node.Type);
return node.Update(newLocals, newSideEffects, newValue, newType);
}