Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: runtime/vm/class_finalizer.cc

Issue 745023002: - Properly canonicalize enum values. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698