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

Unified Diff: runtime/vm/parser.cc

Issue 2498863002: Map deleted enum values to a sentinel value. (Closed)
Patch Set: asiva review Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object_reload.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 86264b9b2308c14281548bc15378f97f132ccecb..04a339079180bc2ef5752ebd6ea8ca5c153446bd 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -4854,6 +4854,7 @@ void Parser::ParseEnumDefinition(const Class& cls) {
}
ExpectToken(Token::kRBRACE);
+ const Type& array_type = Type::Handle(Z, Type::ArrayType());
// Add static field 'const List values'.
Field& values_field = Field::ZoneHandle(Z);
values_field =
@@ -4861,10 +4862,19 @@ void Parser::ParseEnumDefinition(const Class& cls) {
/* is_static = */ true,
/* is_final = */ true,
/* is_const = */ true,
- /* is_reflectable = */ true, cls,
- Type::Handle(Z, Type::ArrayType()), cls.token_pos());
+ /* is_reflectable = */ true, cls, array_type, cls.token_pos());
enum_members.AddField(values_field);
+ // Add static field 'const _deleted_enum_sentinel'.
+ Field& deleted_enum_sentinel = Field::ZoneHandle(Z);
+ deleted_enum_sentinel = Field::New(Symbols::_DeletedEnumSentinel(),
+ /* is_static = */ true,
+ /* is_final = */ true,
+ /* is_const = */ true,
+ /* is_reflectable = */ false, cls,
+ Object::dynamic_type(), cls.token_pos());
+ enum_members.AddField(deleted_enum_sentinel);
+
// Allocate the immutable array containing the enumeration values.
// The actual enum instance values will be patched in later.
const Array& values_array = Array::Handle(Z, Array::New(i, Heap::kOld));
« no previous file with comments | « runtime/vm/object_reload.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698