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