Exemple #1
0
        public static bool HasYield(AstNode node)
        {
            var visitor = new YieldSearchVisitor();

            node.AcceptVisitor(visitor);
            return(visitor.Found);
        }
Exemple #2
0
        private void EmitUsing(AstNode expression, IEnumerable <AstNode> inner)
        {
            var visitor = new YieldSearchVisitor();

            this.UsingStatement.EmbeddedStatement.AcceptVisitor(visitor);
            bool hasRet = visitor.Found;

            VariableInitializer variableInitializer = expression as VariableInitializer;

            if (variableInitializer != null)
            {
                if (hasRet)
                {
                    this.WriteReturn(true);
                }
                this.Write("System.using");
                this.WriteOpenParentheses();
                variableInitializer.Initializer.AcceptVisitor(this.Emitter);
                this.WriteComma();
                this.WriteFunction();
                this.WriteOpenParentheses();
                this.Write(variableInitializer.Name);
            }
            else
            {
                AssignmentExpression assignmentExpression = (AssignmentExpression)expression;
                assignmentExpression.AcceptVisitor(this.Emitter);
                this.WriteNewLine();
                if (hasRet)
                {
                    this.WriteReturn(true);
                }
                this.Write("System.using");
                this.WriteOpenParentheses();
                assignmentExpression.Left.AcceptVisitor(this.Emitter);
                this.WriteComma();
                this.WriteFunction();
                this.WriteOpenParentheses();
                assignmentExpression.Left.AcceptVisitor(this.Emitter);
            }

            this.WriteCloseParentheses();
            this.BeginFunctionBlock();
            this.UsingStatement.EmbeddedStatement.AcceptVisitor(this.Emitter);
            this.EndFunctionBlock();
            this.WriteCloseParentheses();
            this.WriteNewLine();
        }
Exemple #3
0
 public static bool HasYield(AstNode node)
 {
     var visitor = new YieldSearchVisitor();
     node.AcceptVisitor(visitor);
     return visitor.Found;
 }