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


C# BlockExpression.GetExpression方法代码示例

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


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

示例1: Emit

        private void Emit(BlockExpression node, EmitAs emitAs) {
            EnterScope(node);

            int count = node.ExpressionCount;
            for (int index = 0; index < count - 1; index++) {
                var e = node.GetExpression(index);

                if (_emitDebugSymbols) {
                    //No need to emit a clearance if the next expression in the block is also a
                    //DebugInfoExprssion.
                    var debugInfo = e as DebugInfoExpression;
                    if (debugInfo != null && debugInfo.IsClear && node.GetExpression(index + 1) is DebugInfoExpression) {
                        continue;
                    }
                }
                EmitExpressionAsVoid(e);
            }

            // if the type of Block it means this is not a Comma
            // so we will force the last expression to emit as void.
            if (emitAs == EmitAs.Void || node.Type == typeof(void)) {
                EmitExpressionAsVoid(node.GetExpression(count - 1));
            } else {
                EmitExpressionAsType(node.GetExpression(count - 1), node.Type);
            }

            ExitScope(node);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:28,代码来源:LambdaCompiler.Statements.cs

示例2: Emit

        private void Emit(BlockExpression node, CompilationFlags flags)
        {
            int count = node.ExpressionCount;

            if (count == 0)
            {
                return;
            }

            EnterScope(node);

            CompilationFlags emitAs = flags & CompilationFlags.EmitAsTypeMask;

            CompilationFlags tailCall = flags & CompilationFlags.EmitAsTailCallMask;
            for (int index = 0; index < count - 1; index++)
            {
                var e = node.GetExpression(index);
                var next = node.GetExpression(index + 1);

                CompilationFlags tailCallFlag;
                if (tailCall != CompilationFlags.EmitAsNoTail)
                {
                    var g = next as GotoExpression;
                    if (g != null && (g.Value == null || !Significant(g.Value)) && ReferenceLabel(g.Target).CanReturn)
                    {
                        // Since tail call flags are not passed into EmitTryExpression, CanReturn means the goto will be emitted
                        // as Ret. Therefore we can emit the current expression with tail call.
                        tailCallFlag = CompilationFlags.EmitAsTail;
                    }
                    else
                    {
                        // In the middle of the block.
                        // We may do better here by marking it as Tail if the following expressions are not going to emit any IL.
                        tailCallFlag = CompilationFlags.EmitAsMiddle;
                    }
                }
                else
                {
                    tailCallFlag = CompilationFlags.EmitAsNoTail;
                }

                flags = UpdateEmitAsTailCallFlag(flags, tailCallFlag);
                EmitExpressionAsVoid(e, flags);
            }

            // if the type of Block it means this is not a Comma
            // so we will force the last expression to emit as void.
            // We don't need EmitAsType flag anymore, should only pass
            // the EmitTailCall field in flags to emitting the last expression.
            if (emitAs == CompilationFlags.EmitAsVoidType || node.Type == typeof(void))
            {
                EmitExpressionAsVoid(node.GetExpression(count - 1), tailCall);
            }
            else
            {
                EmitExpressionAsType(node.GetExpression(count - 1), node.Type, tailCall);
            }

            ExitScope(node);
        }
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:60,代码来源:LambdaCompiler.Statements.cs

示例3: Emit

        private void Emit(BlockExpression node, EmitAs emitAs) {
            int count = node.ExpressionCount;

            // Labels defined immediately in the block are valid for the whole block

            for(int i = 0; i < count; i++) {
                Expression e = node.GetExpression(i);

                var label = e as LabelExpression;
                if (label != null) {
                    DefineLabel(label.Label);
                }
            }

            EnterScope(node);

            for (int index = 0; index < count - 1; index++) {
                EmitExpressionAsVoid(node.GetExpression(index));
            }

            // if the type of Block it means this is not a Comma
            // so we will force the last expression to emit as void.
            if (emitAs == EmitAs.Void || node.Type == typeof(void)) {
                EmitExpressionAsVoid(node.GetExpression(count - 1));
            } else {
                EmitExpression(node.GetExpression(count - 1));
            }

            ExitScope(node);
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:30,代码来源:LambdaCompiler.Statements.cs

示例4: Emit

        private void Emit(BlockExpression node, CompilationFlags flags) {
            EnterScope(node);

            CompilationFlags emitAs = flags & CompilationFlags.EmitAsTypeMask;

            int count = node.ExpressionCount;
            CompilationFlags tailCall = flags & CompilationFlags.EmitAsTailCallMask;
            CompilationFlags middleTailCall = tailCall == CompilationFlags.EmitAsNoTail ? CompilationFlags.EmitAsNoTail : CompilationFlags.EmitAsMiddle;

            for (int index = 0; index < count - 1; index++) {
                var e = node.GetExpression(index);
                var next = node.GetExpression(index + 1);

                if (EmitDebugSymbols) {
                    // No need to emit a clearance if the next expression in the block is also a
                    // DebugInfoExprssion.
                    var debugInfo = e as DebugInfoExpression;
                    if (debugInfo != null && debugInfo.IsClear && next is DebugInfoExpression) {
                        continue;
                    }
                }
                // In the middle of the block.
                // We may do better here by marking it as Tail if the following expressions are not going to emit any IL.
                var tailCallFlag = middleTailCall;

                var g = next as GotoExpression;
                if (g != null && (g.Value == null || !Significant(g.Value))) {
                    var labelInfo = ReferenceLabel(g.Target);
                    if (labelInfo.CanReturn) {
                        // Since tail call flags are not passed into EmitTryExpression, CanReturn means the goto will be emitted
                        // as Ret. Therefore we can emit the current expression with tail call.
                        tailCallFlag = CompilationFlags.EmitAsTail;
                    }
                }
                flags = UpdateEmitAsTailCallFlag(flags, tailCallFlag);
                EmitExpressionAsVoid(e, flags);
            }

            // if the type of Block it means this is not a Comma
            // so we will force the last expression to emit as void.
            // We don't need EmitAsType flag anymore, should only pass
            // the EmitTailCall field in flags to emitting the last expression.
            if (emitAs == CompilationFlags.EmitAsVoidType || node.Type == typeof(void)) {
                EmitExpressionAsVoid(node.GetExpression(count - 1), tailCall);
            } else {
                EmitExpressionAsType(node.GetExpression(count - 1), node.Type, tailCall);
            }

            ExitScope(node);
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:50,代码来源:LambdaCompiler.Statements.cs

示例5: EmitBranchBlock

        private void EmitBranchBlock(bool branch, BlockExpression node, Label label) {
            EnterScope(node);

            int count = node.ExpressionCount;
            for (int i = 0; i < count - 1; i++) {
                EmitExpressionAsVoid(node.GetExpression(i));
            }
            EmitExpressionAndBranch(branch, node.GetExpression(count - 1), label);

            ExitScope(node);
        }
开发者ID:salloo,项目名称:mono,代码行数:11,代码来源:LambdaCompiler.Logical.cs


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