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


C# AstGenerator.TransformAndDynamicConvert方法代码示例

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


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

示例1: Transform

        internal override MSAst.Expression Transform(AstGenerator ag, Type type) {
            MSAst.Expression test = ag.TransformAndDynamicConvert(_testExpr, typeof(bool));
            MSAst.Expression ifTrue = ag.TransformAndDynamicConvert(_trueExpr, type);
            MSAst.Expression ifFalse = ag.TransformAndDynamicConvert(_falseExpr, type);

            // Convert both to "type" ... since they are assignable already
            // it is really just a cosmetic cast.
            ifTrue = AstUtils.Convert(ifTrue, type);
            ifFalse = AstUtils.Convert(ifFalse, type);

            return Ast.Condition(test, ifTrue, ifFalse);
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:12,代码来源:ConditionalExpression.cs

示例2: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            MSAst.Expression result;

            if (_else != null) {
                result = ag.Transform(_else);
            } else {
                result = AstUtils.Empty();
            }

            // Now build from the inside out
            int i = _tests.Length;
            while (i-- > 0) {
                IfStatementTest ist = _tests[i];

                result = ag.AddDebugInfoAndVoid(
                    Ast.Condition(
                        ag.TransformAndDynamicConvert(ist.Test, typeof(bool)),
                        ag.TransformMaybeSingleLineSuite(ist.Body, ist.Test.Start), 
                        result
                    ),
                    new SourceSpan(ist.Start, ist.Header)
                );
            }

            return result;
        }
开发者ID:techarch,项目名称:ironruby,代码行数:26,代码来源:IfStatement.cs

示例3: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            MSAst.MethodCallExpression call;

            if (_locals == null && _globals == null) {
                // exec code
                call = Ast.Call(
                    AstGenerator.GetHelperMethod("UnqualifiedExec"), 
                    AstUtils.CodeContext(), 
                    ag.TransformAsObject(_code)
                );
            } else {
                // exec code in globals [ , locals ]
                // We must have globals now (locals is last and may be absent)
                Debug.Assert(_globals != null);
                call = Ast.Call(
                    AstGenerator.GetHelperMethod("QualifiedExec"), 
                    AstUtils.CodeContext(), 
                    ag.TransformAsObject(_code), 
                    ag.TransformAndDynamicConvert(_globals, typeof(IAttributesCollection)), 
                    ag.TransformOrConstantNull(_locals, typeof(object))
                );
            }

            return ag.AddDebugInfo(call, Span);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:25,代码来源:ExecStatement.cs

示例4: Transform

 internal override MSAst.Expression Transform(AstGenerator ag, MSAst.Expression body) {
     return ag.AddDebugInfoAndVoid(
         AstUtils.If(
             ag.TransformAndDynamicConvert(_test, typeof(bool)),
             body
         ),
         Span
     );
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:9,代码来源:ListComprehensionIf.cs

示例5: 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

示例6: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            // If debugging is off, return empty statement
            if (ag.Optimize) {
                return AstUtils.Empty();
            }

            // Transform into:
            // if (_test) {
            // } else {
            //     RaiseAssertionError(_message);
            // }
            return ag.AddDebugInfoAndVoid(
                AstUtils.Unless(                                 // if
                    ag.TransformAndDynamicConvert(_test, typeof(bool)), // _test
                    Ast.Call(                                           // else branch
                        AstGenerator.GetHelperMethod("RaiseAssertionError"),
                        ag.TransformOrConstantNull(_message, typeof(object))
                    )
                ),
                Span
            );
        }
开发者ID:techarch,项目名称:ironruby,代码行数:22,代码来源:AssertStatement.cs

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