| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 bool has_extra_parameter_info = true; | 134 bool has_extra_parameter_info = true; |
| 135 if (non_implicit_param_count == 0) { | 135 if (non_implicit_param_count == 0) { |
| 136 has_extra_parameter_info = false; | 136 has_extra_parameter_info = false; |
| 137 } | 137 } |
| 138 if (func.IsImplicitConstructor()) { | 138 if (func.IsImplicitConstructor()) { |
| 139 // This covers the default constructor and forwarding constructors. | 139 // This covers the default constructor and forwarding constructors. |
| 140 has_extra_parameter_info = false; | 140 has_extra_parameter_info = false; |
| 141 } | 141 } |
| 142 if (func.IsSignatureFunction() && | 142 if (func.IsSignatureFunction() && |
| 143 (func.token_pos() == Token::kNoSourcePos)) { | 143 (func.token_pos() == TokenDescriptor::kNoSource)) { |
| 144 // Signature functions (except those describing typedefs) get canonicalized, | 144 // Signature functions (except those describing typedefs) get canonicalized, |
| 145 // hence do not have a token position, and therefore cannot be reparsed. | 145 // hence do not have a token position, and therefore cannot be reparsed. |
| 146 has_extra_parameter_info = false; | 146 has_extra_parameter_info = false; |
| 147 } | 147 } |
| 148 | 148 |
| 149 Array& param_descriptor = Array::Handle(); | 149 Array& param_descriptor = Array::Handle(); |
| 150 if (has_extra_parameter_info) { | 150 if (has_extra_parameter_info) { |
| 151 // Reparse the function for the following information: | 151 // Reparse the function for the following information: |
| 152 // * The default value of a parameter. | 152 // * The default value of a parameter. |
| 153 // * Whether a parameters has been declared as final. | 153 // * Whether a parameters has been declared as final. |
| (...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 // the equality test. | 1441 // the equality test. |
| 1442 function = function.parent_function(); | 1442 function = function.parent_function(); |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 Type& instantiator = Type::Handle(); | 1445 Type& instantiator = Type::Handle(); |
| 1446 if (closure.IsClosure()) { | 1446 if (closure.IsClosure()) { |
| 1447 const TypeArguments& arguments = | 1447 const TypeArguments& arguments = |
| 1448 TypeArguments::Handle(closure.GetTypeArguments()); | 1448 TypeArguments::Handle(closure.GetTypeArguments()); |
| 1449 const Class& cls = | 1449 const Class& cls = |
| 1450 Class::Handle(Isolate::Current()->object_store()->object_class()); | 1450 Class::Handle(Isolate::Current()->object_store()->object_class()); |
| 1451 instantiator = Type::New(cls, arguments, Token::kNoSourcePos); | 1451 instantiator = Type::New(cls, arguments, TokenDescriptor::kNoSource); |
| 1452 instantiator.SetIsFinalized(); | 1452 instantiator.SetIsFinalized(); |
| 1453 } | 1453 } |
| 1454 return CreateMethodMirror(function, | 1454 return CreateMethodMirror(function, |
| 1455 Instance::null_instance(), | 1455 Instance::null_instance(), |
| 1456 instantiator); | 1456 instantiator); |
| 1457 } | 1457 } |
| 1458 return Instance::null(); | 1458 return Instance::null(); |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 | 1461 |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1962 if (reflectee.IsMirrorReference()) { | 1962 if (reflectee.IsMirrorReference()) { |
| 1963 const MirrorReference& decl_ref = MirrorReference::Cast(reflectee); | 1963 const MirrorReference& decl_ref = MirrorReference::Cast(reflectee); |
| 1964 decl = decl_ref.referent(); | 1964 decl = decl_ref.referent(); |
| 1965 } else if (reflectee.IsTypeParameter()) { | 1965 } else if (reflectee.IsTypeParameter()) { |
| 1966 decl = reflectee.raw(); | 1966 decl = reflectee.raw(); |
| 1967 } else { | 1967 } else { |
| 1968 UNREACHABLE(); | 1968 UNREACHABLE(); |
| 1969 } | 1969 } |
| 1970 | 1970 |
| 1971 Script& script = Script::Handle(); | 1971 Script& script = Script::Handle(); |
| 1972 intptr_t token_pos = Token::kNoSourcePos; | 1972 TokenDescriptor token_pos = TokenDescriptor::kNoSource; |
| 1973 | 1973 |
| 1974 if (decl.IsFunction()) { | 1974 if (decl.IsFunction()) { |
| 1975 const Function& func = Function::Cast(decl); | 1975 const Function& func = Function::Cast(decl); |
| 1976 if (func.IsImplicitConstructor() || func.IsSignatureFunction()) { | 1976 if (func.IsImplicitConstructor() || func.IsSignatureFunction()) { |
| 1977 // These are synthetic methods; they have no source. | 1977 // These are synthetic methods; they have no source. |
| 1978 return Instance::null(); | 1978 return Instance::null(); |
| 1979 } | 1979 } |
| 1980 script = func.script(); | 1980 script = func.script(); |
| 1981 token_pos = func.token_pos(); | 1981 token_pos = func.token_pos(); |
| 1982 } else if (decl.IsClass()) { | 1982 } else if (decl.IsClass()) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2012 ASSERT(!script.IsNull()); | 2012 ASSERT(!script.IsNull()); |
| 2013 const String& libname = String::Handle(lib.name()); | 2013 const String& libname = String::Handle(lib.name()); |
| 2014 if (libname.Length() == 0) { | 2014 if (libname.Length() == 0) { |
| 2015 // No library declaration. | 2015 // No library declaration. |
| 2016 const String& uri = String::Handle(script.url()); | 2016 const String& uri = String::Handle(script.url()); |
| 2017 return CreateSourceLocation(uri, 1, 1); | 2017 return CreateSourceLocation(uri, 1, 1); |
| 2018 } | 2018 } |
| 2019 const TokenStream& stream = TokenStream::Handle(script.tokens()); | 2019 const TokenStream& stream = TokenStream::Handle(script.tokens()); |
| 2020 TokenStream::Iterator tkit(stream, 0); | 2020 TokenStream::Iterator tkit(stream, 0); |
| 2021 if (tkit.CurrentTokenKind() == Token::kSCRIPTTAG) tkit.Advance(); | 2021 if (tkit.CurrentTokenKind() == Token::kSCRIPTTAG) tkit.Advance(); |
| 2022 token_pos = tkit.CurrentPosition(); | 2022 token_pos = TokenDescriptor(tkit.CurrentPosition()); |
| 2023 } | 2023 } |
| 2024 | 2024 |
| 2025 ASSERT(!script.IsNull()); | 2025 ASSERT(!script.IsNull()); |
| 2026 ASSERT(token_pos != Token::kNoSourcePos); | 2026 ASSERT(token_pos != TokenDescriptor::kNoSource); |
| 2027 | 2027 |
| 2028 const String& uri = String::Handle(script.url()); | 2028 const String& uri = String::Handle(script.url()); |
| 2029 intptr_t from_line = 0; | 2029 intptr_t from_line = 0; |
| 2030 intptr_t from_col = 0; | 2030 intptr_t from_col = 0; |
| 2031 if (script.HasSource()) { | 2031 if (script.HasSource()) { |
| 2032 script.GetTokenLocation(token_pos, &from_line, &from_col); | 2032 script.GetTokenLocation(token_pos, &from_line, &from_col); |
| 2033 } else { | 2033 } else { |
| 2034 // Avoid the slow path of printing the token stream when precise source | 2034 // Avoid the slow path of printing the token stream when precise source |
| 2035 // information is not available. | 2035 // information is not available. |
| 2036 script.GetTokenLocation(token_pos, &from_line, NULL); | 2036 script.GetTokenLocation(token_pos, &from_line, NULL); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 } | 2084 } |
| 2085 | 2085 |
| 2086 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { | 2086 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { |
| 2087 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); | 2087 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); |
| 2088 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); | 2088 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); |
| 2089 return Bool::Get(a.IsSubtypeOf(b, NULL)).raw(); | 2089 return Bool::Get(a.IsSubtypeOf(b, NULL)).raw(); |
| 2090 } | 2090 } |
| 2091 | 2091 |
| 2092 | 2092 |
| 2093 } // namespace dart | 2093 } // namespace dart |
| OLD | NEW |