change run to use meson/ninja and then exec. - remove libvala code from application...
[roobuilder] / src / ccode / valaccodeelementaccess.vala
1 /* valaccodememberaccess.vala
2  *
3  * Copyright (C) 2006  Raffaele Sandrini
4  * Copyright (C) 2006-2008  Jürg Billeter
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
19  *
20  * Author:
21  *      Raffaele Sandrini <raffaele@sandrini.ch>
22  *      Jürg Billeter <j@bitron.ch>
23  */
24
25 using GLib;
26
27 /**
28  * Represents an access to an array member in the C code.
29  */
30 public class Vala.CCodeElementAccess : CCodeExpression {
31         /**
32          * Expression representing the container on which we want to access.
33          */
34         public CCodeExpression container { get; set; }
35
36         /**
37          * Expression representing the index we want to access inside the
38          * container.
39          */
40         public List<CCodeExpression> indices { get; set; }
41
42         public CCodeElementAccess (CCodeExpression cont, CCodeExpression i) {
43                 container = cont;
44                 indices = new ArrayList<CCodeExpression> ();
45                 indices.add (i);
46         }
47
48         public CCodeElementAccess.with_indices (CCodeExpression cont, List<CCodeExpression> i) {
49                 container = cont;
50                 indices = i;
51         }
52
53         public override void write (CCodeWriter writer) {
54                 container.write_inner (writer);
55                 writer.write_string ("[");
56                 bool first = true;
57                 foreach (var index in indices) {
58                         if (!first) {
59                                 writer.write_string ("][");
60                         }
61                         index.write (writer);
62                         first = false;
63                 }
64                 writer.write_string ("]");
65         }
66 }