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

Unified Diff: runtime/lib/mirrors.cc

Issue 20208002: Inline MethodMirror creation (Closed) Base URL: https://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
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index 666109ab0bb413ac3f215a442841449bc95395ae..ba8f890fe574b37ce971cb5710ef62fc0139fa0f 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -550,36 +550,32 @@ static Dart_Handle CreateClassMirrorUsingApi(Dart_Handle intf,
}
+static RawInstance* CreateMethodMirror(const Function& func,
+ const Instance& owner_mirror) {
+ HANDLESCOPE(Isolate::Current());
siva 2013/07/25 20:54:40 Is the HANDLESCOPE here needed? Do we have a leak
Michael Lippautz (Google) 2013/07/25 21:06:38 It's not needed anymore. It was needed when the Mi
+ const Array& args = Array::Handle(Array::New(11));
+ args.SetAt(0, MirrorReference::Handle(MirrorReference::New(func)));
+ args.SetAt(1, owner_mirror);
+ args.SetAt(2, func.is_static() ? Bool::True() : Bool::False());
+ args.SetAt(3, func.is_abstract() ? Bool::True() : Bool::False());
+ args.SetAt(4, func.IsGetterFunction() ? Bool::True() : Bool::False());
+ args.SetAt(5, func.IsSetterFunction() ? Bool::True() : Bool::False());
+ args.SetAt(6, func.IsConstructor() ? Bool::True() : Bool::False());
+ // TODO(mlippautz): Implement different constructor kinds.
+ args.SetAt(7, Bool::False());
+ args.SetAt(8, Bool::False());
+ args.SetAt(9, Bool::False());
+ args.SetAt(10, Bool::False());
+ return CreateMirror(Symbols::_LocalMethodMirrorImpl(), args);
+}
+
+
static Dart_Handle CreateMethodMirrorUsingApi(Dart_Handle func,
Dart_Handle owner_mirror) {
- // TODO(11742): Unwrapping is needed until the whole method is converted.
Isolate* isolate = Isolate::Current();
- const Function& func_obj = Api::UnwrapFunctionHandle(isolate, func);
-
- Dart_Handle mirror_cls_name = NewString("_LocalMethodMirrorImpl");
- Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL);
- if (Dart_IsError(mirror_type)) {
- return mirror_type;
- }
-
- // TODO(turnidge): Implement constructor kinds (arguments 7 - 10).
- Dart_Handle args[] = {
- CreateMirrorReference(func),
- owner_mirror,
- CreateParameterMirrorListUsingApi(func),
- func_obj.is_static() ? Api::True() : Api::False(),
- func_obj.is_abstract() ? Api::True() : Api::False(),
- func_obj.IsGetterFunction() ? Api::True() : Api::False(),
- func_obj.IsSetterFunction() ? Api::True() : Api::False(),
- func_obj.IsConstructor() ? Api::True() : Api::False(),
- Api::False(),
- Api::False(),
- Api::False(),
- Api::False()
- };
- Dart_Handle mirror =
- Dart_New(mirror_type, Dart_Null(), ARRAY_SIZE(args), args);
- return mirror;
+ return Api::NewHandle(isolate, CreateMethodMirror(
+ Api::UnwrapFunctionHandle(isolate, func),
+ Api::UnwrapInstanceHandle(isolate, owner_mirror)));
}
static RawInstance* CreateVariableMirror(const Field& field,
@@ -1029,25 +1025,6 @@ static RawInstance* CreateLibraryMirror(const Library& lib) {
}
-static RawInstance* CreateMethodMirror(const Function& func,
- const Instance& owner_mirror) {
- Instance& retvalue = Instance::Handle();
- Dart_EnterScope();
- Isolate* isolate = Isolate::Current();
- Dart_Handle func_handle = Api::NewHandle(isolate, func.raw());
- Dart_Handle owner_handle = Api::NewHandle(isolate, owner_mirror.raw());
- // TODO(11742): At some point the handle calls will be replaced by inlined
- // functionality.
- Dart_Handle result = CreateMethodMirrorUsingApi(func_handle, owner_handle);
- if (Dart_IsError(result)) {
- Dart_PropagateError(result);
- }
- retvalue ^= Api::UnwrapHandle(result);
- Dart_ExitScope();
- return retvalue.raw();
-}
-
-
static RawInstance* CreateTypeMirror(const AbstractType& type) {
ASSERT(!type.IsMalformed());
if (type.HasResolvedTypeClass()) {
@@ -1890,6 +1867,13 @@ DEFINE_NATIVE_ENTRY(MethodMirror_owner, 1) {
}
+DEFINE_NATIVE_ENTRY(MethodMirror_parameters, 1) {
+ GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
+ const Function& func = Function::Handle(ref.GetFunctionReferent());
+ return CreateParameterMirrorList(func);
+}
+
+
DEFINE_NATIVE_ENTRY(MethodMirror_return_type, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
const Function& func = Function::Handle(ref.GetFunctionReferent());
« 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