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

Unified Diff: runtime/lib/mirrors.cc

Issue 19188004: Make the ClassMirrors created through reflectClass() find their owners (libraries) lazily. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
===================================================================
--- runtime/lib/mirrors.cc (revision 25127)
+++ runtime/lib/mirrors.cc (working copy)
@@ -421,7 +421,6 @@
static Dart_Handle CreateTypedefMirror(Dart_Handle cls,
Dart_Handle cls_name,
- Dart_Handle owner,
Dart_Handle owner_mirror) {
Dart_Handle mirror_cls_name = NewString("_LocalTypedefMirrorImpl");
Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL);
@@ -452,13 +451,12 @@
static Dart_Handle CreateClassMirror(Dart_Handle intf,
Dart_Handle intf_name,
- Dart_Handle lib,
Dart_Handle lib_mirror) {
ASSERT(Dart_IsClass(intf));
if (Dart_ClassIsTypedef(intf)) {
// This class is actually a typedef. Represent it specially in
// reflection.
- return CreateTypedefMirror(intf, intf_name, lib, lib_mirror);
+ return CreateTypedefMirror(intf, intf_name, lib_mirror);
}
Dart_Handle cls_name = NewString("_LocalClassMirrorImpl");
@@ -611,7 +609,7 @@
return intf;
}
Dart_Handle intf_mirror =
- CreateClassMirror(intf, intf_name, owner, owner_mirror);
+ CreateClassMirror(intf, intf_name, owner_mirror);
if (Dart_IsError(intf_mirror)) {
return intf_mirror;
}
@@ -1011,17 +1009,9 @@
if (Dart_IsError(name_handle)) {
Dart_PropagateError(name_handle);
}
- Dart_Handle lib_handle = Api::NewHandle(isolate, cls.library());
- if (Dart_IsError(lib_handle)) {
- Dart_PropagateError(lib_handle);
- }
- Dart_Handle lib_mirror = CreateLibraryMirror(lib_handle);
- if (Dart_IsError(lib_mirror)) {
- Dart_PropagateError(lib_mirror);
- }
+ Dart_Handle lib_mirror = Dart_Null();
Dart_Handle result = CreateClassMirror(cls_handle,
name_handle,
- lib_handle,
lib_mirror);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
@@ -1192,6 +1182,25 @@
}
+DEFINE_NATIVE_ENTRY(ClassMirror_library, 1) {
+ const MirrorReference& klass_ref =
+ MirrorReference::CheckedHandle(arguments->NativeArgAt(0));
+ Class& klass = Class::Handle();
+ klass ^= klass_ref.referent();
+
+ // TODO(11742): This is transitional.
+ Instance& result = Instance::Handle();
+ Dart_EnterScope();
+ DARTSCOPE(isolate);
rmacnak 2013/07/18 02:50:02 Is this needed, or is Dart_EnterScope fine by itse
rmacnak 2013/07/18 17:27:30 It appears not. Without it, tests pass and perform
+ result = Instance::RawCast(
+ Api::UnwrapHandle(
+ CreateLibraryMirror(
+ Api::NewHandle(isolate, klass.library()))));
+ Dart_ExitScope();
+ return result.raw();
+}
+
+
// Invoke the function, or noSuchMethod if it is null. Propagate any unhandled
// exceptions. Wrap and propagate any compilation errors.
static RawObject* ReflectivelyInvokeDynamicFunction(const Instance& receiver,
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698