[vala/staging] codewriter: Output valid vala syntax for LoopStatement
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codewriter: Output valid vala syntax for LoopStatement
- Date: Tue, 16 Feb 2021 09:33:55 +0000 (UTC)
commit 2e9b53c44c6550aab73ace8a1d995c16c152577a
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Feb 16 10:33:06 2021 +0100
codewriter: Output valid vala syntax for LoopStatement
vala/valacodewriter.vala | 4 +++-
vala/valaloopstatement.vala | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
---
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]