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

Unified Diff: runtime/vm/kernel_reader.cc

Issue 2693863006: VM: Restore old implementation of ClassID.cid* fields (Closed)
Patch Set: Done Created 3 years, 10 months 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/bootstrap_natives.h ('k') | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_reader.cc
diff --git a/runtime/vm/kernel_reader.cc b/runtime/vm/kernel_reader.cc
index b6940778f71ed6ec16e1ef81936f67730ac96749..752e42e667910e2f0b488177fb4fd96d654f8c8a 100644
--- a/runtime/vm/kernel_reader.cc
+++ b/runtime/vm/kernel_reader.cc
@@ -288,28 +288,37 @@ dart::Class& KernelReader::ReadClass(const dart::Library& library,
ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass);
- for (intptr_t i = 0; i < kernel_klass->fields().length(); i++) {
- Field* kernel_field = kernel_klass->fields()[i];
- ActiveMemberScope active_member_scope(&active_class_, kernel_field);
-
- const dart::String& name = H.DartFieldName(kernel_field->name());
- const AbstractType& type =
- T.TranslateTypeWithoutFinalization(kernel_field->type());
- const Object& script_class =
- ClassForScriptAt(klass, kernel_field->source_uri_index());
- dart::Field& field = dart::Field::Handle(
- Z, dart::Field::New(name, kernel_field->IsStatic(),
- // In the VM all const fields are implicitly final
- // whereas in Kernel they are not final because they
- // are not explicitly declared that way.
- kernel_field->IsFinal() || kernel_field->IsConst(),
- kernel_field->IsConst(),
- false, // is_reflectable
- script_class, type, kernel_field->position()));
- field.set_kernel_field(kernel_field);
- field.set_has_initializer(kernel_field->initializer() != NULL);
- GenerateFieldAccessors(klass, field, kernel_field);
- klass.AddField(field);
+ if (library.raw() == dart::Library::InternalLibrary() &&
+ klass.Name() == Symbols::ClassID().raw()) {
+ // If this is a dart:internal.ClassID class ignore field declarations
+ // contained in the Kernel file and instead inject our own const
+ // fields.
+ klass.InjectCIDFields();
+ } else {
+ for (intptr_t i = 0; i < kernel_klass->fields().length(); i++) {
+ Field* kernel_field = kernel_klass->fields()[i];
+ ActiveMemberScope active_member_scope(&active_class_, kernel_field);
+
+ const dart::String& name = H.DartFieldName(kernel_field->name());
+ const AbstractType& type =
+ T.TranslateTypeWithoutFinalization(kernel_field->type());
+ const Object& script_class =
+ ClassForScriptAt(klass, kernel_field->source_uri_index());
+ dart::Field& field = dart::Field::Handle(
+ Z,
+ dart::Field::New(name, kernel_field->IsStatic(),
+ // In the VM all const fields are implicitly final
+ // whereas in Kernel they are not final because they
+ // are not explicitly declared that way.
+ kernel_field->IsFinal() || kernel_field->IsConst(),
+ kernel_field->IsConst(),
+ false, // is_reflectable
+ script_class, type, kernel_field->position()));
+ field.set_kernel_field(kernel_field);
+ field.set_has_initializer(kernel_field->initializer() != NULL);
+ GenerateFieldAccessors(klass, field, kernel_field);
+ klass.AddField(field);
+ }
}
for (intptr_t i = 0; i < kernel_klass->constructors().length(); i++) {
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698