summaryrefslogtreecommitdiff
path: root/vala/valablock.vala
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2007-05-02 09:42:00 +0000
committerJürg Billeter <juergbi@src.gnome.org>2007-05-02 09:42:00 +0000
commitf8387ad143f1884f8f5f89bd5389605624f4c34f (patch)
treee75e563fc9535200ec146af72962e80778359ae4 /vala/valablock.vala
parent9db973114ee1449c1764404163ecc8294f8e73d2 (diff)
downloadvala-f8387ad143f1884f8f5f89bd5389605624f4c34f.tar.gz
Move contents of vala-pkg to trunk
2007-05-02 Jürg Billeter <j@bitron.ch> * Move contents of vala-pkg to trunk svn path=/trunk/; revision=300
Diffstat (limited to 'vala/valablock.vala')
-rw-r--r--vala/valablock.vala92
1 files changed, 92 insertions, 0 deletions
diff --git a/vala/valablock.vala b/vala/valablock.vala
new file mode 100644
index 000000000..f25da4bdb
--- /dev/null
+++ b/vala/valablock.vala
@@ -0,0 +1,92 @@
+/* valablock.vala
+ *
+ * Copyright (C) 2006 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 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 a source code block.
+ */
+public class Vala.Block : Statement {
+ /**
+ * Specifies whether this block contains a jump statement. This
+ * information can be used to remove unreachable block cleanup code.
+ */
+ public bool contains_jump_statement { get; set; }
+
+ private List<Statement> statement_list;
+ private List<VariableDeclarator> local_variables;
+
+ /**
+ * Creates a new block.
+ *
+ * @param source reference to source code
+ */
+ public Block (SourceReference source = null) {
+ source_reference = source;
+ }
+
+ /**
+ * Append a statement to this block.
+ *
+ * @param stmt a statement
+ */
+ public void add_statement (Statement! stmt) {
+ statement_list.append (stmt);
+ }
+
+ /**
+ * Returns a copy of the list of statements.
+ *
+ * @return statement list
+ */
+ public ref List<weak Statement> get_statements () {
+ return statement_list.copy ();
+ }
+
+ /**
+ * Add a local variable to this block.
+ *
+ * @param decl a variable declarator
+ */
+ public void add_local_variable (VariableDeclarator! decl) {
+ local_variables.append (decl);
+ }
+
+ /**
+ * Returns a copy of the list of local variables.
+ *
+ * @return variable declarator list
+ */
+ public ref List<weak VariableDeclarator> get_local_variables () {
+ return local_variables.copy ();
+ }
+
+ public override void accept (CodeVisitor! visitor) {
+ visitor.visit_begin_block (this);
+
+ foreach (Statement! stmt in statement_list) {
+ stmt.accept (visitor);
+ }
+
+ visitor.visit_end_block (this);
+ }
+}