| 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 5597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5608 if (IsClosureFunction()) { | 5608 if (IsClosureFunction()) { |
| 5609 ClosureData::Cast(obj).set_parent_function(value); | 5609 ClosureData::Cast(obj).set_parent_function(value); |
| 5610 } else { | 5610 } else { |
| 5611 ASSERT(IsSignatureFunction()); | 5611 ASSERT(IsSignatureFunction()); |
| 5612 SignatureData::Cast(obj).set_parent_function(value); | 5612 SignatureData::Cast(obj).set_parent_function(value); |
| 5613 } | 5613 } |
| 5614 } | 5614 } |
| 5615 | 5615 |
| 5616 | 5616 |
| 5617 bool Function::HasGenericParent() const { | 5617 bool Function::HasGenericParent() const { |
| 5618 if (IsImplicitClosureFunction()) { |
| 5619 // The parent function of an implicit closure function is not the enclosing |
| 5620 // function we are asking about here. |
| 5621 return false; |
| 5622 } |
| 5618 Function& parent = Function::Handle(parent_function()); | 5623 Function& parent = Function::Handle(parent_function()); |
| 5619 while (!parent.IsNull()) { | 5624 while (!parent.IsNull()) { |
| 5620 if (parent.IsGeneric()) { | 5625 if (parent.IsGeneric()) { |
| 5621 return true; | 5626 return true; |
| 5622 } | 5627 } |
| 5623 parent = parent.parent_function(); | 5628 parent = parent.parent_function(); |
| 5624 } | 5629 } |
| 5625 return false; | 5630 return false; |
| 5626 } | 5631 } |
| 5627 | 5632 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6006 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread); | 6011 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread); |
| 6007 TypeArguments& type_params = thread->TypeArgumentsHandle(); | 6012 TypeArguments& type_params = thread->TypeArgumentsHandle(); |
| 6008 type_params = type_parameters(); | 6013 type_params = type_parameters(); |
| 6009 // We require null to represent a non-generic function. | 6014 // We require null to represent a non-generic function. |
| 6010 ASSERT(type_params.Length() != 0); | 6015 ASSERT(type_params.Length() != 0); |
| 6011 return type_params.Length(); | 6016 return type_params.Length(); |
| 6012 } | 6017 } |
| 6013 | 6018 |
| 6014 | 6019 |
| 6015 intptr_t Function::NumParentTypeParameters() const { | 6020 intptr_t Function::NumParentTypeParameters() const { |
| 6021 if (IsImplicitClosureFunction()) { |
| 6022 return 0; |
| 6023 } |
| 6016 Thread* thread = Thread::Current(); | 6024 Thread* thread = Thread::Current(); |
| 6017 Function& parent = Function::Handle(parent_function()); | 6025 Function& parent = Function::Handle(parent_function()); |
| 6018 intptr_t num_parent_type_params = 0; | 6026 intptr_t num_parent_type_params = 0; |
| 6019 while (!parent.IsNull()) { | 6027 while (!parent.IsNull()) { |
| 6020 num_parent_type_params += parent.NumTypeParameters(thread); | 6028 num_parent_type_params += parent.NumTypeParameters(thread); |
| 6021 parent ^= parent.parent_function(); | 6029 parent ^= parent.parent_function(); |
| 6022 } | 6030 } |
| 6023 return num_parent_type_params; | 6031 return num_parent_type_params; |
| 6024 } | 6032 } |
| 6025 | 6033 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6044 if (!type_params.IsNull()) { | 6052 if (!type_params.IsNull()) { |
| 6045 const intptr_t num_type_params = type_params.Length(); | 6053 const intptr_t num_type_params = type_params.Length(); |
| 6046 for (intptr_t i = 0; i < num_type_params; i++) { | 6054 for (intptr_t i = 0; i < num_type_params; i++) { |
| 6047 type_param ^= type_params.TypeAt(i); | 6055 type_param ^= type_params.TypeAt(i); |
| 6048 type_param_name = type_param.name(); | 6056 type_param_name = type_param.name(); |
| 6049 if (type_param_name.Equals(type_name)) { | 6057 if (type_param_name.Equals(type_name)) { |
| 6050 return type_param.raw(); | 6058 return type_param.raw(); |
| 6051 } | 6059 } |
| 6052 } | 6060 } |
| 6053 } | 6061 } |
| 6062 if (function.IsImplicitClosureFunction()) { |
| 6063 // The parent function is not the enclosing function, but the closurized |
| 6064 // function with identical type parameters. |
| 6065 break; |
| 6066 } |
| 6054 function ^= function.parent_function(); | 6067 function ^= function.parent_function(); |
| 6055 if (function_level != NULL) { | 6068 if (function_level != NULL) { |
| 6056 (*function_level)--; | 6069 (*function_level)--; |
| 6057 } | 6070 } |
| 6058 } | 6071 } |
| 6059 return TypeParameter::null(); | 6072 return TypeParameter::null(); |
| 6060 } | 6073 } |
| 6061 | 6074 |
| 6062 | 6075 |
| 6063 void Function::set_kind(RawFunction::Kind value) const { | 6076 void Function::set_kind(RawFunction::Kind value) const { |
| (...skipping 17232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23296 return UserTag::null(); | 23309 return UserTag::null(); |
| 23297 } | 23310 } |
| 23298 | 23311 |
| 23299 | 23312 |
| 23300 const char* UserTag::ToCString() const { | 23313 const char* UserTag::ToCString() const { |
| 23301 const String& tag_label = String::Handle(label()); | 23314 const String& tag_label = String::Handle(label()); |
| 23302 return tag_label.ToCString(); | 23315 return tag_label.ToCString(); |
| 23303 } | 23316 } |
| 23304 | 23317 |
| 23305 } // namespace dart | 23318 } // namespace dart |
| OLD | NEW |