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


C# Statement.Transform方法代码示例

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


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

示例1: TransformWithLineNumberUpdate

        private MSAst.Expression TransformWithLineNumberUpdate(Statement/*!*/ fromStmt) {
            // add line number tracking when the line changes...  First we see if the
            // line number changes and then we transform the body.  This prevents the body
            // from updating the line info first.
            bool updateLine = false;

            if (fromStmt.CanThrow &&        // don't need to update line tracking for statements that can't throw
                ((_curLine.HasValue && fromStmt.Start.IsValid && _curLine.Value != fromStmt.Start.Line) ||  // don't need to update unless line has changed
                (!_curLine.HasValue && fromStmt.Start.IsValid))) {  // do need to update if we don't yet have a valid line

                _curLine = fromStmt.Start.Line;
                updateLine = true;
            }

            MSAst.Expression toExpr = fromStmt.Transform(this);

            if (toExpr != null && updateLine && Context.SourceUnit.Kind != SourceCodeKind.Expression) {
                toExpr = Ast.Block(
                    UpdateLineNumber(fromStmt.Start.Line),
                    toExpr
                );
            }

            if (InFinally || InLoop) {
                if (!LoopOrFinallyLocations.ContainsKey(fromStmt.Span.Start.Line)) {
                    LoopOrFinallyLocations.Add(fromStmt.Span.Start.Line, new Dictionary<int, bool>(LoopOrFinallyIds));
                }
            }

            return toExpr;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:31,代码来源:AstGenerator.cs

示例2: TransformWithLineNumberUpdate

        private MSAst.Expression TransformWithLineNumberUpdate(Statement/*!*/ fromStmt) {
            // add line number tracking when the line changes...  First we see if the
            // line number changes and then we transform the body.  This prevents the body
            // from updating the line info first.
            bool updateLine = false;

            if (fromStmt.CanThrow &&        // don't need to update line tracking for statements that can't throw
                ((_curLine.HasValue && fromStmt.Start.IsValid && _curLine.Value != fromStmt.Start.Line) ||  // don't need to update unless line has changed
                (!_curLine.HasValue && fromStmt.Start.IsValid))) {  // do need to update if we don't yet have a valid line

                _curLine = fromStmt.Start.Line;
                updateLine = true;
            }

            MSAst.Expression toExpr = fromStmt.Transform(this);

            if (toExpr != null && updateLine) {
                toExpr = Ast.Block(
                    UpdateLineNumber(fromStmt.Start.Line),
                    toExpr
                );
            }

            return toExpr;
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:25,代码来源:AstGenerator.cs

示例3: TransformMaybeSingleLineSuite

        public MSAst.Expression TransformMaybeSingleLineSuite(Statement body, SourceLocation prevStart) {
            MSAst.Expression res;
            if (body.Start.Line == prevStart.Line) {
                // avoid creating and throwing away as much line number goo as we can...
                res = body.Transform(this);
            } else {
                res = Transform(body);
            }

            MSAst.BlockExpression block = res as MSAst.BlockExpression;
            if (block != null && block.Expressions.Count > 0) {
                MSAst.DebugInfoExpression dbgInfo = block.Expressions[0] as MSAst.DebugInfoExpression;
                // body on the same line as an if, don't generate a 2nd sequence point
                if (dbgInfo != null && dbgInfo.StartLine == prevStart.Line) {
                    // we remove the debug info based upon how it's generated in DebugStatement.AddDebugInfo which is
                    // the helper method which adds the debug info.
                    if (block.Type == typeof(void)) {
                        Debug.Assert(block.Expressions.Count == 3);
                        Debug.Assert(block.Expressions[2] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear);
                        res = block.Expressions[1];
                    } else {
                        Debug.Assert(block.Expressions.Count == 4);
                        Debug.Assert(block.Expressions[3] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear);
                        Debug.Assert(block.Expressions[1] is MSAst.BinaryExpression && ((MSAst.BinaryExpression)block.Expressions[2]).NodeType == MSAst.ExpressionType.Assign);
                        res = ((MSAst.BinaryExpression)block.Expressions[1]).Right;
                    }
                }
            }

            if (res.Type != typeof(void)) {
                res = AstUtils.Void(res);
            }

            return res;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:35,代码来源:AstGenerator.cs


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