| 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()); |
| 767 Error& bound_error = Error::Handle(); | 773 Error& bound_error = Error::Handle(); |
| 768 AbstractType& result = AbstractType::Handle( | 774 AbstractType& result = AbstractType::Handle(type.InstantiateFrom( |
| 769 type.InstantiateFrom(type_args, &bound_error, NULL, NULL, Heap::kOld)); | 775 instantiator_type_args, Object::null_type_arguments(), &bound_error, NULL, |
| 776 NULL, Heap::kOld)); |
| 770 if (!bound_error.IsNull()) { | 777 if (!bound_error.IsNull()) { |
| 771 Exceptions::PropagateError(bound_error); | 778 Exceptions::PropagateError(bound_error); |
| 772 UNREACHABLE(); | 779 UNREACHABLE(); |
| 773 } | 780 } |
| 774 ASSERT(result.IsFinalized()); | 781 ASSERT(result.IsFinalized()); |
| 775 return result.Canonicalize(); | 782 return result.Canonicalize(); |
| 776 } | 783 } |
| 777 | 784 |
| 778 | 785 |
| 779 DEFINE_NATIVE_ENTRY(MirrorSystem_libraries, 0) { | 786 DEFINE_NATIVE_ENTRY(MirrorSystem_libraries, 0) { |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 | 1703 |
| 1697 Class& redirected_klass = Class::Handle(klass.raw()); | 1704 Class& redirected_klass = Class::Handle(klass.raw()); |
| 1698 Function& redirected_constructor = Function::Handle(lookup_constructor.raw()); | 1705 Function& redirected_constructor = Function::Handle(lookup_constructor.raw()); |
| 1699 if (lookup_constructor.IsRedirectingFactory()) { | 1706 if (lookup_constructor.IsRedirectingFactory()) { |
| 1700 ClassFinalizer::ResolveRedirectingFactory(klass, lookup_constructor); | 1707 ClassFinalizer::ResolveRedirectingFactory(klass, lookup_constructor); |
| 1701 Type& redirect_type = Type::Handle(lookup_constructor.RedirectionType()); | 1708 Type& redirect_type = Type::Handle(lookup_constructor.RedirectionType()); |
| 1702 | 1709 |
| 1703 if (!redirect_type.IsInstantiated()) { | 1710 if (!redirect_type.IsInstantiated()) { |
| 1704 // The type arguments of the redirection type are instantiated from the | 1711 // The type arguments of the redirection type are instantiated from the |
| 1705 // type arguments of the type reflected by the class mirror. | 1712 // type arguments of the type reflected by the class mirror. |
| 1713 ASSERT(redirect_type.IsInstantiated(kFunctions)); |
| 1706 Error& bound_error = Error::Handle(); | 1714 Error& bound_error = Error::Handle(); |
| 1707 redirect_type ^= redirect_type.InstantiateFrom( | 1715 redirect_type ^= redirect_type.InstantiateFrom( |
| 1708 type_arguments, &bound_error, NULL, NULL, Heap::kOld); | 1716 type_arguments, Object::null_type_arguments(), &bound_error, NULL, |
| 1717 NULL, Heap::kOld); |
| 1709 if (!bound_error.IsNull()) { | 1718 if (!bound_error.IsNull()) { |
| 1710 Exceptions::PropagateError(bound_error); | 1719 Exceptions::PropagateError(bound_error); |
| 1711 UNREACHABLE(); | 1720 UNREACHABLE(); |
| 1712 } | 1721 } |
| 1713 redirect_type ^= redirect_type.Canonicalize(); | 1722 redirect_type ^= redirect_type.Canonicalize(); |
| 1714 } | 1723 } |
| 1715 | 1724 |
| 1716 type = redirect_type.raw(); | 1725 type = redirect_type.raw(); |
| 1717 type_arguments = redirect_type.arguments(); | 1726 type_arguments = redirect_type.arguments(); |
| 1718 | 1727 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 | 2097 |
| 2089 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { | 2098 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { |
| 2090 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); | 2099 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); |
| 2091 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); | 2100 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); |
| 2092 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); | 2101 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); |
| 2093 } | 2102 } |
| 2094 | 2103 |
| 2095 #endif // !PRODUCT && !DART_PRECOMPILED_RUNTIME | 2104 #endif // !PRODUCT && !DART_PRECOMPILED_RUNTIME |
| 2096 | 2105 |
| 2097 } // namespace dart | 2106 } // namespace dart |
| OLD | NEW |