blob: 55aba15ff4363db324597d705bf62a1a658148b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/* valainitializerlist.vala
*
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
*
* 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>
* Raffaele Sandrini <raffaele@sandrini.ch>
*/
using GLib;
using Gee;
/**
* Represents an array or struct initializer list in the source code.
*/
public class Vala.InitializerList : Expression {
private Gee.List<Expression> initializers = new ArrayList<Expression> ();
/**
* Appends the specified expression to this initializer list.
*
* @param expr an expression
*/
public void append (Expression expr) {
initializers.add (expr);
}
/**
* Returns a copy of the expression list.
*
* @return expression list
*/
public Collection<Expression> get_initializers () {
return new ReadOnlyCollection<Expression> (initializers);
}
/**
* Returns the initializer count in this initializer list.
*/
public int size {
get { return initializers.size; }
}
/**
* Creates a new initializer list.
*
* @param source_reference reference to source code
* @return newly created initializer list
*/
public InitializerList (construct SourceReference source_reference) {
}
public override void accept_children (CodeVisitor visitor) {
foreach (Expression expr in initializers) {
expr.accept (visitor);
}
}
public override void accept (CodeVisitor visitor) {
visitor.visit_initializer_list (this);
}
public override bool is_pure () {
foreach (Expression initializer in initializers) {
if (!initializer.is_pure ()) {
return false;
}
}
return true;
}
}
|