Release 0.41.92
[vala-gnome.git] / vala / valatuple.vala
blobd35795a392a492f946c957f1afeadb58d6dfabd0
1 /* valatuple.vala
3 * Copyright (C) 2006-2010 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.1 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
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 using GLib;
25 /**
26 * Represents a fixed-length sequence of expressions in the source code.
28 public class Vala.Tuple : Expression {
29 private List<Expression> expression_list = new ArrayList<Expression> ();
31 public Tuple (SourceReference? source_reference = null) {
32 this.source_reference = source_reference;
35 public override void accept_children (CodeVisitor visitor) {
36 foreach (Expression expr in expression_list) {
37 expr.accept (visitor);
41 public override void accept (CodeVisitor visitor) {
42 visitor.visit_tuple (this);
44 visitor.visit_expression (this);
47 public void add_expression (Expression expr) {
48 expression_list.add (expr);
51 public List<Expression> get_expressions () {
52 return expression_list;
55 public override bool is_pure () {
56 return false;
59 public override void replace_expression (Expression old_node, Expression new_node) {
60 for (int i = 0; i < expression_list.size; i++) {
61 if (expression_list[i] == old_node) {
62 expression_list[i] = new_node;
67 public override bool check (CodeContext context) {
68 if (checked) {
69 return !error;
72 checked = true;
74 Report.error (source_reference, "tuples are not supported");
75 error = true;
76 return false;
79 public override void emit (CodeGenerator codegen) {
80 foreach (Expression expr in expression_list) {
81 expr.emit (codegen);
84 codegen.visit_tuple (this);
86 codegen.visit_expression (this);