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

Unified Diff: runtime/lib/mirrors.cc

Issue 21440002: Inline CreateClassMirror and remove dead code. (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/vm/symbols.h » ('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 f62fe0c7a6c3964abc0c4c53d8a1e9f5c5f486dd..a2032fa7125f220b09bccd9579f7d05c1a749f0d 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -2,19 +2,13 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-#include "include/dart_api.h"
-#include "include/dart_debugger_api.h"
-#include "include/dart_mirrors_api.h"
-#include "vm/dart_api_impl.h"
-#include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef.
+#include "lib/invocation_mirror.h"
#include "vm/bootstrap_natives.h"
#include "vm/dart_entry.h"
#include "vm/exceptions.h"
-#include "vm/message.h"
#include "vm/object_store.h"
#include "vm/port.h"
#include "vm/symbols.h"
-#include "lib/invocation_mirror.h"
namespace dart {
@@ -33,11 +27,6 @@ static RawInstance* CreateMirror(const String& mirror_class_name,
}
-inline Dart_Handle NewString(const char* str) {
- return Dart_NewStringFromCString(str);
-}
-
-
DEFINE_NATIVE_ENTRY(Mirrors_isLocalPort, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(Instance, port, arguments->NativeArgAt(0));
@@ -55,24 +44,6 @@ DEFINE_NATIVE_ENTRY(Mirrors_isLocalPort, 1) {
}
-static Dart_Handle MirrorLib() {
- Dart_Handle mirror_lib_name = NewString("dart:mirrors");
- return Dart_LookupLibrary(mirror_lib_name);
-}
-
-
-// TODO(11742): Remove once there are no more users of the Dart_Handle-based
-// VMReferences.
-static Dart_Handle CreateMirrorReference(Dart_Handle handle) {
- Isolate* isolate = Isolate::Current();
- DARTSCOPE(isolate);
- const Object& referent = Object::Handle(isolate, Api::UnwrapHandle(handle));
- const MirrorReference& reference =
- MirrorReference::Handle(MirrorReference::New(referent));
- return Api::NewHandle(isolate, reference.raw());
-}
-
-
static RawInstance* CreateParameterMirrorList(const Function& func) {
HANDLESCOPE(Isolate::Current());
const intptr_t param_cnt = func.num_fixed_parameters() -
@@ -137,42 +108,6 @@ static RawInstance* CreateTypedefMirror(const Class& cls,
}
-static Dart_Handle CreateTypedefMirrorUsingApi(Dart_Handle cls,
- Dart_Handle cls_name,
- Dart_Handle owner_mirror) {
- Isolate* isolate = Isolate::Current();
- return Api::NewHandle(
- isolate, CreateTypedefMirror(
- Api::UnwrapClassHandle(isolate, cls),
- Api::UnwrapInstanceHandle(isolate, owner_mirror)));
-}
-
-
-static Dart_Handle CreateClassMirrorUsingApi(Dart_Handle intf,
- Dart_Handle intf_name,
- Dart_Handle lib_mirror) {
- ASSERT(Dart_IsClass(intf));
- if (Dart_ClassIsTypedef(intf)) {
- // This class is actually a typedef. Represent it specially in
- // reflection.
- return CreateTypedefMirrorUsingApi(intf, intf_name, lib_mirror);
- }
-
- Dart_Handle cls_name = NewString("_LocalClassMirrorImpl");
- Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL);
- if (Dart_IsError(type)) {
- return type;
- }
-
- Dart_Handle args[] = {
- CreateMirrorReference(intf),
- Dart_Null(), // "name"
- };
- Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args);
- return mirror;
-}
-
-
static RawInstance* CreateMethodMirror(const Function& func,
const Instance& owner_mirror) {
const Array& args = Array::Handle(Array::New(12));
@@ -214,29 +149,14 @@ static RawInstance* CreateVariableMirror(const Field& field,
static RawInstance* CreateClassMirror(const Class& cls,
const Instance& owner_mirror) {
- Instance& retvalue = Instance::Handle();
- Dart_EnterScope();
- Isolate* isolate = Isolate::Current();
- Dart_Handle cls_handle = Api::NewHandle(isolate, cls.raw());
- if (Dart_IsError(cls_handle)) {
- Dart_PropagateError(cls_handle);
+ // We represent typedefs as non-canonical signature classes.
+ if (cls.IsSignatureClass() && !cls.IsCanonicalSignatureClass()) {
rmacnak 2013/08/01 00:06:19 If it is a canonical signature class, create a Fun
Michael Lippautz (Google) 2013/08/01 17:05:10 Done.
+ return CreateTypedefMirror(cls, owner_mirror);
}
- Dart_Handle name_handle = Api::NewHandle(isolate, cls.Name());
- if (Dart_IsError(name_handle)) {
- Dart_PropagateError(name_handle);
- }
- Dart_Handle lib_mirror = Api::NewHandle(isolate, owner_mirror.raw());
- // TODO(11742): At some point the handle calls will be replaced by inlined
- // functionality.
- Dart_Handle result = CreateClassMirrorUsingApi(cls_handle,
- name_handle,
- lib_mirror);
- if (Dart_IsError(result)) {
- Dart_PropagateError(result);
- }
- retvalue ^= Api::UnwrapHandle(result);
- Dart_ExitScope();
- return retvalue.raw();
+ const Array& args = Array::Handle(Array::New(2));
+ args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls)));
+ args.SetAt(1, String::Handle(cls.UserVisibleName()));
+ return CreateMirror(Symbols::_LocalClassMirrorImpl(), args);
}
@@ -323,33 +243,10 @@ DEFINE_NATIVE_ENTRY(Mirrors_makeLocalMirrorSystem, 0) {
}
-void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalClassMirror)(
- Dart_NativeArguments args) {
- Dart_EnterScope();
- Isolate* isolate = Isolate::Current();
- Dart_Handle key = Dart_GetNativeArgument(args, 0);
- if (Dart_IsError(key)) {
- Dart_PropagateError(key);
- }
- const Type& type = Api::UnwrapTypeHandle(isolate, key);
+DEFINE_NATIVE_ENTRY(Mirrors_makeLocalClassMirror, 1) {
+ GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0));
const Class& cls = Class::Handle(type.type_class());
- Dart_Handle cls_handle = Api::NewHandle(isolate, cls.raw());
- if (Dart_IsError(cls_handle)) {
- Dart_PropagateError(cls_handle);
- }
- Dart_Handle name_handle = Api::NewHandle(isolate, cls.Name());
- if (Dart_IsError(name_handle)) {
- Dart_PropagateError(name_handle);
- }
- Dart_Handle lib_mirror = Dart_Null();
- Dart_Handle result = CreateClassMirrorUsingApi(cls_handle,
- name_handle,
- lib_mirror);
- if (Dart_IsError(result)) {
- Dart_PropagateError(result);
- }
- Dart_SetReturnValue(args, result);
- Dart_ExitScope();
+ return CreateClassMirror(cls, Object::null_instance());
}
@@ -417,13 +314,6 @@ DEFINE_NATIVE_ENTRY(FunctionTypeMirror_return_type, 1) {
}
-void HandleMirrorsMessage(Isolate* isolate,
- Dart_Port reply_port,
- const Instance& message) {
- UNIMPLEMENTED();
-}
-
-
static bool FieldIsUninitialized(const Field& field) {
ASSERT(!field.IsNull());
« no previous file with comments | « no previous file | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698