Line data Source code
1 : /* valastatementlist.vala
2 : *
3 : * Copyright (C) 2008-2010 Jürg Billeter
4 : *
5 : * This library is free software; you can redistribute it and/or
6 : * modify it under the terms of the GNU Lesser General Public
7 : * License as published by the Free Software Foundation; either
8 : * version 2.1 of the License, or (at your option) any later version.
9 :
10 : * This library is distributed in the hope that it will be useful,
11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 : * Lesser General Public License for more details.
14 :
15 : * You should have received a copy of the GNU Lesser General Public
16 : * License along with this library; if not, write to the Free Software
17 : * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 : *
19 : * Author:
20 : * Jürg Billeter <j@bitron.ch>
21 : */
22 :
23 :
24 80698 : public class Vala.StatementList : CodeNode, Statement {
25 77852 : private List<Statement> list = new ArrayList<Statement> ();
26 :
27 : public int length {
28 364455 : get { return list.size; }
29 : }
30 :
31 77852 : public StatementList (SourceReference? source_reference = null) {
32 38926 : this.source_reference = source_reference;
33 : }
34 :
35 310215 : public Statement get (int index) {
36 310215 : return list.get (index);
37 : }
38 :
39 9 : public void set (int index, Statement stmt) {
40 9 : list.set (index, stmt);
41 : }
42 :
43 77852 : public void add (Statement stmt) {
44 77852 : list.add (stmt);
45 : }
46 :
47 54299 : public void insert (int index, Statement stmt) {
48 54299 : list.insert (index, stmt);
49 : }
50 :
51 0 : public override void get_error_types (Collection<DataType> collection, SourceReference? source_reference = null) {
52 0 : foreach (var stmt in list) {
53 0 : stmt.get_error_types (collection, source_reference);
54 : }
55 : }
56 :
57 27168 : public override void accept (CodeVisitor visitor) {
58 211856 : foreach (Statement stmt in list) {
59 92344 : stmt.accept (visitor);
60 : }
61 : }
62 :
63 0 : public override bool check (CodeContext context) {
64 0 : foreach (Statement stmt in list) {
65 0 : if (!stmt.check (context)) {
66 0 : return false;
67 : }
68 : }
69 0 : return true;
70 : }
71 :
72 0 : public override void emit (CodeGenerator codegen) {
73 0 : foreach (Statement stmt in list) {
74 0 : stmt.emit (codegen);
75 : }
76 : }
77 : }
|