public override void Emit() { if (this.ExpressionStatement.IsNull) { return; } var oldSemiColon = this.Emitter.EnableSemicolon; List <Expression> awaiters = null; if (this.Emitter.IsAsync) { var awaitSearch = new AwaitSearchVisitor(); this.ExpressionStatement.Expression.AcceptVisitor(awaitSearch); awaiters = awaitSearch.GetAwaitExpressions(); } bool isAwaiter = this.ExpressionStatement.Expression is UnaryOperatorExpression && ((UnaryOperatorExpression)this.ExpressionStatement.Expression).Operator == UnaryOperatorType.Await; this.ExpressionStatement.Expression.AcceptVisitor(this.Emitter); if (this.Emitter.EnableSemicolon && !isAwaiter) { this.WriteSemiColon(true); } if (oldSemiColon) { this.Emitter.EnableSemicolon = true; } }
public override AstNode VisitUsingStatement(UsingStatement usingStatement) { var awaitSearch = new AwaitSearchVisitor(null); usingStatement.AcceptVisitor(awaitSearch); var awaiters = awaitSearch.GetAwaitExpressions().ToArray(); if (awaiters.Length > 0) { IEnumerable <AstNode> inner = null; var res = usingStatement.ResourceAcquisition; var varStat = res as VariableDeclarationStatement; if (varStat != null) { inner = varStat.Variables.Skip(1); res = varStat.Variables.First(); } return(this.EmitUsing(usingStatement, res, inner, varStat)); } return(base.VisitUsingStatement(usingStatement)); }
protected override void DoEmit() { if (this.ExpressionStatement.IsNull) { return; } var oldSemiColon = this.Emitter.EnableSemicolon; List<Expression> awaiters = null; if (this.Emitter.IsAsync) { var awaitSearch = new AwaitSearchVisitor(); this.ExpressionStatement.Expression.AcceptVisitor(awaitSearch); awaiters = awaitSearch.GetAwaitExpressions(); } bool isAwaiter = this.ExpressionStatement.Expression is UnaryOperatorExpression && ((UnaryOperatorExpression)this.ExpressionStatement.Expression).Operator == UnaryOperatorType.Await; this.ExpressionStatement.Expression.AcceptVisitor(this.Emitter); if (this.Emitter.EnableSemicolon && !isAwaiter) { this.WriteSemiColon(true); } if (oldSemiColon) { this.Emitter.EnableSemicolon = true; } }
protected Expression[] GetAwaiters(AstNode node) { var awaitSearch = new AwaitSearchVisitor(); node.AcceptVisitor(awaitSearch); return(awaitSearch.GetAwaitExpressions().ToArray()); }
public override void VisitUsingStatement(UsingStatement usingStatement) { var awaitSearch = new AwaitSearchVisitor(null); usingStatement.AcceptVisitor(awaitSearch); var awaiters = awaitSearch.GetAwaitExpressions().ToArray(); if (awaiters.Length > 0) { this.Found = true; } base.VisitUsingStatement(usingStatement); }
protected Expression[] GetAwaiters(AstNode node) { var awaitSearch = new AwaitSearchVisitor(); node.AcceptVisitor(awaitSearch); return awaitSearch.GetAwaitExpressions().ToArray(); }