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 "lib/mirrors.h" | 5 #include "lib/mirrors.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/bootstrap_natives.h" | 8 #include "vm/bootstrap_natives.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 return field.StaticValue(); | 747 return field.StaticValue(); |
| 748 } | 748 } |
| 749 | 749 |
| 750 | 750 |
| 751 static RawAbstractType* InstantiateType(const AbstractType& type, | 751 static RawAbstractType* InstantiateType(const AbstractType& type, |
| 752 const AbstractType& instantiator) { | 752 const AbstractType& instantiator) { |
| 753 ASSERT(type.IsFinalized()); | 753 ASSERT(type.IsFinalized()); |
| 754 PROPAGATE_IF_MALFORMED(type); | 754 PROPAGATE_IF_MALFORMED(type); |
| 755 ASSERT(type.IsCanonical() || type.IsTypeParameter() || type.IsBoundedType()); | 755 ASSERT(type.IsCanonical() || type.IsTypeParameter() || type.IsBoundedType()); |
| 756 | 756 |
| 757 // TODO(regis): Support uninstantiated type referring to function type params. | |
| 758 if (!type.IsInstantiated(kFunctions)) { | |
| 759 UNIMPLEMENTED(); | |
| 760 } | |
| 761 | |
| 757 if (type.IsInstantiated() || instantiator.IsNull()) { | 762 if (type.IsInstantiated() || instantiator.IsNull()) { |
| 763 // TODO(regis): Shouldn't type parameters be replaced by dynamic? | |
| 758 return type.Canonicalize(); | 764 return type.Canonicalize(); |
| 759 } | 765 } |
| 760 | 766 |
| 761 ASSERT(!instantiator.IsNull()); | 767 ASSERT(!instantiator.IsNull()); |
| 762 ASSERT(instantiator.IsFinalized()); | 768 ASSERT(instantiator.IsFinalized()); |
| 763 PROPAGATE_IF_MALFORMED(instantiator); | 769 PROPAGATE_IF_MALFORMED(instantiator); |
| 764 | 770 |
| 765 const TypeArguments& type_args = | 771 const TypeArguments& instantiator_type_args = |
| 766 TypeArguments::Handle(instantiator.arguments()); | 772 TypeArguments::Handle(instantiator.arguments()); |
| 773 const TypeArguments& function_type_args = TypeArguments::Handle(); | |
| 767 Error& bound_error = Error::Handle(); | 774 Error& bound_error = Error::Handle(); |
| 768 AbstractType& result = AbstractType::Handle( | 775 AbstractType& result = AbstractType::Handle( |
| 769 type.InstantiateFrom(type_args, &bound_error, NULL, NULL, Heap::kOld)); | 776 type.InstantiateFrom(instantiator_type_args, function_type_args, |
|
siva
2017/04/10 22:04:55
why not use Object::null_type_arguments() instead
regis
2017/04/11 04:23:07
Done.
| |
| 777 &bound_error, NULL, NULL, Heap::kOld)); | |
| 770 if (!bound_error.IsNull()) { | 778 if (!bound_error.IsNull()) { |
| 771 Exceptions::PropagateError(bound_error); | 779 Exceptions::PropagateError(bound_error); |
| 772 UNREACHABLE(); | 780 UNREACHABLE(); |
| 773 } | 781 } |
| 774 ASSERT(result.IsFinalized()); | 782 ASSERT(result.IsFinalized()); |
| 775 return result.Canonicalize(); | 783 return result.Canonicalize(); |
| 776 } | 784 } |
| 777 | 785 |
| 778 | 786 |
| 779 DEFINE_NATIVE_ENTRY(MirrorSystem_libraries, 0) { | 787 DEFINE_NATIVE_ENTRY(MirrorSystem_libraries, 0) { |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1696 | 1704 |
| 1697 Class& redirected_klass = Class::Handle(klass.raw()); | 1705 Class& redirected_klass = Class::Handle(klass.raw()); |
| 1698 Function& redirected_constructor = Function::Handle(lookup_constructor.raw()); | 1706 Function& redirected_constructor = Function::Handle(lookup_constructor.raw()); |
| 1699 if (lookup_constructor.IsRedirectingFactory()) { | 1707 if (lookup_constructor.IsRedirectingFactory()) { |
| 1700 ClassFinalizer::ResolveRedirectingFactory(klass, lookup_constructor); | 1708 ClassFinalizer::ResolveRedirectingFactory(klass, lookup_constructor); |
| 1701 Type& redirect_type = Type::Handle(lookup_constructor.RedirectionType()); | 1709 Type& redirect_type = Type::Handle(lookup_constructor.RedirectionType()); |
| 1702 | 1710 |
| 1703 if (!redirect_type.IsInstantiated()) { | 1711 if (!redirect_type.IsInstantiated()) { |
| 1704 // The type arguments of the redirection type are instantiated from the | 1712 // The type arguments of the redirection type are instantiated from the |
| 1705 // type arguments of the type reflected by the class mirror. | 1713 // type arguments of the type reflected by the class mirror. |
| 1714 ASSERT(redirect_type.IsInstantiated(kFunctions)); | |
| 1706 Error& bound_error = Error::Handle(); | 1715 Error& bound_error = Error::Handle(); |
| 1707 redirect_type ^= redirect_type.InstantiateFrom( | 1716 redirect_type ^= redirect_type.InstantiateFrom( |
| 1708 type_arguments, &bound_error, NULL, NULL, Heap::kOld); | 1717 type_arguments, Object::null_type_arguments(), &bound_error, NULL, |
| 1718 NULL, Heap::kOld); | |
| 1709 if (!bound_error.IsNull()) { | 1719 if (!bound_error.IsNull()) { |
| 1710 Exceptions::PropagateError(bound_error); | 1720 Exceptions::PropagateError(bound_error); |
| 1711 UNREACHABLE(); | 1721 UNREACHABLE(); |
| 1712 } | 1722 } |
| 1713 redirect_type ^= redirect_type.Canonicalize(); | 1723 redirect_type ^= redirect_type.Canonicalize(); |
| 1714 } | 1724 } |
| 1715 | 1725 |
| 1716 type = redirect_type.raw(); | 1726 type = redirect_type.raw(); |
| 1717 type_arguments = redirect_type.arguments(); | 1727 type_arguments = redirect_type.arguments(); |
| 1718 | 1728 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2088 | 2098 |
| 2089 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { | 2099 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { |
| 2090 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); | 2100 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); |
| 2091 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); | 2101 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); |
| 2092 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); | 2102 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); |
| 2093 } | 2103 } |
| 2094 | 2104 |
| 2095 #endif // !PRODUCT && !DART_PRECOMPILED_RUNTIME | 2105 #endif // !PRODUCT && !DART_PRECOMPILED_RUNTIME |
| 2096 | 2106 |
| 2097 } // namespace dart | 2107 } // namespace dart |
| OLD | NEW |