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 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 } | 2061 } |
2062 | 2062 |
2063 | 2063 |
2064 DEFINE_NATIVE_ENTRY(TypedefMirror_referent, 1) { | 2064 DEFINE_NATIVE_ENTRY(TypedefMirror_referent, 1) { |
2065 GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0)); | 2065 GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0)); |
2066 ASSERT(type.IsFunctionType()); | 2066 ASSERT(type.IsFunctionType()); |
2067 const Class& cls = Class::Handle(type.type_class()); | 2067 const Class& cls = Class::Handle(type.type_class()); |
2068 ASSERT(cls.IsTypedefClass()); | 2068 ASSERT(cls.IsTypedefClass()); |
2069 const Function& sig_func = Function::Handle(cls.signature_function()); | 2069 const Function& sig_func = Function::Handle(cls.signature_function()); |
2070 Type& referent_type = Type::Handle(sig_func.SignatureType()); | 2070 Type& referent_type = Type::Handle(sig_func.SignatureType()); |
2071 // If the scope class of the function type is not generic, replace it with | |
2072 // Closure class (Function::SignatureType() keeps it). | |
2073 ASSERT(cls.raw() == referent_type.type_class()); | 2071 ASSERT(cls.raw() == referent_type.type_class()); |
2074 if (!cls.IsGeneric()) { | |
2075 referent_type = Type::New( | |
2076 Class::Handle(Isolate::Current()->object_store()->closure_class()), | |
2077 TypeArguments::Handle(referent_type.arguments()), | |
2078 referent_type.token_pos()); | |
2079 referent_type.set_signature(sig_func); | |
2080 referent_type ^= ClassFinalizer::FinalizeType( | |
2081 cls, referent_type, ClassFinalizer::kCanonicalize); | |
2082 } | |
2083 referent_type ^= InstantiateType(referent_type, type); | 2072 referent_type ^= InstantiateType(referent_type, type); |
2084 return CreateFunctionTypeMirror(referent_type); | 2073 return CreateFunctionTypeMirror(referent_type); |
2085 } | 2074 } |
2086 | 2075 |
2087 | 2076 |
2088 DEFINE_NATIVE_ENTRY(ParameterMirror_type, 3) { | 2077 DEFINE_NATIVE_ENTRY(ParameterMirror_type, 3) { |
2089 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 2078 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
2090 GET_NON_NULL_NATIVE_ARGUMENT(Smi, pos, arguments->NativeArgAt(1)); | 2079 GET_NON_NULL_NATIVE_ARGUMENT(Smi, pos, arguments->NativeArgAt(1)); |
2091 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(2)); | 2080 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(2)); |
2092 const Function& func = Function::Handle(ref.GetFunctionReferent()); | 2081 const Function& func = Function::Handle(ref.GetFunctionReferent()); |
(...skipping 13 matching lines...) Expand all Loading... |
2106 | 2095 |
2107 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { | 2096 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { |
2108 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); | 2097 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); |
2109 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); | 2098 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); |
2110 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); | 2099 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); |
2111 } | 2100 } |
2112 | 2101 |
2113 #endif // !PRODUCT | 2102 #endif // !PRODUCT |
2114 | 2103 |
2115 } // namespace dart | 2104 } // namespace dart |
OLD | NEW |