summaryrefslogtreecommitdiff
path: root/vala/valaloopstatement.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/valaloopstatement.vala
parent14c43ac962667ec028683777530a8c84c7703d29 (diff)
downloadvala-b3ee5b0fffc7ab7f5d070bfde5bf8bb1d661b5e8.tar.gz
vala: Rename Loop to LoopStatement and introduce a common base class
Diffstat (limited to 'vala/valaloopstatement.vala')
-rw-r--r--vala/valaloopstatement.vala68
1 files changed, 68 insertions, 0 deletions
diff --git a/vala/valaloopstatement.vala b/vala/valaloopstatement.vala
new file mode 100644
index 000000000..8348d300c
--- /dev/null
+++ b/vala/valaloopstatement.vala
@@ -0,0 +1,68 @@
+/* valaloopstatement.vala
+ *
+ * Copyright (C) 2009-2010 Jürg Billeter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+/**
+ * Represents an endless loop.
+ */
+public class Vala.LoopStatement : Loop, Statement {
+ /**
+ * Creates a new loop.
+ *
+ * @param body loop body
+ * @param source_reference reference to source code
+ * @return newly created while statement
+ */
+ public LoopStatement (Block body, SourceReference? source_reference = null) {
+ base (null, body, source_reference);
+ }
+
+ public override void accept (CodeVisitor visitor) {
+ visitor.visit_loop_statement (this);
+ }
+
+ public override void accept_children (CodeVisitor visitor) {
+ body.accept (visitor);
+ }
+
+ public override void get_error_types (Collection<DataType> collection, SourceReference? source_reference = null) {
+ body.get_error_types (collection, source_reference);
+ }
+
+ public override bool check (CodeContext context) {
+ if (checked) {
+ return !error;
+ }
+
+ checked = true;
+
+ body.check (context);
+
+ return !error;
+ }
+
+ public override void emit (CodeGenerator codegen) {
+ codegen.visit_loop_statement (this);
+ }
+}
+