System.Linq.Expressions.Compiler.LabelInfo.MarkWithEmptyStack C# (CSharp) Method

MarkWithEmptyStack() private method

private MarkWithEmptyStack ( ) : void
return void
        internal void MarkWithEmptyStack()
        {
            _ilg.MarkLabel(Label);
            if (_value != null)
            {
                // We always read the value from a local, because we don't know
                // if there will be a "leave" instruction targeting it ("branch"
                // preserves its stack, but "leave" empties the stack)
                _ilg.Emit(OpCodes.Ldloc, _value);
            }
        }

Usage Example

コード例 #1
0
        private void EmitLoopExpression(Expression expr)
        {
            LoopExpression node = (LoopExpression)expr;

            PushLabelBlock(LabelScopeKind.Statement);
            LabelInfo breakTarget    = DefineLabel(node.BreakLabel);
            LabelInfo continueTarget = DefineLabel(node.ContinueLabel);

            continueTarget.MarkWithEmptyStack();

            EmitExpressionAsVoid(node.Body);

            _ilg.Emit(OpCodes.Br, continueTarget.Label);

            PopLabelBlock(LabelScopeKind.Statement);

            breakTarget.MarkWithEmptyStack();
        }