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/invocation_mirror.h" | 5 #include "lib/invocation_mirror.h" |
6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1894 | 1894 |
1895 | 1895 |
1896 DEFINE_NATIVE_ENTRY(MethodMirror_parameters, 2) { | 1896 DEFINE_NATIVE_ENTRY(MethodMirror_parameters, 2) { |
1897 GET_NON_NULL_NATIVE_ARGUMENT(Instance, owner, arguments->NativeArgAt(0)); | 1897 GET_NON_NULL_NATIVE_ARGUMENT(Instance, owner, arguments->NativeArgAt(0)); |
1898 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); | 1898 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); |
1899 const Function& func = Function::Handle(ref.GetFunctionReferent()); | 1899 const Function& func = Function::Handle(ref.GetFunctionReferent()); |
1900 return CreateParameterMirrorList(func, owner); | 1900 return CreateParameterMirrorList(func, owner); |
1901 } | 1901 } |
1902 | 1902 |
1903 | 1903 |
1904 DEFINE_NATIVE_ENTRY(MethodMirror_return_type, 1) { | 1904 DEFINE_NATIVE_ENTRY(MethodMirror_return_type, 2) { |
1905 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1905 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
1906 const Function& func = Function::Handle(ref.GetFunctionReferent()); | 1906 const Function& func = Function::Handle(ref.GetFunctionReferent()); |
1907 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); | |
1907 // We handle constructors in Dart code. | 1908 // We handle constructors in Dart code. |
1908 ASSERT(!func.IsConstructor()); | 1909 ASSERT(!func.IsConstructor()); |
1909 return func.result_type(); | 1910 const AbstractType& type = AbstractType::Handle(func.result_type()); |
1911 if (instantiator.IsNull()) { | |
rmacnak
2013/11/06 18:40:33
Null in the case the method is top-level, librarie
regis
2013/11/06 19:06:07
You could have a null instantiator, because the in
rmacnak
2013/11/07 19:56:00
The instantiator here isn't a type vector, it's th
| |
1912 return type.raw(); | |
1913 } else { | |
1914 return InstantiateType(type, instantiator); | |
1915 } | |
1910 } | 1916 } |
1911 | 1917 |
1912 | 1918 |
1913 DEFINE_NATIVE_ENTRY(MethodMirror_source, 1) { | 1919 DEFINE_NATIVE_ENTRY(MethodMirror_source, 1) { |
1914 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1920 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
1915 const Function& func = Function::Handle(ref.GetFunctionReferent()); | 1921 const Function& func = Function::Handle(ref.GetFunctionReferent()); |
1916 const Script& script = Script::Handle(func.script()); | 1922 const Script& script = Script::Handle(func.script()); |
1917 const TokenStream& stream = TokenStream::Handle(script.tokens()); | 1923 const TokenStream& stream = TokenStream::Handle(script.tokens()); |
1918 const TokenStream::Iterator tkit(stream, func.end_token_pos()); | 1924 const TokenStream::Iterator tkit(stream, func.end_token_pos()); |
1919 intptr_t from_line; | 1925 intptr_t from_line; |
(...skipping 25 matching lines...) Expand all Loading... | |
1945 const Function& sig_func = Function::Handle(cls.signature_function()); | 1951 const Function& sig_func = Function::Handle(cls.signature_function()); |
1946 const Class& sig_cls = Class::Handle(sig_func.signature_class()); | 1952 const Class& sig_cls = Class::Handle(sig_func.signature_class()); |
1947 | 1953 |
1948 AbstractType& referent_type = AbstractType::Handle(sig_cls.DeclarationType()); | 1954 AbstractType& referent_type = AbstractType::Handle(sig_cls.DeclarationType()); |
1949 referent_type = InstantiateType(referent_type, type); | 1955 referent_type = InstantiateType(referent_type, type); |
1950 | 1956 |
1951 return CreateFunctionTypeMirror(sig_cls, referent_type); | 1957 return CreateFunctionTypeMirror(sig_cls, referent_type); |
1952 } | 1958 } |
1953 | 1959 |
1954 | 1960 |
1955 DEFINE_NATIVE_ENTRY(ParameterMirror_type, 2) { | 1961 DEFINE_NATIVE_ENTRY(ParameterMirror_type, 3) { |
1956 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1962 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
1957 GET_NON_NULL_NATIVE_ARGUMENT(Smi, pos, arguments->NativeArgAt(1)); | 1963 GET_NON_NULL_NATIVE_ARGUMENT(Smi, pos, arguments->NativeArgAt(1)); |
1964 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(2)); | |
1958 const Function& func = Function::Handle(ref.GetFunctionReferent()); | 1965 const Function& func = Function::Handle(ref.GetFunctionReferent()); |
1959 return func.ParameterTypeAt(func.NumImplicitParameters() + pos.Value()); | 1966 const AbstractType& type = AbstractType::Handle( |
1967 func.ParameterTypeAt(func.NumImplicitParameters() + pos.Value())); | |
1968 if (instantiator.IsNull()) { | |
regis
2013/11/06 19:06:07
ditto
| |
1969 return type.raw(); | |
1970 } else { | |
1971 return InstantiateType(type, instantiator); | |
1972 } | |
1960 } | 1973 } |
1961 | 1974 |
1962 | 1975 |
1963 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { | 1976 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) { |
1964 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1977 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
1965 const Field& field = Field::Handle(ref.GetFieldReferent()); | 1978 const Field& field = Field::Handle(ref.GetFieldReferent()); |
1966 return field.type(); | 1979 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); |
1980 const AbstractType& type = AbstractType::Handle(field.type()); | |
1981 if (instantiator.IsNull()) { | |
regis
2013/11/06 19:06:07
ditto
| |
1982 return type.raw(); | |
1983 } else { | |
1984 return InstantiateType(type, instantiator); | |
1985 } | |
1967 } | 1986 } |
1968 | 1987 |
1969 } // namespace dart | 1988 } // namespace dart |
OLD | NEW |