[vala/0.40] vala: Add missing re-check guards for Do/For/WhileStatement and SwitchLabel
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] vala: Add missing re-check guards for Do/For/WhileStatement and SwitchLabel
- Date: Thu, 6 Dec 2018 13:13:15 +0000 (UTC)
commit 345a04124bf17d353844b2b9abdf57003955edf0
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Oct 23 23:12:06 2018 +0200
vala: Add missing re-check guards for Do/For/WhileStatement and SwitchLabel
vala/valadostatement.vala | 18 ++++++++++++++++--
vala/valaforstatement.vala | 12 +++++++++++-
vala/valaswitchlabel.vala | 11 ++++++++++-
vala/valawhilestatement.vala | 12 +++++++++++-
4 files changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/vala/valadostatement.vala b/vala/valadostatement.vala
index 68e6e9320..4849393e7 100644
--- a/vala/valadostatement.vala
+++ b/vala/valadostatement.vala
@@ -93,6 +93,12 @@ public class Vala.DoStatement : CodeNode, Statement {
}
public override bool check (CodeContext context) {
+ if (checked) {
+ return !error;
+ }
+
+ checked = true;
+
// convert to simple loop
// do not generate variable and if block if condition is always true
@@ -102,7 +108,11 @@ public class Vala.DoStatement : CodeNode, Statement {
var parent_block = (Block) parent_node;
parent_block.replace_statement (this, loop);
- return loop.check (context);
+ if (!loop.check (context)) {
+ error = true;
+ }
+
+ return !error;
}
var block = new Block (source_reference);
@@ -127,6 +137,10 @@ public class Vala.DoStatement : CodeNode, Statement {
var parent_block = (Block) parent_node;
parent_block.replace_statement (this, block);
- return block.check (context);
+ if (!block.check (context)) {
+ error = true;
+ }
+
+ return !error;
}
}
diff --git a/vala/valaforstatement.vala b/vala/valaforstatement.vala
index 037a63979..a93e42c6f 100644
--- a/vala/valaforstatement.vala
+++ b/vala/valaforstatement.vala
@@ -165,6 +165,12 @@ public class Vala.ForStatement : CodeNode, Statement {
}
public override bool check (CodeContext context) {
+ if (checked) {
+ return !error;
+ }
+
+ checked = true;
+
// convert to simple loop
var block = new Block (source_reference);
@@ -206,6 +212,10 @@ public class Vala.ForStatement : CodeNode, Statement {
var parent_block = (Block) parent_node;
parent_block.replace_statement (this, block);
- return block.check (context);
+ if (!block.check (context)) {
+ error = true;
+ }
+
+ return !error;
}
}
diff --git a/vala/valaswitchlabel.vala b/vala/valaswitchlabel.vala
index a3a5201db..3a46d7c4b 100644
--- a/vala/valaswitchlabel.vala
+++ b/vala/valaswitchlabel.vala
@@ -79,6 +79,12 @@ public class Vala.SwitchLabel : CodeNode {
}
public override bool check (CodeContext context) {
+ if (checked) {
+ return !error;
+ }
+
+ checked = true;
+
if (expression != null) {
var switch_statement = (SwitchStatement) section.parent_node;
@@ -95,7 +101,10 @@ public class Vala.SwitchLabel : CodeNode {
}
}
- expression.check (context);
+ if (!expression.check (context)) {
+ error = true;
+ return false;
+ }
if (!expression.is_constant ()) {
error = true;
diff --git a/vala/valawhilestatement.vala b/vala/valawhilestatement.vala
index bec6b35b3..5ebc9349f 100644
--- a/vala/valawhilestatement.vala
+++ b/vala/valawhilestatement.vala
@@ -98,6 +98,12 @@ public class Vala.WhileStatement : CodeNode, Statement {
}
public override bool check (CodeContext context) {
+ if (checked) {
+ return !error;
+ }
+
+ checked = true;
+
// convert to simple loop
if (always_true (condition)) {
@@ -118,7 +124,11 @@ public class Vala.WhileStatement : CodeNode, Statement {
var parent_block = (Block) parent_node;
parent_block.replace_statement (this, loop);
- return loop.check (context);
+ if (!loop.check (context)) {
+ error = true;
+ }
+
+ return !error;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]