~ubuntu-branches/ubuntu/natty/vala/natty

« back to all changes in this revision

Viewing changes to vala/valaconstant.vala

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2010-11-09 20:07:00 UTC
  • mfrom: (1.5.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20101109200700-sqa6eyuhymlhvfmo
Tags: 0.11.2-0ubuntu1
* New upstream release (LP: #673166)
* debian/control
  - bump standard version to 3.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
163
163
                }
164
164
        }
165
165
 
166
 
        public override bool check (SemanticAnalyzer analyzer) {
 
166
        public override bool check (CodeContext context) {
167
167
                if (checked) {
168
168
                        return !error;
169
169
                }
172
172
 
173
173
                process_attributes ();
174
174
 
175
 
                var old_source_file = analyzer.current_source_file;
176
 
                var old_symbol = analyzer.current_symbol;
 
175
                var old_source_file = context.analyzer.current_source_file;
 
176
                var old_symbol = context.analyzer.current_symbol;
177
177
 
178
178
                if (source_reference != null) {
179
 
                        analyzer.current_source_file = source_reference.file;
 
179
                        context.analyzer.current_source_file = source_reference.file;
180
180
                }
181
 
                analyzer.current_symbol = this;
182
 
 
183
 
                type_reference.check (analyzer);
184
 
 
185
 
                if (!check_const_type (type_reference, analyzer)) {
 
181
                context.analyzer.current_symbol = this;
 
182
 
 
183
                type_reference.check (context);
 
184
 
 
185
                if (!check_const_type (type_reference, context)) {
186
186
                        error = true;
187
187
                        Report.error (source_reference, "`%s' not supported as type for constants".printf (type_reference.to_string ()));
188
188
                        return false;
195
195
                        } else {
196
196
                                value.target_type = type_reference;
197
197
 
198
 
                                value.check (analyzer);
 
198
                                value.check (context);
199
199
 
200
200
                                if (!value.value_type.compatible (type_reference)) {
201
201
                                        error = true;
214
214
                        Report.warning (source_reference, "%s hides inherited constant `%s'. Use the `new' keyword if hiding was intentional".printf (get_full_name (), get_hidden_member ().get_full_name ()));
215
215
                }
216
216
 
217
 
                analyzer.current_source_file = old_source_file;
218
 
                analyzer.current_symbol = old_symbol;
 
217
                context.analyzer.current_source_file = old_source_file;
 
218
                context.analyzer.current_symbol = old_symbol;
219
219
 
220
220
                active = true;
221
221
 
222
222
                return !error;
223
223
        }
224
224
 
225
 
        bool check_const_type (DataType type, SemanticAnalyzer analyzer) {
 
225
        bool check_const_type (DataType type, CodeContext context) {
226
226
                if (type is ValueType) {
227
227
                        return true;
228
228
                } else if (type is ArrayType) {
229
229
                        var array_type = type as ArrayType;
230
 
                        return check_const_type (array_type.element_type, analyzer);
231
 
                } else if (type.data_type == analyzer.string_type.data_type) {
 
230
                        return check_const_type (array_type.element_type, context);
 
231
                } else if (type.data_type == context.analyzer.string_type.data_type) {
232
232
                        return true;
233
233
                } else {
234
234
                        return false;