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


C# AstGenerator.TransformLoopBody方法代码示例

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


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

示例1: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            // Temporary variable for the IEnumerator object
            MSAst.ParameterExpression enumerator = ag.GetTemporary("foreach_enumerator", typeof(IEnumerator));

            // Only the body is "in the loop" for the purposes of break/continue
            // The "else" clause is outside
            MSAst.LabelTarget breakLabel, continueLabel;
            MSAst.Expression body = ag.TransformLoopBody(_body, _left.Start, out breakLabel, out continueLabel);
            if (body == null) {
                // error recovery
                return null;
            }
            return TransformForStatement(ag, enumerator, _list, _left, body, _else, Span, _header, breakLabel, continueLabel);
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:14,代码来源:ForStatement.cs

示例2: Transform

 internal override MSAst.Expression Transform(AstGenerator ag) {
     // Only the body is "in the loop" for the purposes of break/continue
     // The "else" clause is outside
     MSAst.LabelTarget breakLabel, continueLabel;
     MSAst.Expression body = ag.TransformLoopBody(_body, out breakLabel, out continueLabel);
     return AstUtils.While(
         ag.AddDebugInfo(
             ag.TransformAndDynamicConvert(_test, typeof(bool)),
             Header
         ),
         body, 
         ag.Transform(_else),
         breakLabel,
         continueLabel
     );
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:16,代码来源:WhileStatement.cs

示例3: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            // Only the body is "in the loop" for the purposes of break/continue
            // The "else" clause is outside
            MSAst.LabelTarget breakLabel, continueLabel;

            ConstantExpression constTest = _test as ConstantExpression;
            if (constTest != null && constTest.Value is int) {
                // while 0: / while 1:
                int val = (int)constTest.Value;
                if (val == 0) {
                    // completely optimize the loop away
                    if (_else == null) {
                        return MSAst.Expression.Empty();
                    } else {
                        return ag.Transform(_else);
                    }
                }

                MSAst.Expression test = MSAst.Expression.Constant(true);
                MSAst.Expression res = AstUtils.While(
                    test,
                    ag.TransformLoopBody(_body, SourceLocation.Invalid, out breakLabel, out continueLabel),
                    ag.Transform(_else),
                    breakLabel,
                    continueLabel
                );

                if (_test.Start.Line != _body.Start.Line) {
                    res = ag.AddDebugInfo(res, _test.Span);
                }

                return res;
            }

            return AstUtils.While(
                ag.AddDebugInfo(
                    ag.TransformAndDynamicConvert(_test, typeof(bool)),
                    Header
                ),
                ag.TransformLoopBody(_body, _test.Start, out breakLabel, out continueLabel), 
                ag.Transform(_else),
                breakLabel,
                continueLabel
            );
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:45,代码来源:WhileStatement.cs


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