| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/class_finalizer.h" | 5 #include "vm/class_finalizer.h" |
| 6 | 6 |
| 7 #include "vm/code_generator.h" | 7 #include "vm/code_generator.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2376 for (intptr_t i = 0; i < fields.Length(); i++) { | 2376 for (intptr_t i = 0; i < fields.Length(); i++) { |
| 2377 field = Field::RawCast(fields.At(i)); | 2377 field = Field::RawCast(fields.At(i)); |
| 2378 if (!field.is_static()) continue; | 2378 if (!field.is_static()) continue; |
| 2379 ordinal_value = field.value(); | 2379 ordinal_value = field.value(); |
| 2380 // The static fields that need to be initialized with enum instances | 2380 // The static fields that need to be initialized with enum instances |
| 2381 // contain the smi value of the ordinal number, which was stored in | 2381 // contain the smi value of the ordinal number, which was stored in |
| 2382 // the field by the parser. Other fields contain non-smi values. | 2382 // the field by the parser. Other fields contain non-smi values. |
| 2383 if (!ordinal_value.IsSmi()) continue; | 2383 if (!ordinal_value.IsSmi()) continue; |
| 2384 enum_value = Instance::New(enum_cls, Heap::kOld); | 2384 enum_value = Instance::New(enum_cls, Heap::kOld); |
| 2385 enum_value.SetField(index_field, ordinal_value); | 2385 enum_value.SetField(index_field, ordinal_value); |
| 2386 const char* error_msg = ""; |
| 2387 enum_value = enum_value.CheckAndCanonicalize(&error_msg); |
| 2388 if (enum_value.IsNull()) { |
| 2389 ReportError(enum_cls, enum_cls.token_pos(), "Failed finalizing values."); |
| 2390 UNREACHABLE(); |
| 2391 } |
| 2392 ASSERT(enum_value.IsCanonical()); |
| 2386 field.set_value(enum_value); | 2393 field.set_value(enum_value); |
| 2387 field.RecordStore(enum_value); | 2394 field.RecordStore(enum_value); |
| 2388 intptr_t ord = Smi::Cast(ordinal_value).Value(); | 2395 intptr_t ord = Smi::Cast(ordinal_value).Value(); |
| 2389 ASSERT(ord < values_list.Length()); | 2396 ASSERT(ord < values_list.Length()); |
| 2390 values_list.SetAt(ord, enum_value); | 2397 values_list.SetAt(ord, enum_value); |
| 2391 } | 2398 } |
| 2392 values_list.MakeImmutable(); | 2399 values_list.MakeImmutable(); |
| 2393 } | 2400 } |
| 2394 | 2401 |
| 2395 | 2402 |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3140 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3147 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
| 3141 field ^= fields_array.At(0); | 3148 field ^= fields_array.At(0); |
| 3142 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3149 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
| 3143 name ^= field.name(); | 3150 name ^= field.name(); |
| 3144 expected_name ^= String::New("_data"); | 3151 expected_name ^= String::New("_data"); |
| 3145 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3152 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 3146 #endif | 3153 #endif |
| 3147 } | 3154 } |
| 3148 | 3155 |
| 3149 } // namespace dart | 3156 } // namespace dart |
| OLD | NEW |