Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" |
| 13 #include "vm/message.h" | 13 #include "vm/message.h" |
| 14 #include "vm/port.h" | 14 #include "vm/port.h" |
| 15 #include "vm/resolver.h" | 15 #include "vm/resolver.h" |
| 16 #include "vm/symbols.h" | 16 #include "vm/symbols.h" |
| 17 | 17 |
| 18 namespace dart { | 18 namespace dart { |
| 19 | 19 |
| 20 static RawInstance* CreateMirror(const String& mirror_class_name, | |
| 21 const Array& constructor_arguments) { | |
| 22 const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); | |
| 23 const String& constructor_name = Symbols::Dot(); | |
| 24 | |
| 25 const Object& result = Object::Handle( | |
| 26 DartLibraryCalls::ExceptionCreate(mirrors_lib, | |
|
Michael Lippautz (Google)
2013/07/19 19:03:02
ExceptionCreate should at some point (this CL?) be
siva
2013/07/19 21:01:40
Good point, I do not know why we called it Excepti
Michael Lippautz (Google)
2013/07/19 22:13:20
Done.
| |
| 27 mirror_class_name, | |
| 28 constructor_name, | |
| 29 constructor_arguments)); | |
| 30 ASSERT(!result.IsError()); | |
| 31 ASSERT(result.IsInstance()); | |
|
rmacnak
2013/07/19 20:37:22
Doesn't IsInstance() guarantee !IsError()?
Michael Lippautz (Google)
2013/07/19 20:53:01
Leftover from debugging. Done.
| |
| 32 return Instance::Cast(result).raw(); | |
| 33 } | |
| 34 | |
| 35 | |
| 20 inline Dart_Handle NewString(const char* str) { | 36 inline Dart_Handle NewString(const char* str) { |
| 21 return Dart_NewStringFromCString(str); | 37 return Dart_NewStringFromCString(str); |
| 22 } | 38 } |
| 23 | 39 |
| 24 | 40 |
| 25 DEFINE_NATIVE_ENTRY(Mirrors_isLocalPort, 1) { | 41 DEFINE_NATIVE_ENTRY(Mirrors_isLocalPort, 1) { |
| 26 GET_NON_NULL_NATIVE_ARGUMENT(Instance, port, arguments->NativeArgAt(0)); | 42 GET_NON_NULL_NATIVE_ARGUMENT(Instance, port, arguments->NativeArgAt(0)); |
| 27 | 43 |
| 28 // Get the port id from the SendPort instance. | 44 // Get the port id from the SendPort instance. |
| 29 const Object& id_obj = Object::Handle(DartLibraryCalls::PortGetId(port)); | 45 const Object& id_obj = Object::Handle(DartLibraryCalls::PortGetId(port)); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 } | 364 } |
| 349 Dart_Handle result = Dart_ListSetAt(mirror_list, i, mirror); | 365 Dart_Handle result = Dart_ListSetAt(mirror_list, i, mirror); |
| 350 if (Dart_IsError(result)) { | 366 if (Dart_IsError(result)) { |
| 351 return result; | 367 return result; |
| 352 } | 368 } |
| 353 } | 369 } |
| 354 return mirror_list; | 370 return mirror_list; |
| 355 } | 371 } |
| 356 | 372 |
| 357 | 373 |
| 358 static Dart_Handle CreateTypeVariableMirror(Dart_Handle type_var, | 374 static Dart_Handle CreateTypeVariableMirrorUsingApi(Dart_Handle type_var, |
| 359 Dart_Handle type_var_name, | 375 Dart_Handle type_var_name, |
| 360 Dart_Handle owner_mirror) { | 376 Dart_Handle owner_mirror) { |
| 361 ASSERT(Dart_IsTypeVariable(type_var)); | 377 ASSERT(Dart_IsTypeVariable(type_var)); |
| 362 Dart_Handle cls_name = NewString("_LocalTypeVariableMirrorImpl"); | 378 Dart_Handle cls_name = NewString("_LocalTypeVariableMirrorImpl"); |
| 363 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); | 379 Dart_Handle type = Dart_GetType(MirrorLib(), cls_name, 0, NULL); |
| 364 if (Dart_IsError(type)) { | 380 if (Dart_IsError(type)) { |
| 365 return type; | 381 return type; |
| 366 } | 382 } |
| 367 | 383 |
| 368 Dart_Handle upper_bound = Dart_TypeVariableUpperBound(type_var); | 384 Dart_Handle upper_bound = Dart_TypeVariableUpperBound(type_var); |
| 369 if (Dart_IsError(upper_bound)) { | 385 if (Dart_IsError(upper_bound)) { |
| 370 return upper_bound; | 386 return upper_bound; |
| 371 } | 387 } |
| 372 | 388 |
| 373 Dart_Handle args[] = { | 389 Dart_Handle args[] = { |
| 374 CreateMirrorReference(type_var), | 390 CreateMirrorReference(type_var), |
| 375 type_var_name, | 391 type_var_name, |
| 376 owner_mirror, | 392 owner_mirror, |
| 377 CreateLazyMirror(upper_bound), | 393 CreateLazyMirror(upper_bound), |
| 378 }; | 394 }; |
| 379 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); | 395 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 380 return mirror; | 396 return mirror; |
| 381 } | 397 } |
| 382 | 398 |
| 383 | 399 |
| 400 static RawInstance* CreateTypeVariableMirror(const TypeParameter& param, | |
| 401 const Instance& owner_mirror) { | |
| 402 Instance& retvalue = Instance::Handle(); | |
| 403 Dart_EnterScope(); | |
| 404 Isolate* isolate = Isolate::Current(); | |
| 405 Dart_Handle param_handle = Api::NewHandle(isolate, param.raw()); | |
| 406 if (Dart_IsError(param_handle)) { | |
| 407 Dart_PropagateError(param_handle); | |
| 408 } | |
| 409 Dart_Handle name_handle = Api::NewHandle(isolate, param.Name()); | |
| 410 if (Dart_IsError(name_handle)) { | |
| 411 Dart_PropagateError(name_handle); | |
| 412 } | |
| 413 // Until we get rid of lazy mirrors, we must have owners. | |
| 414 Dart_Handle owner_handle; | |
| 415 if (owner_mirror.IsNull()) { | |
| 416 owner_handle = Api::NewHandle(isolate, param.parameterized_class()); | |
| 417 if (Dart_IsError(owner_handle)) { | |
| 418 Dart_PropagateError(owner_handle); | |
| 419 } | |
| 420 owner_handle = CreateLazyMirror(owner_handle); | |
| 421 if (Dart_IsError(owner_handle)) { | |
| 422 Dart_PropagateError(owner_handle); | |
| 423 } | |
| 424 } else { | |
| 425 owner_handle = Api::NewHandle(isolate, owner_mirror.raw()); | |
| 426 if (Dart_IsError(owner_handle)) { | |
| 427 Dart_PropagateError(owner_handle); | |
| 428 } | |
| 429 } | |
| 430 // TODO(11742): At some point the handle calls will be replaced by inlined | |
| 431 // functionality. | |
| 432 Dart_Handle result = CreateTypeVariableMirrorUsingApi(param_handle, | |
| 433 name_handle, | |
| 434 owner_handle); | |
| 435 if (Dart_IsError(result)) { | |
| 436 Dart_PropagateError(result); | |
| 437 } | |
| 438 retvalue ^= Api::UnwrapHandle(result); | |
| 439 Dart_ExitScope(); | |
| 440 return retvalue.raw(); | |
| 441 } | |
| 442 | |
| 443 | |
| 384 static Dart_Handle CreateTypeVariableMap(Dart_Handle owner, | 444 static Dart_Handle CreateTypeVariableMap(Dart_Handle owner, |
| 385 Dart_Handle owner_mirror) { | 445 Dart_Handle owner_mirror) { |
| 386 ASSERT(Dart_IsClass(owner)); | 446 ASSERT(Dart_IsClass(owner)); |
| 387 // TODO(turnidge): This should be an immutable map. | 447 // TODO(turnidge): This should be an immutable map. |
| 388 Dart_Handle map = MapNew(); | 448 Dart_Handle map = MapNew(); |
| 389 if (Dart_IsError(map)) { | 449 if (Dart_IsError(map)) { |
| 390 return map; | 450 return map; |
| 391 } | 451 } |
| 392 | 452 |
| 393 Dart_Handle names = Dart_GetTypeVariableNames(owner); | 453 Dart_Handle names = Dart_GetTypeVariableNames(owner); |
| 394 if (Dart_IsError(names)) { | 454 if (Dart_IsError(names)) { |
| 395 return names; | 455 return names; |
| 396 } | 456 } |
| 397 intptr_t len; | 457 intptr_t len; |
| 398 Dart_Handle result = Dart_ListLength(names, &len); | 458 Dart_Handle result = Dart_ListLength(names, &len); |
| 399 if (Dart_IsError(result)) { | 459 if (Dart_IsError(result)) { |
| 400 return result; | 460 return result; |
| 401 } | 461 } |
| 402 for (intptr_t i = 0; i < len; i++) { | 462 for (intptr_t i = 0; i < len; i++) { |
| 403 Dart_Handle type_var_name = Dart_ListGetAt(names, i); | 463 Dart_Handle type_var_name = Dart_ListGetAt(names, i); |
| 404 Dart_Handle type_var = Dart_LookupTypeVariable(owner, type_var_name); | 464 Dart_Handle type_var = Dart_LookupTypeVariable(owner, type_var_name); |
| 405 if (Dart_IsError(type_var)) { | 465 if (Dart_IsError(type_var)) { |
| 406 return type_var; | 466 return type_var; |
| 407 } | 467 } |
| 408 ASSERT(!Dart_IsNull(type_var)); | 468 ASSERT(!Dart_IsNull(type_var)); |
| 409 Dart_Handle type_var_mirror = | 469 Dart_Handle type_var_mirror = |
| 410 CreateTypeVariableMirror(type_var, type_var_name, owner_mirror); | 470 CreateTypeVariableMirrorUsingApi(type_var, type_var_name, owner_mirror); |
| 411 if (Dart_IsError(type_var_mirror)) { | 471 if (Dart_IsError(type_var_mirror)) { |
| 412 return type_var_mirror; | 472 return type_var_mirror; |
| 413 } | 473 } |
| 414 result = MapAdd(map, type_var_name, type_var_mirror); | 474 result = MapAdd(map, type_var_name, type_var_mirror); |
| 415 if (Dart_IsError(result)) { | 475 if (Dart_IsError(result)) { |
| 416 return result; | 476 return result; |
| 417 } | 477 } |
| 418 } | 478 } |
| 419 return map; | 479 return map; |
| 420 } | 480 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 }; | 566 }; |
| 507 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); | 567 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 508 return mirror; | 568 return mirror; |
| 509 } | 569 } |
| 510 | 570 |
| 511 | 571 |
| 512 static Dart_Handle CreateMethodMirrorUsingApi(Dart_Handle func, | 572 static Dart_Handle CreateMethodMirrorUsingApi(Dart_Handle func, |
| 513 Dart_Handle owner_mirror) { | 573 Dart_Handle owner_mirror) { |
| 514 // TODO(11742): Unwrapping is needed until the whole method is converted. | 574 // TODO(11742): Unwrapping is needed until the whole method is converted. |
| 515 Isolate* isolate = Isolate::Current(); | 575 Isolate* isolate = Isolate::Current(); |
| 516 DARTSCOPE(isolate); | |
| 517 const Function& func_obj = Api::UnwrapFunctionHandle(isolate, func); | 576 const Function& func_obj = Api::UnwrapFunctionHandle(isolate, func); |
| 518 | 577 |
| 519 Dart_Handle mirror_cls_name = NewString("_LocalMethodMirrorImpl"); | 578 Dart_Handle mirror_cls_name = NewString("_LocalMethodMirrorImpl"); |
| 520 Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL); | 579 Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL); |
| 521 if (Dart_IsError(mirror_type)) { | 580 if (Dart_IsError(mirror_type)) { |
| 522 return mirror_type; | 581 return mirror_type; |
| 523 } | 582 } |
| 524 | 583 |
| 525 Dart_Handle return_type = Dart_FunctionReturnType(func); | |
|
Michael Lippautz (Google)
2013/07/19 19:03:02
We get rid of Dart_FunctionReturnType() in this pl
| |
| 526 if (Dart_IsError(return_type)) { | |
| 527 return return_type; | |
| 528 } | |
| 529 | |
| 530 // TODO(turnidge): Implement constructor kinds (arguments 7 - 10). | 584 // TODO(turnidge): Implement constructor kinds (arguments 7 - 10). |
| 531 Dart_Handle args[] = { | 585 Dart_Handle args[] = { |
| 532 CreateMirrorReference(func), | 586 CreateMirrorReference(func), |
| 533 owner_mirror, | 587 owner_mirror, |
| 534 CreateParameterMirrorList(func), | 588 CreateParameterMirrorList(func), |
| 535 CreateLazyMirror(return_type), | |
| 536 func_obj.is_static() ? Api::True() : Api::False(), | 589 func_obj.is_static() ? Api::True() : Api::False(), |
| 537 func_obj.is_abstract() ? Api::True() : Api::False(), | 590 func_obj.is_abstract() ? Api::True() : Api::False(), |
| 538 func_obj.IsGetterFunction() ? Api::True() : Api::False(), | 591 func_obj.IsGetterFunction() ? Api::True() : Api::False(), |
| 539 func_obj.IsSetterFunction() ? Api::True() : Api::False(), | 592 func_obj.IsSetterFunction() ? Api::True() : Api::False(), |
| 540 func_obj.IsConstructor() ? Api::True() : Api::False(), | 593 func_obj.IsConstructor() ? Api::True() : Api::False(), |
| 541 Api::False(), | 594 Api::False(), |
| 542 Api::False(), | 595 Api::False(), |
| 543 Api::False(), | 596 Api::False(), |
| 544 Api::False() | 597 Api::False() |
| 545 }; | 598 }; |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 973 Dart_EnterScope(); | 1026 Dart_EnterScope(); |
| 974 Isolate* isolate = Isolate::Current(); | 1027 Isolate* isolate = Isolate::Current(); |
| 975 Dart_Handle cls_handle = Api::NewHandle(isolate, cls.raw()); | 1028 Dart_Handle cls_handle = Api::NewHandle(isolate, cls.raw()); |
| 976 if (Dart_IsError(cls_handle)) { | 1029 if (Dart_IsError(cls_handle)) { |
| 977 Dart_PropagateError(cls_handle); | 1030 Dart_PropagateError(cls_handle); |
| 978 } | 1031 } |
| 979 Dart_Handle name_handle = Api::NewHandle(isolate, cls.Name()); | 1032 Dart_Handle name_handle = Api::NewHandle(isolate, cls.Name()); |
| 980 if (Dart_IsError(name_handle)) { | 1033 if (Dart_IsError(name_handle)) { |
| 981 Dart_PropagateError(name_handle); | 1034 Dart_PropagateError(name_handle); |
| 982 } | 1035 } |
| 983 Dart_Handle lib_mirror = Api::NewHandle(isolate, owner_mirror.raw()); | 1036 // Until we get rid of lazy mirrors, we must have owners. |
|
rmacnak
2013/07/19 20:37:22
Unnecessary after https://chromiumcodereview.appsp
Michael Lippautz (Google)
2013/07/19 20:53:01
As I think of it now, it was not even necessary in
| |
| 1037 Dart_Handle lib_mirror; | |
| 1038 if (owner_mirror.IsNull()) { | |
| 1039 Dart_Handle owner_handle = Api::NewHandle(isolate, cls.library()); | |
| 1040 if (Dart_IsError(owner_handle)) { | |
| 1041 Dart_PropagateError(owner_handle); | |
| 1042 } | |
| 1043 lib_mirror = CreateLazyMirror(owner_handle); | |
| 1044 } else { | |
| 1045 lib_mirror = Api::NewHandle(isolate, owner_mirror.raw()); | |
| 1046 } | |
| 1047 if (Dart_IsError(lib_mirror)) { | |
| 1048 Dart_PropagateError(lib_mirror); | |
| 1049 } | |
| 984 // TODO(11742): At some point the handle calls will be replaced by inlined | 1050 // TODO(11742): At some point the handle calls will be replaced by inlined |
| 985 // functionality. | 1051 // functionality. |
| 986 Dart_Handle result = CreateClassMirrorUsingApi(cls_handle, | 1052 Dart_Handle result = CreateClassMirrorUsingApi(cls_handle, |
| 987 name_handle, | 1053 name_handle, |
| 988 lib_mirror); | 1054 lib_mirror); |
| 989 if (Dart_IsError(result)) { | 1055 if (Dart_IsError(result)) { |
| 990 Dart_PropagateError(result); | 1056 Dart_PropagateError(result); |
| 991 } | 1057 } |
| 992 retvalue ^= Api::UnwrapHandle(result); | 1058 retvalue ^= Api::UnwrapHandle(result); |
| 993 Dart_ExitScope(); | 1059 Dart_ExitScope(); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1024 Dart_Handle result = CreateMethodMirrorUsingApi(func_handle, owner_handle); | 1090 Dart_Handle result = CreateMethodMirrorUsingApi(func_handle, owner_handle); |
| 1025 if (Dart_IsError(result)) { | 1091 if (Dart_IsError(result)) { |
| 1026 Dart_PropagateError(result); | 1092 Dart_PropagateError(result); |
| 1027 } | 1093 } |
| 1028 retvalue ^= Api::UnwrapHandle(result); | 1094 retvalue ^= Api::UnwrapHandle(result); |
| 1029 Dart_ExitScope(); | 1095 Dart_ExitScope(); |
| 1030 return retvalue.raw(); | 1096 return retvalue.raw(); |
| 1031 } | 1097 } |
| 1032 | 1098 |
| 1033 | 1099 |
| 1100 static RawInstance* CreateTypeMirror(const AbstractType& type) { | |
| 1101 ASSERT(!type.IsMalformed()); | |
| 1102 Isolate* isolate = Isolate::Current(); | |
| 1103 if (type.HasResolvedTypeClass()) { | |
| 1104 const Class& cls = Class::Handle(type.type_class()); | |
| 1105 // Handle void and dynamic types. | |
| 1106 if (cls.IsVoidClass()) { | |
| 1107 const String& class_name = String::Handle( | |
| 1108 String::New("_SpecialTypeMirrorImpl")); | |
|
siva
2013/07/19 21:01:40
Please add _SpecialTypeMirrorImpl to the symbols l
Michael Lippautz (Google)
2013/07/19 22:13:20
Done.
| |
| 1109 const String& name = String::Handle(String::New("void")); | |
|
siva
2013/07/19 21:01:40
this should be Symbols::Void()
Michael Lippautz (Google)
2013/07/19 22:13:20
Done.
| |
| 1110 Array& args = Array::Handle(Array::New(1)); | |
| 1111 args.SetAt(0, name); | |
| 1112 return CreateMirror(class_name, args); | |
| 1113 } else if (cls.IsDynamicClass()) { | |
| 1114 const String& class_name = String::Handle( | |
| 1115 String::New("_SpecialTypeMirrorImpl")); | |
|
siva
2013/07/19 21:01:40
Symbols::_SpecialTypeMirrorImpl() here.
Michael Lippautz (Google)
2013/07/19 22:13:20
Done.
| |
| 1116 const String& name = String::Handle(String::New("dynamic")); | |
|
siva
2013/07/19 21:01:40
Symbols::Dynamic() here.
Michael Lippautz (Google)
2013/07/19 22:13:20
Done.
| |
| 1117 Array& args = Array::Handle(Array::New(1)); | |
| 1118 args.SetAt(0, name); | |
| 1119 return CreateMirror(class_name, args); | |
| 1120 } | |
| 1121 return CreateClassMirror(cls, Instance::Handle()); | |
| 1122 } else if (type.IsTypeParameter()) { | |
| 1123 TypeParameter& param = TypeParameter::Handle( | |
| 1124 isolate, TypeParameter::Cast(type).raw()); | |
|
siva
2013/07/19 21:01:40
why cast an reassign back to another newly created
Michael Lippautz (Google)
2013/07/19 22:13:20
Done.
| |
| 1125 return CreateTypeVariableMirror(param, Instance::Handle()); | |
| 1126 } | |
| 1127 UNREACHABLE(); | |
| 1128 return Instance::null(); | |
| 1129 } | |
| 1130 | |
| 1131 | |
| 1034 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)( | 1132 void NATIVE_ENTRY_FUNCTION(Mirrors_makeLocalMirrorSystem)( |
| 1035 Dart_NativeArguments args) { | 1133 Dart_NativeArguments args) { |
| 1036 Dart_EnterScope(); | 1134 Dart_EnterScope(); |
| 1037 Dart_Handle mirrors = CreateMirrorSystem(); | 1135 Dart_Handle mirrors = CreateMirrorSystem(); |
| 1038 if (Dart_IsError(mirrors)) { | 1136 if (Dart_IsError(mirrors)) { |
| 1039 Dart_PropagateError(mirrors); | 1137 Dart_PropagateError(mirrors); |
| 1040 } | 1138 } |
| 1041 Dart_SetReturnValue(args, mirrors); | 1139 Dart_SetReturnValue(args, mirrors); |
| 1042 Dart_ExitScope(); | 1140 Dart_ExitScope(); |
| 1043 } | 1141 } |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1799 ThrowMirroredCompilationError(message); | 1897 ThrowMirroredCompilationError(message); |
| 1800 UNREACHABLE(); | 1898 UNREACHABLE(); |
| 1801 } | 1899 } |
| 1802 | 1900 |
| 1803 field.set_value(value); | 1901 field.set_value(value); |
| 1804 return value.raw(); | 1902 return value.raw(); |
| 1805 } | 1903 } |
| 1806 | 1904 |
| 1807 | 1905 |
| 1808 DEFINE_NATIVE_ENTRY(MethodMirror_name, 1) { | 1906 DEFINE_NATIVE_ENTRY(MethodMirror_name, 1) { |
| 1809 const MirrorReference& func_ref = | 1907 const Function& func = Function::Handle( |
| 1810 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); | 1908 MirrorReference::GetFunctionReferent(arguments->NativeArgAt(0))); |
|
siva
2013/07/19 21:01:40
I just realized for all native methods we normally
Michael Lippautz (Google)
2013/07/19 22:13:20
Ok, I will do the change for the two existing nati
| |
| 1811 Function& func = Function::Handle(); | |
| 1812 func ^= func_ref.referent(); | |
| 1813 return func.UserVisibleName(); | 1909 return func.UserVisibleName(); |
| 1814 } | 1910 } |
| 1815 | 1911 |
| 1816 | 1912 |
| 1817 DEFINE_NATIVE_ENTRY(MethodMirror_owner, 1) { | 1913 DEFINE_NATIVE_ENTRY(MethodMirror_owner, 1) { |
| 1818 const MirrorReference& func_ref = | 1914 const Function& func = Function::Handle( |
| 1819 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); | 1915 MirrorReference::GetFunctionReferent(arguments->NativeArgAt(0))); |
| 1820 Function& func = Function::Handle(); | |
| 1821 func ^= func_ref.referent(); | |
| 1822 if (func.IsNonImplicitClosureFunction()) { | 1916 if (func.IsNonImplicitClosureFunction()) { |
| 1823 return CreateMethodMirror(Function::Handle( | 1917 return CreateMethodMirror(Function::Handle( |
| 1824 func.parent_function()), Instance::Handle()); | 1918 func.parent_function()), Instance::Handle()); |
| 1825 } | 1919 } |
| 1826 const Class& owner = Class::Handle(func.Owner()); | 1920 const Class& owner = Class::Handle(func.Owner()); |
| 1827 if (owner.IsTopLevel()) { | 1921 if (owner.IsTopLevel()) { |
| 1828 return CreateLibraryMirror(Library::Handle(owner.library())); | 1922 return CreateLibraryMirror(Library::Handle(owner.library())); |
| 1829 } | 1923 } |
| 1830 return CreateClassMirror(owner, Instance::Handle()); | 1924 return CreateClassMirror(owner, Instance::Handle()); |
| 1831 } | 1925 } |
| 1832 | 1926 |
| 1927 | |
| 1928 DEFINE_NATIVE_ENTRY(MethodMirror_return_type, 1) { | |
| 1929 const Function& func = Function::Handle( | |
| 1930 MirrorReference::GetFunctionReferent(arguments->NativeArgAt(0))); | |
| 1931 // We handle constructors in dart code. | |
|
rmacnak
2013/07/19 20:37:22
Dart
Michael Lippautz (Google)
2013/07/19 20:53:01
Done.
| |
| 1932 ASSERT(!func.IsConstructor()); | |
| 1933 const AbstractType& return_type = AbstractType::Handle(func.result_type()); | |
| 1934 return CreateTypeMirror(return_type); | |
| 1935 } | |
| 1936 | |
| 1833 } // namespace dart | 1937 } // namespace dart |
| OLD | NEW |