public void VisitDoWhile(IndentWriter context, AstStatement.DoWhileStmt doWhileStmt)
 {
     context.WriteLine("do {");
     context.Indent();
     doWhileStmt.Body.Accept(context, this);
     context.Unindent();
     context.WriteLine("} while (");
     context.Indent();
     this.PrintExpression(context, doWhileStmt.Condition, doWhileStmt.Scope);
     context.Unindent();
     context.WriteLine(");");
 }
        public List <Instruction> VisitDoWhile(object context, AstStatement.DoWhileStmt doWhileStmt)
        {
            /*
             * do ( stmt() ) while (expr());
             *
             * #label
             * stmt();
             * expr();
             * jumpIf #label
             */

            var label = this.GetNextLabel(doWhileStmt);
            var list  = new List <Instruction>();

            list.Add(Label, new[] { label });
            list.AddRange(doWhileStmt.Body.Accept(context, this));
            list.AddRange(doWhileStmt.Condition.Accept(doWhileStmt.Scope, this));
            list.Add(JumpIf, new[] { label });
            return(list);
        }
 public AstStatement VisitDoWhile(Scope context, AstStatement.DoWhileStmt doWhileStmt)
 {
     doWhileStmt.Body      = doWhileStmt.Body.Accept(context, this);
     doWhileStmt.Condition = doWhileStmt.Condition.Accept(context, this);
     return(doWhileStmt);
 }
Example #4
0
 public Tree VisitDoWhile(object c, AstStatement.DoWhileStmt doWhileStmt)
 => new Tree("dowhile", doWhileStmt.Body.Accept(c, this), Expr(doWhileStmt.Condition));