From: Rico Tzschichholz Date: Tue, 16 Feb 2021 09:33:06 +0000 (+0100) Subject: codewriter: Output valid vala syntax for LoopStatement X-Git-Tag: 0.51.2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e9b53c44c6550aab73ace8a1d995c16c152577a;p=thirdparty%2Fvala.git codewriter: Output valid vala syntax for LoopStatement --- diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index 944451e41..8c2df4db6 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -1083,7 +1083,9 @@ public class Vala.CodeWriter : CodeVisitor { public override void visit_loop_statement (LoopStatement stmt) { write_indent (); - write_string ("loop"); + write_string ("while ("); + stmt.condition.accept (this); + write_string (")"); stmt.body.accept (this); write_newline (); } diff --git a/vala/valaloopstatement.vala b/vala/valaloopstatement.vala index 8348d300c..e522fd1b0 100644 --- a/vala/valaloopstatement.vala +++ b/vala/valaloopstatement.vala @@ -34,7 +34,7 @@ public class Vala.LoopStatement : Loop, Statement { * @return newly created while statement */ public LoopStatement (Block body, SourceReference? source_reference = null) { - base (null, body, source_reference); + base (new BooleanLiteral (true, source_reference), body, source_reference); } public override void accept (CodeVisitor visitor) { @@ -56,6 +56,7 @@ public class Vala.LoopStatement : Loop, Statement { checked = true; + condition.check (context); body.check (context); return !error;