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

Unified Diff: runtime/vm/object.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/object.h ('k') | tools/patch_sdk.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index b8da11621e888fdcac9c668face1563ce1bfda2e..ba18f72c30c140e43e766eb77933f3aa87024c00 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -1670,6 +1670,13 @@ RawError* Object::Init(Isolate* isolate, kernel::Program* kernel_program) {
// Set up recognized state of all functions (core, math and typed data).
MethodRecognizer::InitializeState();
+ // Adds static const fields (class ids) to the class 'ClassID');
+ lib = Library::LookupLibrary(thread, Symbols::DartInternal());
+ ASSERT(!lib.IsNull());
+ cls = lib.LookupClassAllowPrivate(Symbols::ClassID());
+ ASSERT(!cls.IsNull());
+ cls.InjectCIDFields();
+
isolate->object_store()->InitKnownObjects();
#endif // !defined(DART_PRECOMPILED_RUNTIME)
} else {
@@ -3157,6 +3164,32 @@ void Class::AddFields(const GrowableArray<const Field*>& new_fields) const {
}
+void Class::InjectCIDFields() const {
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
+ Field& field = Field::Handle(zone);
+ Smi& value = Smi::Handle(zone);
+ String& field_name = String::Handle(zone);
+
+#define CLASS_LIST_WITH_NULL(V) \
+ V(Null) \
+ CLASS_LIST_NO_OBJECT(V)
+
+#define ADD_SET_FIELD(clazz) \
+ field_name = Symbols::New(thread, "cid" #clazz); \
+ field = \
+ Field::New(field_name, true, false, true, false, *this, \
+ Type::Handle(Type::IntType()), TokenPosition::kMinSource); \
+ value = Smi::New(k##clazz##Cid); \
+ field.SetStaticValue(value, true); \
+ AddField(field);
+
+ CLASS_LIST_WITH_NULL(ADD_SET_FIELD)
+#undef ADD_SET_FIELD
+#undef CLASS_LIST_WITH_NULL
+}
+
+
template <class FakeInstance>
RawClass* Class::NewCommon(intptr_t index) {
ASSERT(Object::class_class() != Class::null());
« no previous file with comments | « runtime/vm/object.h ('k') | tools/patch_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698