summaryrefslogtreecommitdiff
path: root/vala/valawhilestatement.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2018-01-09 16:21:06 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2021-02-01 10:13:12 +0100
commitb3ee5b0fffc7ab7f5d070bfde5bf8bb1d661b5e8 (patch)
treef57498defbef15cff02e341b3293336d818f48cd /vala/valawhilestatement.vala
parent14c43ac962667ec028683777530a8c84c7703d29 (diff)
downloadvala-b3ee5b0fffc7ab7f5d070bfde5bf8bb1d661b5e8.tar.gz
vala: Rename Loop to LoopStatement and introduce a common base class
Diffstat (limited to 'vala/valawhilestatement.vala')
-rw-r--r--vala/valawhilestatement.vala43
1 files changed, 3 insertions, 40 deletions
diff --git a/vala/valawhilestatement.vala b/vala/valawhilestatement.vala
index 161252219..be9237242 100644
--- a/vala/valawhilestatement.vala
+++ b/vala/valawhilestatement.vala
@@ -25,36 +25,7 @@ using GLib;
/**
* Represents a while iteration statement in the source code.
*/
-public class Vala.WhileStatement : CodeNode, Statement {
- /**
- * Specifies the loop condition.
- */
- public Expression condition {
- get {
- return _condition;
- }
- private set {
- _condition = value;
- _condition.parent_node = this;
- }
- }
-
- /**
- * Specifies the loop body.
- */
- public Block body {
- get {
- return _body;
- }
- private set {
- _body = value;
- _body.parent_node = this;
- }
- }
-
- private Expression _condition;
- private Block _body;
-
+public class Vala.WhileStatement : Loop, Statement {
/**
* Creates a new while statement.
*
@@ -64,9 +35,7 @@ public class Vala.WhileStatement : CodeNode, Statement {
* @return newly created while statement
*/
public WhileStatement (Expression condition, Block body, SourceReference? source_reference = null) {
- this.body = body;
- this.source_reference = source_reference;
- this.condition = condition;
+ base (condition, body, source_reference);
}
public override void accept (CodeVisitor visitor) {
@@ -81,12 +50,6 @@ public class Vala.WhileStatement : CodeNode, Statement {
body.accept (visitor);
}
- public override void replace_expression (Expression old_node, Expression new_node) {
- if (condition == old_node) {
- condition = new_node;
- }
- }
-
public override bool check (CodeContext context) {
if (checked) {
return !error;
@@ -109,7 +72,7 @@ public class Vala.WhileStatement : CodeNode, Statement {
body.insert_statement (0, if_stmt);
}
- var loop = new Loop (body, source_reference);
+ var loop = new LoopStatement (body, source_reference);
unowned Block parent_block = (Block) parent_node;
parent_block.replace_statement (this, loop);