IronPython.Compiler.Ast.SuiteStatement.Reduce C# (CSharp) Méthode

Reduce() public méthode

public Reduce ( ) : Expression
Résultat System.Linq.Expressions.Expression
        public override MSAst.Expression Reduce() {
            if (_statements.Length == 0) {
                return GlobalParent.AddDebugInfoAndVoid(AstUtils.Empty(), Span);
            }

            ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>();

            int curStart = -1;
            foreach (var statement in _statements) {
                // CPython debugging treats multiple statements on the same line as a single step, we
                // match that behavior here.
                int newline = GlobalParent.IndexToLocation(statement.StartIndex).Line;
                if (newline == curStart) {
                    statements.Add(new DebugInfoRemovalExpression(statement, curStart));
                } else {
                    if (statement.CanThrow && newline != -1) {
                        statements.Add(UpdateLineNumber(newline));
                    }

                    statements.Add(statement);
                }
                curStart = newline;
            }
            
            return Ast.Block(statements.ToReadOnlyCollection());
        }