Exemple #1
0
        protected void VisitForStatement()
        {
            ForStatement forStatement = this.ForStatement;

            this.BeginDoBlock();

            this.PushLocals();
            this.Emitter.EnableSemicolon = false;

            foreach (var item in forStatement.Initializers)
            {
                if (item != forStatement.Initializers.First())
                {
                    this.WriteSemiColon();
                    this.WriteSpace();
                }
                item.AcceptVisitor(this.Emitter);
            }
            this.WriteSemiColon();
            this.WriteNewLine();

            this.WriteWhile();

            if (!forStatement.Condition.IsNull)
            {
                forStatement.Condition.AcceptVisitor(this.Emitter);
            }
            else
            {
                this.Write("true");
            }
            this.WriteSpace();
            this.Emitter.EnableSemicolon = true;

            this.BeginDoBlock();

            bool hasContinue = ContinueBlock.HasContinue(this, this.ForStatement);

            forStatement.EmbeddedStatement.AcceptVisitor(this.Emitter);
            if (hasContinue)
            {
                ContinueBlock.EmitEndContinue(this);
            }

            foreach (var item in forStatement.Iterators)
            {
                if (item != forStatement.Iterators.First())
                {
                    this.WriteSemiColon();
                }
                item.AcceptVisitor(this.Emitter);
            }

            this.EndCodeBlock();
            this.WriteNewLine();

            this.PopLocals();
            this.EndCodeBlock();
            this.WriteNewLine();
        }
Exemple #2
0
        protected void VisitForeachStatement(bool?replaceAwaiterByVar = null)
        {
            ForeachStatement foreachStatement = this.ForeachStatement;

            if (foreachStatement.EmbeddedStatement is EmptyStatement)
            {
                return;
            }

            this.PushWriter("{0}");
            this.WriteOpenParentheses();
            foreachStatement.InExpression.AcceptVisitor(this.Emitter);
            this.WriteCloseParentheses();
            string script = this.PopWriter(true);

            this.WriteFor();
            this.Write("_, ", foreachStatement.VariableName, " in ", Bridge.Translator.Emitter.ROOT);
            this.WriteDot();
            this.Write(Bridge.Translator.Emitter.ITERATOR);
            this.Write(script);

            this.WriteSpace();
            this.BeginDoBlock();

            BlockStatement block = foreachStatement.EmbeddedStatement as BlockStatement;

            if (replaceAwaiterByVar.HasValue)
            {
                this.Emitter.ReplaceAwaiterByVar = replaceAwaiterByVar.Value;
            }

            if (block != null)
            {
                this.Emitter.NoBraceBlock = block;
            }

            bool hasContinue = ContinueBlock.HasContinue(this, this.ForeachStatement);

            foreachStatement.EmbeddedStatement.AcceptVisitor(this.Emitter);
            if (hasContinue)
            {
                ContinueBlock.EmitEndContinue(this);
            }

            if (!this.Emitter.IsNewLine)
            {
                this.WriteNewLine();
            }

            this.EndCodeBlock();
            this.WriteNewLine();
        }
Exemple #3
0
        protected void VisitWhileStatement()
        {
            this.WriteWhile();
            this.WhileStatement.Condition.AcceptVisitor(this.Emitter);
            this.WriteSpace();
            this.BeginDoBlock();
            bool hasContinue = ContinueBlock.HasContinue(this, this.WhileStatement);

            WhileStatement.EmbeddedStatement.AcceptVisitor(this.Emitter);
            if (hasContinue)
            {
                ContinueBlock.EmitEndContinue(this);
            }
            this.EndCodeBlock();
            this.WriteNewLine();
        }
        protected void VisitDoWhileStatement()
        {
            DoWhileStatement doWhileStatement = this.DoWhileStatement;

            this.BeginRepeatBlock();
            bool hasContinue = ContinueBlock.HasContinue(this, this.DoWhileStatement);

            doWhileStatement.EmbeddedStatement.AcceptVisitor(this.Emitter);
            if (hasContinue)
            {
                ContinueBlock.EmitEndContinue(this);
            }
            this.EndUntilBlock();
            this.WriteOpenParentheses();
            doWhileStatement.Condition.AcceptVisitor(this.Emitter);
            this.WriteCloseParentheses();
            this.WriteSemiColon();
            this.WriteNewLine();
        }