Chromium Code Reviews| 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 "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/become.h" | 10 #include "vm/become.h" |
| (...skipping 5598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5609 if (IsClosureFunction()) { | 5609 if (IsClosureFunction()) { |
| 5610 ClosureData::Cast(obj).set_parent_function(value); | 5610 ClosureData::Cast(obj).set_parent_function(value); |
| 5611 } else { | 5611 } else { |
| 5612 ASSERT(IsSignatureFunction()); | 5612 ASSERT(IsSignatureFunction()); |
| 5613 SignatureData::Cast(obj).set_parent_function(value); | 5613 SignatureData::Cast(obj).set_parent_function(value); |
| 5614 } | 5614 } |
| 5615 } | 5615 } |
| 5616 | 5616 |
| 5617 | 5617 |
| 5618 bool Function::HasGenericParent() const { | 5618 bool Function::HasGenericParent() const { |
| 5619 if (IsImplicitClosureFunction()) { | |
| 5620 // The parent function of an implicit closure function is not the enclosing | |
| 5621 // function we are asking about here. | |
| 5622 return false; | |
| 5623 } | |
| 5619 Function& parent = Function::Handle(parent_function()); | 5624 Function& parent = Function::Handle(parent_function()); |
| 5620 while (!parent.IsNull()) { | 5625 while (!parent.IsNull()) { |
| 5621 if (parent.IsGeneric()) { | 5626 if (parent.IsGeneric()) { |
| 5622 return true; | 5627 return true; |
| 5623 } | 5628 } |
| 5624 parent = parent.parent_function(); | 5629 parent = parent.parent_function(); |
| 5625 } | 5630 } |
| 5626 return false; | 5631 return false; |
| 5627 } | 5632 } |
| 5628 | 5633 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6007 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread); | 6012 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread); |
| 6008 TypeArguments& type_params = thread->TypeArgumentsHandle(); | 6013 TypeArguments& type_params = thread->TypeArgumentsHandle(); |
| 6009 type_params = type_parameters(); | 6014 type_params = type_parameters(); |
| 6010 // We require null to represent a non-generic function. | 6015 // We require null to represent a non-generic function. |
| 6011 ASSERT(type_params.Length() != 0); | 6016 ASSERT(type_params.Length() != 0); |
| 6012 return type_params.Length(); | 6017 return type_params.Length(); |
| 6013 } | 6018 } |
| 6014 | 6019 |
| 6015 | 6020 |
| 6016 intptr_t Function::NumParentTypeParameters() const { | 6021 intptr_t Function::NumParentTypeParameters() const { |
| 6022 if (IsImplicitClosureFunction()) { | |
| 6023 return 0; | |
| 6024 } | |
| 6017 Thread* thread = Thread::Current(); | 6025 Thread* thread = Thread::Current(); |
| 6018 Function& parent = Function::Handle(parent_function()); | 6026 Function& parent = Function::Handle(parent_function()); |
| 6019 intptr_t num_parent_type_params = 0; | 6027 intptr_t num_parent_type_params = 0; |
| 6020 while (!parent.IsNull()) { | 6028 while (!parent.IsNull()) { |
| 6021 num_parent_type_params += parent.NumTypeParameters(thread); | 6029 num_parent_type_params += parent.NumTypeParameters(thread); |
| 6022 parent ^= parent.parent_function(); | 6030 parent ^= parent.parent_function(); |
| 6023 } | 6031 } |
| 6024 return num_parent_type_params; | 6032 return num_parent_type_params; |
| 6025 } | 6033 } |
| 6026 | 6034 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 6045 if (!type_params.IsNull()) { | 6053 if (!type_params.IsNull()) { |
| 6046 const intptr_t num_type_params = type_params.Length(); | 6054 const intptr_t num_type_params = type_params.Length(); |
| 6047 for (intptr_t i = 0; i < num_type_params; i++) { | 6055 for (intptr_t i = 0; i < num_type_params; i++) { |
| 6048 type_param ^= type_params.TypeAt(i); | 6056 type_param ^= type_params.TypeAt(i); |
| 6049 type_param_name = type_param.name(); | 6057 type_param_name = type_param.name(); |
| 6050 if (type_param_name.Equals(type_name)) { | 6058 if (type_param_name.Equals(type_name)) { |
| 6051 return type_param.raw(); | 6059 return type_param.raw(); |
| 6052 } | 6060 } |
| 6053 } | 6061 } |
| 6054 } | 6062 } |
| 6063 if (function.IsImplicitClosureFunction()) { | |
| 6064 // The parent function is not the enclosing function, but the closurized | |
| 6065 // function with identical type parameters. | |
| 6066 break; | |
| 6067 } | |
| 6055 function ^= function.parent_function(); | 6068 function ^= function.parent_function(); |
| 6056 if (function_level != NULL) { | 6069 if (function_level != NULL) { |
| 6057 (*function_level)--; | 6070 (*function_level)--; |
| 6058 } | 6071 } |
| 6059 } | 6072 } |
| 6060 return TypeParameter::null(); | 6073 return TypeParameter::null(); |
| 6061 } | 6074 } |
| 6062 | 6075 |
| 6063 | 6076 |
| 6064 void Function::set_kind(RawFunction::Kind value) const { | 6077 void Function::set_kind(RawFunction::Kind value) const { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6336 // constructed name is a valid C++ identifier for debugging purpose. | 6349 // constructed name is a valid C++ identifier for debugging purpose. |
| 6337 // Set 'chars' to allocated buffer and return number of written characters. | 6350 // Set 'chars' to allocated buffer and return number of written characters. |
| 6338 | 6351 |
| 6339 enum QualifiedFunctionLibKind { | 6352 enum QualifiedFunctionLibKind { |
| 6340 kQualifiedFunctionLibKindLibUrl, | 6353 kQualifiedFunctionLibKindLibUrl, |
| 6341 kQualifiedFunctionLibKindLibName | 6354 kQualifiedFunctionLibKindLibName |
| 6342 }; | 6355 }; |
| 6343 | 6356 |
| 6344 | 6357 |
| 6345 static intptr_t ConstructFunctionFullyQualifiedCString( | 6358 static intptr_t ConstructFunctionFullyQualifiedCString( |
| 6346 const Function& function, | 6359 const Function& fun, |
| 6347 char** chars, | 6360 char** chars, |
| 6348 intptr_t reserve_len, | 6361 intptr_t reserve_len, |
| 6349 bool with_lib, | 6362 bool with_lib, |
| 6350 QualifiedFunctionLibKind lib_kind) { | 6363 QualifiedFunctionLibKind lib_kind) { |
| 6364 // Hide implicit closure functions. | |
| 6365 const Function& function = Function::Handle( | |
|
rmacnak
2017/04/25 19:21:42
I think this output is only used for debug printin
regis
2017/04/25 19:57:26
OK, I removed the change.
| |
| 6366 fun.IsImplicitClosureFunction() ? fun.parent_function() : fun.raw()); | |
| 6351 const char* name = String::Handle(function.name()).ToCString(); | 6367 const char* name = String::Handle(function.name()).ToCString(); |
| 6352 const char* function_format = (reserve_len == 0) ? "%s" : "%s_"; | 6368 const char* function_format = (reserve_len == 0) ? "%s" : "%s_"; |
| 6353 reserve_len += OS::SNPrint(NULL, 0, function_format, name); | 6369 reserve_len += OS::SNPrint(NULL, 0, function_format, name); |
| 6354 const Function& parent = Function::Handle(function.parent_function()); | 6370 const Function& parent = Function::Handle(function.parent_function()); |
| 6355 intptr_t written = 0; | 6371 intptr_t written = 0; |
| 6356 if (parent.IsNull()) { | 6372 if (parent.IsNull()) { |
| 6357 const Class& function_class = Class::Handle(function.Owner()); | 6373 const Class& function_class = Class::Handle(function.Owner()); |
| 6358 ASSERT(!function_class.IsNull()); | 6374 ASSERT(!function_class.IsNull()); |
| 6359 const char* class_name = String::Handle(function_class.Name()).ToCString(); | 6375 const char* class_name = String::Handle(function_class.Name()).ToCString(); |
| 6360 ASSERT(class_name != NULL); | 6376 ASSERT(class_name != NULL); |
| (...skipping 16949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 23310 return UserTag::null(); | 23326 return UserTag::null(); |
| 23311 } | 23327 } |
| 23312 | 23328 |
| 23313 | 23329 |
| 23314 const char* UserTag::ToCString() const { | 23330 const char* UserTag::ToCString() const { |
| 23315 const String& tag_label = String::Handle(label()); | 23331 const String& tag_label = String::Handle(label()); |
| 23316 return tag_label.ToCString(); | 23332 return tag_label.ToCString(); |
| 23317 } | 23333 } |
| 23318 | 23334 |
| 23319 } // namespace dart | 23335 } // namespace dart |
| OLD | NEW |