Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1209)

Side by Side Diff: runtime/lib/mirrors.cc

Issue 2793033005: Keep types in signatures of function types properly instantiated as the function (Closed)
Patch Set: added comment and sync Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 959
960 960
961 DEFINE_NATIVE_ENTRY(FunctionTypeMirror_parameters, 2) { 961 DEFINE_NATIVE_ENTRY(FunctionTypeMirror_parameters, 2) {
962 GET_NON_NULL_NATIVE_ARGUMENT(Instance, owner, arguments->NativeArgAt(0)); 962 GET_NON_NULL_NATIVE_ARGUMENT(Instance, owner, arguments->NativeArgAt(0));
963 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); 963 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1));
964 const Function& func = Function::Handle(ref.GetFunctionReferent()); 964 const Function& func = Function::Handle(ref.GetFunctionReferent());
965 return CreateParameterMirrorList(func, owner); 965 return CreateParameterMirrorList(func, owner);
966 } 966 }
967 967
968 968
969 DEFINE_NATIVE_ENTRY(FunctionTypeMirror_return_type, 2) { 969 DEFINE_NATIVE_ENTRY(FunctionTypeMirror_return_type, 1) {
970 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 970 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
971 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, instantiator,
972 arguments->NativeArgAt(1));
973 const Function& func = Function::Handle(ref.GetFunctionReferent()); 971 const Function& func = Function::Handle(ref.GetFunctionReferent());
974 ASSERT(!func.IsNull()); 972 ASSERT(!func.IsNull());
975 AbstractType& type = AbstractType::Handle(func.result_type()); 973 AbstractType& type = AbstractType::Handle(func.result_type());
976 return InstantiateType(type, instantiator); 974 // Signatures of function types are instantiated, but not canonical.
975 return type.Canonicalize();
977 } 976 }
978 977
979 978
980 DEFINE_NATIVE_ENTRY(ClassMirror_libraryUri, 1) { 979 DEFINE_NATIVE_ENTRY(ClassMirror_libraryUri, 1) {
981 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 980 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
982 const Class& klass = Class::Handle(ref.GetClassReferent()); 981 const Class& klass = Class::Handle(ref.GetClassReferent());
983 const Library& library = Library::Handle(klass.library()); 982 const Library& library = Library::Handle(klass.library());
984 ASSERT(!library.IsNull()); 983 ASSERT(!library.IsNull());
985 return library.url(); 984 return library.url();
986 } 985 }
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 return CreateParameterMirrorList(func, owner); 1939 return CreateParameterMirrorList(func, owner);
1941 } 1940 }
1942 1941
1943 1942
1944 DEFINE_NATIVE_ENTRY(MethodMirror_return_type, 2) { 1943 DEFINE_NATIVE_ENTRY(MethodMirror_return_type, 2) {
1945 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1944 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1946 const Function& func = Function::Handle(ref.GetFunctionReferent()); 1945 const Function& func = Function::Handle(ref.GetFunctionReferent());
1947 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); 1946 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1));
1948 // We handle constructors in Dart code. 1947 // We handle constructors in Dart code.
1949 ASSERT(!func.IsGenerativeConstructor()); 1948 ASSERT(!func.IsGenerativeConstructor());
1950 const AbstractType& type = AbstractType::Handle(func.result_type()); 1949 AbstractType& type = AbstractType::Handle(func.result_type());
1950 type ^= type.Canonicalize(); // Instantiated signatures are not canonical.
1951 return InstantiateType(type, instantiator); 1951 return InstantiateType(type, instantiator);
1952 } 1952 }
1953 1953
1954 1954
1955 DEFINE_NATIVE_ENTRY(MethodMirror_source, 1) { 1955 DEFINE_NATIVE_ENTRY(MethodMirror_source, 1) {
1956 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1956 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1957 const Function& func = Function::Handle(ref.GetFunctionReferent()); 1957 const Function& func = Function::Handle(ref.GetFunctionReferent());
1958 return func.GetSource(); 1958 return func.GetSource();
1959 } 1959 }
1960 1960
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 referent_type ^= InstantiateType(referent_type, type); 2064 referent_type ^= InstantiateType(referent_type, type);
2065 return CreateFunctionTypeMirror(referent_type); 2065 return CreateFunctionTypeMirror(referent_type);
2066 } 2066 }
2067 2067
2068 2068
2069 DEFINE_NATIVE_ENTRY(ParameterMirror_type, 3) { 2069 DEFINE_NATIVE_ENTRY(ParameterMirror_type, 3) {
2070 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 2070 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
2071 GET_NON_NULL_NATIVE_ARGUMENT(Smi, pos, arguments->NativeArgAt(1)); 2071 GET_NON_NULL_NATIVE_ARGUMENT(Smi, pos, arguments->NativeArgAt(1));
2072 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(2)); 2072 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(2));
2073 const Function& func = Function::Handle(ref.GetFunctionReferent()); 2073 const Function& func = Function::Handle(ref.GetFunctionReferent());
2074 const AbstractType& type = AbstractType::Handle( 2074 AbstractType& type = AbstractType::Handle(
2075 func.ParameterTypeAt(func.NumImplicitParameters() + pos.Value())); 2075 func.ParameterTypeAt(func.NumImplicitParameters() + pos.Value()));
2076 type ^= type.Canonicalize(); // Instantiated signatures are not canonical.
2076 return InstantiateType(type, instantiator); 2077 return InstantiateType(type, instantiator);
2077 } 2078 }
2078 2079
2079 2080
2080 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) { 2081 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) {
2081 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 2082 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
2082 const Field& field = Field::Handle(ref.GetFieldReferent()); 2083 const Field& field = Field::Handle(ref.GetFieldReferent());
2083 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); 2084 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1));
2084 const AbstractType& type = AbstractType::Handle(field.type()); 2085 const AbstractType& type = AbstractType::Handle(field.type());
2085 return InstantiateType(type, instantiator); 2086 return InstantiateType(type, instantiator);
2086 } 2087 }
2087 2088
2088 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { 2089 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) {
2089 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); 2090 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0));
2090 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); 2091 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1));
2091 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); 2092 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw();
2092 } 2093 }
2093 2094
2094 #endif // !PRODUCT && !DART_PRECOMPILED_RUNTIME 2095 #endif // !PRODUCT && !DART_PRECOMPILED_RUNTIME
2095 2096
2096 } // namespace dart 2097 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698