| 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" |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 type_var_map, | 553 type_var_map, |
| 554 }; | 554 }; |
| 555 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); | 555 Dart_Handle mirror = Dart_New(type, Dart_Null(), ARRAY_SIZE(args), args); |
| 556 return mirror; | 556 return mirror; |
| 557 } | 557 } |
| 558 | 558 |
| 559 | 559 |
| 560 static Dart_Handle CreateMethodMirror(Dart_Handle func, | 560 static Dart_Handle CreateMethodMirror(Dart_Handle func, |
| 561 Dart_Handle owner_mirror) { | 561 Dart_Handle owner_mirror) { |
| 562 ASSERT(Dart_IsFunction(func)); | 562 ASSERT(Dart_IsFunction(func)); |
| 563 // Unwrapping is needed until the whole method is converted. |
| 564 Isolate* isolate = Isolate::Current(); |
| 565 DARTSCOPE(isolate); |
| 566 const Function& f = Function::Handle( |
| 567 Api::UnwrapFunctionHandle(isolate, func).raw()); |
| 568 |
| 563 Dart_Handle mirror_cls_name = NewString("_LocalMethodMirrorImpl"); | 569 Dart_Handle mirror_cls_name = NewString("_LocalMethodMirrorImpl"); |
| 564 Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL); | 570 Dart_Handle mirror_type = Dart_GetType(MirrorLib(), mirror_cls_name, 0, NULL); |
| 565 if (Dart_IsError(mirror_type)) { | 571 if (Dart_IsError(mirror_type)) { |
| 566 return mirror_type; | 572 return mirror_type; |
| 567 } | 573 } |
| 568 | 574 |
| 569 bool is_static = false; | |
| 570 bool is_abstract = false; | |
| 571 bool is_getter = false; | |
| 572 bool is_setter = false; | |
| 573 bool is_constructor = false; | |
| 574 | |
| 575 Dart_Handle result = Dart_FunctionIsStatic(func, &is_static); | |
| 576 if (Dart_IsError(result)) { | |
| 577 return result; | |
| 578 } | |
| 579 result = Dart_FunctionIsAbstract(func, &is_abstract); | |
| 580 if (Dart_IsError(result)) { | |
| 581 return result; | |
| 582 } | |
| 583 result = Dart_FunctionIsGetter(func, &is_getter); | |
| 584 if (Dart_IsError(result)) { | |
| 585 return result; | |
| 586 } | |
| 587 result = Dart_FunctionIsSetter(func, &is_setter); | |
| 588 if (Dart_IsError(result)) { | |
| 589 return result; | |
| 590 } | |
| 591 result = Dart_FunctionIsConstructor(func, &is_constructor); | |
| 592 if (Dart_IsError(result)) { | |
| 593 return result; | |
| 594 } | |
| 595 | |
| 596 Dart_Handle return_type = Dart_FunctionReturnType(func); | 575 Dart_Handle return_type = Dart_FunctionReturnType(func); |
| 597 if (Dart_IsError(return_type)) { | 576 if (Dart_IsError(return_type)) { |
| 598 return return_type; | 577 return return_type; |
| 599 } | 578 } |
| 600 | 579 |
| 601 int64_t fixed_param_count; | |
| 602 int64_t opt_param_count; | |
| 603 result = Dart_FunctionParameterCounts(func, | |
| 604 &fixed_param_count, | |
| 605 &opt_param_count); | |
| 606 if (Dart_IsError(result)) { | |
| 607 return result; | |
| 608 } | |
| 609 | |
| 610 // TODO(turnidge): Implement constructor kinds (arguments 7 - 10). | 580 // TODO(turnidge): Implement constructor kinds (arguments 7 - 10). |
| 611 Dart_Handle args[] = { | 581 Dart_Handle args[] = { |
| 612 CreateMirrorReference(func), | 582 CreateMirrorReference(func), |
| 613 owner_mirror, | 583 owner_mirror, |
| 614 CreateParameterMirrorList(func), | 584 CreateParameterMirrorList(func), |
| 615 CreateLazyMirror(return_type), | 585 CreateLazyMirror(return_type), |
| 616 Dart_NewBoolean(is_static), | 586 f.is_static() ? Api::True() : Api::False(), |
| 617 Dart_NewBoolean(is_abstract), | 587 f.is_abstract() ? Api::True() : Api::False(), |
| 618 Dart_NewBoolean(is_getter), | 588 f.IsGetterFunction() ? Api::True() : Api::False(), |
| 619 Dart_NewBoolean(is_setter), | 589 f.IsSetterFunction() ? Api::True() : Api::False(), |
| 620 Dart_NewBoolean(is_constructor), | 590 f.IsConstructor() ? Api::True() : Api::False(), |
| 621 Dart_False(), | 591 Api::False(), |
| 622 Dart_False(), | 592 Api::False(), |
| 623 Dart_False(), | 593 Api::False(), |
| 624 Dart_False(), | 594 Api::False() |
| 625 }; | 595 }; |
| 626 Dart_Handle mirror = | 596 Dart_Handle mirror = |
| 627 Dart_New(mirror_type, Dart_Null(), ARRAY_SIZE(args), args); | 597 Dart_New(mirror_type, Dart_Null(), ARRAY_SIZE(args), args); |
| 628 return mirror; | 598 return mirror; |
| 629 } | 599 } |
| 630 | 600 |
| 631 | 601 |
| 632 static Dart_Handle CreateVariableMirror(Dart_Handle var, | 602 static Dart_Handle CreateVariableMirror(Dart_Handle var, |
| 633 Dart_Handle var_name, | 603 Dart_Handle var_name, |
| 634 Dart_Handle lib_mirror) { | 604 Dart_Handle lib_mirror) { |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1817 | 1787 |
| 1818 DEFINE_NATIVE_ENTRY(MethodMirror_name, 1) { | 1788 DEFINE_NATIVE_ENTRY(MethodMirror_name, 1) { |
| 1819 const MirrorReference& func_ref = | 1789 const MirrorReference& func_ref = |
| 1820 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); | 1790 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); |
| 1821 Function& func = Function::Handle(); | 1791 Function& func = Function::Handle(); |
| 1822 func ^= func_ref.referent(); | 1792 func ^= func_ref.referent(); |
| 1823 return func.UserVisibleName(); | 1793 return func.UserVisibleName(); |
| 1824 } | 1794 } |
| 1825 | 1795 |
| 1826 } // namespace dart | 1796 } // namespace dart |
| OLD | NEW |