valaccodeelementaccess.vala 1.6 KB
Newer Older
1 2 3
/* valaccodememberaccess.vala
 *
 * Copyright (C) 2006  Raffaele Sandrini
Jürg Billeter's avatar
Jürg Billeter committed
4
 * Copyright (C) 2006-2008  Jürg Billeter
5 6 7 8
 *
 * 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
9
 * version 2.1 of the License, or (at your option) any later version.
10 11 12 13 14 15 16 17 18 19 20

 * 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:
21
 * 	Raffaele Sandrini <raffaele@sandrini.ch>
22
 *	Jürg Billeter <j@bitron.ch>
23 24 25 26 27
 */

using GLib;

/**
28
 * Represents an access to an array member in the C code.
29 30 31
 */
public class Vala.CCodeElementAccess : CCodeExpression {
	/**
32
	 * Expression representing the container on which we want to access.
33
	 */
34
	public CCodeExpression container { get; set; }
35 36
	
	/**
37 38
	 * Expression representing the index we want to access inside the
	 * container.
39
	 */
40
	public CCodeExpression index { get; set; }
41
	
42
	public CCodeElementAccess (CCodeExpression cont, CCodeExpression i) {
43 44 45 46
		container = cont;
		index = i;
	}
	
47
	public override void write (CCodeWriter writer) {
Jürg Billeter's avatar
Jürg Billeter committed
48
		container.write_inner (writer);
49 50 51 52 53
		writer.write_string ("[");
		index.write (writer);
		writer.write_string ("]");
	}
}