~ubuntu-branches/ubuntu/maverick/vala/maverick

« back to all changes in this revision

Viewing changes to vala/valaswitchstatement.vala

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-04-02 10:10:55 UTC
  • mfrom: (1.4.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100402101055-qbx3okzv0tnp3wpp
Tags: 0.8.0-0ubuntu1
* New upstream release:
  - Infer type arguments when calling generic methods.
  - Support `in' operator for arrays.
  - Add experimental support for regular expression literals.
  - Add experimental support for chained relational expressions.
  - Add va_list support.
  - Add clutter-gtk-0.10 bindings (Gordon Allott).
  - Add gdl-1.0 bindings (Nicolas Joseph).
  - Add gstreamer-app-0.10 bindings (Sebastian Dröge).
  - Add gstreamer-cdda-0.10 bindings (Sebastian Dröge).
  - Add gudev-1.0 bindings (Jim Nelson).
  - Add libgda-report-4.0 bindings (Shawn Ferris).
  - Add libgvc (graphviz) bindings (Martin Olsson).
  - Add purple bindings (Adrien Bustany).
  - Many bug fixes and binding updates.
* debian/patches/99_ltmain_as-needed.patch: refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* valaswitchstatement.vala
2
2
 *
3
 
 * Copyright (C) 2006-2009  Jürg Billeter
 
3
 * Copyright (C) 2006-2010  Jürg Billeter
4
4
 *
5
5
 * This library is free software; you can redistribute it and/or
6
6
 * modify it under the terms of the GNU Lesser General Public
70
70
         * @return section list
71
71
         */
72
72
        public List<SwitchSection> get_sections () {
73
 
                return new ReadOnlyList<SwitchSection> (sections);
 
73
                return sections;
74
74
        }
75
75
 
76
76
        public override void accept (CodeVisitor visitor) {
116
116
                // ensure that possibly owned (string) expression stays alive
117
117
                expression.target_type = expression.value_type.copy ();
118
118
 
 
119
                var labelset = new HashSet<string> (str_hash, str_equal);
119
120
                foreach (SwitchSection section in sections) {
120
121
                        section.check (analyzer);
 
122
 
 
123
                        // check for duplicate literal case labels
 
124
                        // FIXME: make it work for all constant expressions
 
125
                        foreach (SwitchLabel label in section.get_labels ()) {
 
126
                                string? value = null;
 
127
                                if (label.expression is StringLiteral) {
 
128
                                        value = ((StringLiteral)label.expression).eval ();
 
129
                                } else if (label.expression is Literal) {
 
130
                                        value = ((Literal)label.expression).to_string ();
 
131
                                }
 
132
 
 
133
                                if (value != null && !labelset.add (value)) {
 
134
                                        error = true;
 
135
                                        Report.error (label.expression.source_reference, "Switch statement already contains this label");
 
136
                                }
 
137
                        }
 
138
                        add_error_types (section.get_error_types ());
121
139
                }
122
140
 
123
141
                return !error;