[vala/staging] 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/staging] vala: Add missing re-check guards for Do/For/WhileStatement and SwitchLabel
- Date: Tue, 27 Nov 2018 10:28:51 +0000 (UTC)
commit ef6d8e644d1e1da08ad7ae5761a4f6d804d54e92
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 987facc90..f34e22358 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 bd3229ad5..aa70cee0b 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 d3df5a3ee..ca92de04c 100644
--- a/vala/valaswitchlabel.vala
+++ b/vala/valaswitchlabel.vala
@@ -78,6 +78,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;
@@ -94,7 +100,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 0b0a1b1bb..a15b1abe8 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]