public override void Visit(DoWhileLoop visitable) { WriteIndentantion(true).AppendLine("Do-while loop"); WriteIndentantion(true).AppendLine("Body:"); Start(visitable.Body); _indentLevel--; WriteIndentantion(true).AppendLine("Condition:"); Start(visitable.Condition); _indentLevel--; _indentLevel--; }
public static void Compile(ByteCodeCompiler bcc, ParserContext parser, ByteBuffer buffer, DoWhileLoop doWhileLoop) { ByteBuffer loopBody = new ByteBuffer(); bcc.Compile(parser, loopBody, doWhileLoop.Code); loopBody.ResolveContinues(true); // continues should jump to the condition, hence the true. ByteBuffer condition = new ByteBuffer(); bcc.CompileExpression(parser, condition, doWhileLoop.Condition, true); loopBody.Concat(condition); loopBody.Add(doWhileLoop.Condition.FirstToken, OpCode.JUMP_IF_TRUE, -loopBody.Size - 1); loopBody.ResolveBreaks(); buffer.Concat(loopBody); }
public abstract void Visit(DoWhileLoop visitable);