コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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));
        }
コード例 #3
0
ファイル: ExpressionBlock.cs プロジェクト: GavinHwa/Bridge
        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;
            }
        }
コード例 #4
0
        protected Expression[] GetAwaiters(AstNode node)
        {
            var awaitSearch = new AwaitSearchVisitor();

            node.AcceptVisitor(awaitSearch);

            return(awaitSearch.GetAwaitExpressions().ToArray());
        }
コード例 #5
0
ファイル: Preconverter.cs プロジェクト: yctri/Bridge
        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);
        }
コード例 #6
0
        protected Expression[] GetAwaiters(AstNode node)
        {
            var awaitSearch = new AwaitSearchVisitor();
            node.AcceptVisitor(awaitSearch);

            return awaitSearch.GetAwaitExpressions().ToArray();
        }