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

Side by Side Diff: runtime/lib/mirrors.cc

Issue 21281002: Hoist .simpleName and .qualifiedName up to _LocalDeclarationMirrorImpl. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_debugger_api.h" 6 #include "include/dart_debugger_api.h"
7 #include "include/dart_mirrors_api.h" 7 #include "include/dart_mirrors_api.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef. 9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef.
10 #include "vm/bootstrap_natives.h" 10 #include "vm/bootstrap_natives.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 Dart_Null(), // "name" 359 Dart_Null(), // "name"
360 type_var_map, 360 type_var_map,
361 }; 361 };
362 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); 362 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args);
363 return mirror; 363 return mirror;
364 } 364 }
365 365
366 366
367 static RawInstance* CreateMethodMirror(const Function& func, 367 static RawInstance* CreateMethodMirror(const Function& func,
368 const Instance& owner_mirror) { 368 const Instance& owner_mirror) {
369 const Array& args = Array::Handle(Array::New(11)); 369 const Array& args = Array::Handle(Array::New(12));
370 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(func))); 370 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(func)));
371 args.SetAt(1, owner_mirror); 371 args.SetAt(1, String::Handle(func.UserVisibleName()));
372 args.SetAt(2, func.is_static() ? Bool::True() : Bool::False()); 372 args.SetAt(2, owner_mirror);
373 args.SetAt(3, func.is_abstract() ? Bool::True() : Bool::False()); 373 args.SetAt(3, func.is_static() ? Bool::True() : Bool::False());
374 args.SetAt(4, func.IsGetterFunction() ? Bool::True() : Bool::False()); 374 args.SetAt(4, func.is_abstract() ? Bool::True() : Bool::False());
375 args.SetAt(5, func.IsSetterFunction() ? Bool::True() : Bool::False()); 375 args.SetAt(5, func.IsGetterFunction() ? Bool::True() : Bool::False());
376 args.SetAt(6, func.IsConstructor() ? Bool::True() : Bool::False()); 376 args.SetAt(6, func.IsSetterFunction() ? Bool::True() : Bool::False());
377 args.SetAt(7, func.IsConstructor() ? Bool::True() : Bool::False());
377 // TODO(mlippautz): Implement different constructor kinds. 378 // TODO(mlippautz): Implement different constructor kinds.
378 args.SetAt(7, Bool::False());
379 args.SetAt(8, Bool::False()); 379 args.SetAt(8, Bool::False());
380 args.SetAt(9, Bool::False()); 380 args.SetAt(9, Bool::False());
381 args.SetAt(10, Bool::False()); 381 args.SetAt(10, Bool::False());
382 args.SetAt(11, Bool::False());
382 return CreateMirror(Symbols::_LocalMethodMirrorImpl(), args); 383 return CreateMirror(Symbols::_LocalMethodMirrorImpl(), args);
383 } 384 }
384 385
385 386
386 static RawInstance* CreateVariableMirror(const Field& field, 387 static RawInstance* CreateVariableMirror(const Field& field,
387 const Instance& owner_mirror) { 388 const Instance& owner_mirror) {
388 const MirrorReference& field_ref = 389 const MirrorReference& field_ref =
389 MirrorReference::Handle(MirrorReference::New(field)); 390 MirrorReference::Handle(MirrorReference::New(field));
390 391
391 const String& name = String::Handle(field.UserVisibleName()); 392 const String& name = String::Handle(field.UserVisibleName());
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 setter_name.ToCString())); 1384 setter_name.ToCString()));
1384 ThrowMirroredCompilationError(message); 1385 ThrowMirroredCompilationError(message);
1385 UNREACHABLE(); 1386 UNREACHABLE();
1386 } 1387 }
1387 1388
1388 field.set_value(value); 1389 field.set_value(value);
1389 return value.raw(); 1390 return value.raw();
1390 } 1391 }
1391 1392
1392 1393
1393 DEFINE_NATIVE_ENTRY(MethodMirror_name, 1) {
1394 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1395 const Function& func = Function::Handle(ref.GetFunctionReferent());
1396 return func.UserVisibleName();
1397 }
1398
1399
1400 DEFINE_NATIVE_ENTRY(MethodMirror_owner, 1) { 1394 DEFINE_NATIVE_ENTRY(MethodMirror_owner, 1) {
1401 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1395 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1402 const Function& func = Function::Handle(ref.GetFunctionReferent()); 1396 const Function& func = Function::Handle(ref.GetFunctionReferent());
1403 if (func.IsNonImplicitClosureFunction()) { 1397 if (func.IsNonImplicitClosureFunction()) {
1404 return CreateMethodMirror(Function::Handle( 1398 return CreateMethodMirror(Function::Handle(
1405 func.parent_function()), Object::null_instance()); 1399 func.parent_function()), Object::null_instance());
1406 } 1400 }
1407 const Class& owner = Class::Handle(func.Owner()); 1401 const Class& owner = Class::Handle(func.Owner());
1408 if (owner.IsTopLevel()) { 1402 if (owner.IsTopLevel()) {
1409 return CreateLibraryMirror(Library::Handle(owner.library())); 1403 return CreateLibraryMirror(Library::Handle(owner.library()));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1435
1442 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1436 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1443 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1437 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1444 const Field& field = Field::Handle(ref.GetFieldReferent()); 1438 const Field& field = Field::Handle(ref.GetFieldReferent());
1445 1439
1446 const AbstractType& type = AbstractType::Handle(field.type()); 1440 const AbstractType& type = AbstractType::Handle(field.type());
1447 return CreateTypeMirror(type); 1441 return CreateTypeMirror(type);
1448 } 1442 }
1449 1443
1450 } // namespace dart 1444 } // namespace dart
OLDNEW
« 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