1 /* valaarraycreationexpression.vala
3 * Copyright (C) 2006-2007 Raffaele Sandrini, Jürg Billeter
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 of the License, or (at your option) any later version.
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.
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
20 * Raffaele Sandrini <rasa@gmx.ch>
21 * Jürg Billeter <j@bitron.ch>
27 * Represents an array creation expression e.g. "new int[] {1,2,3}".
29 public class Vala
.ArrayCreationExpression
: Expression
{
31 * The type of the elements of the array.
33 public TypeReference element_type
{ get; set construct; }
36 * The rank of the array.
38 public int rank
{ get; set construct; }
41 * The size for each dimension ascending from left to right.
43 private List
<Expression
> sizes
;
46 * The root array initializer list.
48 public InitializerList initializer_list
{ get; set construct; }
51 * Add a size expression.
53 public void append_size (Expression
! size
) {
58 * Get the sizes for all dimensions ascending from left to right.
60 public List
<weak Expression
> get_sizes () {
64 public ArrayCreationExpression (TypeReference _element_type
, int _rank
, InitializerList _initializer
, SourceReference source
) {
65 element_type
= _element_type
;
67 initializer_list
= _initializer
;
68 source_reference
= source
;
71 public override void accept (CodeVisitor
! visitor
) {
72 if (element_type
!= null) {
73 element_type
.accept (visitor
);
77 foreach (Expression e
in sizes
) {
82 visitor
.visit_begin_array_creation_expression (this
);
84 if (initializer_list
!= null) {
85 initializer_list
.accept (visitor
);
88 visitor
.visit_end_array_creation_expression (this
);