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