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/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 4082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4093 const char* Function::ToFullyQualifiedCString() const { | 4093 const char* Function::ToFullyQualifiedCString() const { |
4094 char* chars = NULL; | 4094 char* chars = NULL; |
4095 ConstructFunctionFullyQualifiedCString(*this, &chars, 0); | 4095 ConstructFunctionFullyQualifiedCString(*this, &chars, 0); |
4096 return chars; | 4096 return chars; |
4097 } | 4097 } |
4098 | 4098 |
4099 | 4099 |
4100 bool Function::HasCompatibleParametersWith(const Function& other) const { | 4100 bool Function::HasCompatibleParametersWith(const Function& other) const { |
4101 const intptr_t num_fixed_params = num_fixed_parameters(); | 4101 const intptr_t num_fixed_params = num_fixed_parameters(); |
4102 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); | 4102 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); |
4103 const intptr_t num_opt_named_params = NumOptionalNamedParameters(); | |
4104 const intptr_t other_num_fixed_params = other.num_fixed_parameters(); | 4103 const intptr_t other_num_fixed_params = other.num_fixed_parameters(); |
4105 const intptr_t other_num_opt_pos_params = | 4104 const intptr_t other_num_opt_pos_params = |
4106 other.NumOptionalPositionalParameters(); | 4105 other.NumOptionalPositionalParameters(); |
4107 const intptr_t other_num_opt_named_params = | |
4108 other.NumOptionalNamedParameters(); | |
4109 // A generative constructor may be compared to a redirecting factory and be | 4106 // A generative constructor may be compared to a redirecting factory and be |
4110 // compatible although it has an additional phase parameter. | 4107 // compatible although it has an additional phase parameter. |
4111 const intptr_t num_ignored_params = | 4108 const intptr_t num_ignored_params = |
4112 (other.IsRedirectingFactory() && IsConstructor()) ? 1 : 0; | 4109 (other.IsRedirectingFactory() && IsConstructor()) ? 1 : 0; |
4113 // The default values of optional parameters can differ. | 4110 // The default values of optional parameters can differ. |
4114 // This function requires the same arguments or less and accepts the same | 4111 // This function requires the same arguments or less and accepts the same |
4115 // arguments or more. | 4112 // arguments or more. |
4116 if (((num_fixed_params - num_ignored_params) > other_num_fixed_params) || | 4113 if (((num_fixed_params - num_ignored_params) > other_num_fixed_params) || |
4117 ((num_fixed_params - num_ignored_params) + num_opt_pos_params < | 4114 ((num_fixed_params - num_ignored_params) + num_opt_pos_params < |
4118 other_num_fixed_params + other_num_opt_pos_params) || | 4115 other_num_fixed_params + other_num_opt_pos_params)) { |
4119 (num_opt_named_params < other_num_opt_named_params)) { | |
4120 return false; | 4116 return false; |
4121 } | 4117 } |
4122 if (other_num_opt_named_params == 0) { | |
4123 return true; | |
4124 } | |
4125 // Check that for each optional named parameter of the other function there | |
4126 // exists an optional named parameter of this function with an identical | |
4127 // name. | |
4128 // Note that SetParameterNameAt() guarantees that names are symbols, so we | |
4129 // can compare their raw pointers. | |
4130 const int num_params = num_fixed_params + num_opt_named_params; | |
4131 const int other_num_params = | |
4132 other_num_fixed_params + other_num_opt_named_params; | |
4133 bool found_param_name; | |
4134 String& other_param_name = String::Handle(); | |
4135 for (intptr_t i = other_num_fixed_params; i < other_num_params; i++) { | |
4136 other_param_name = other.ParameterNameAt(i); | |
4137 found_param_name = false; | |
4138 for (intptr_t j = num_fixed_params; j < num_params; j++) { | |
4139 if (ParameterNameAt(j) == other_param_name.raw()) { | |
4140 found_param_name = true; | |
4141 break; | |
4142 } | |
4143 } | |
4144 if (!found_param_name) { | |
4145 return false; | |
4146 } | |
4147 } | |
4148 return true; | 4118 return true; |
4149 } | 4119 } |
4150 | 4120 |
4151 | 4121 |
4152 // If test_kind == kIsSubtypeOf, checks if the type of the specified parameter | 4122 // If test_kind == kIsSubtypeOf, checks if the type of the specified parameter |
4153 // of this function is a subtype or a supertype of the type of the specified | 4123 // of this function is a subtype or a supertype of the type of the specified |
4154 // parameter of the other function. | 4124 // parameter of the other function. |
4155 // If test_kind == kIsMoreSpecificThan, checks if the type of the specified | 4125 // If test_kind == kIsMoreSpecificThan, checks if the type of the specified |
4156 // parameter of this function is more specific than the type of the specified | 4126 // parameter of this function is more specific than the type of the specified |
4157 // parameter of the other function. | 4127 // parameter of the other function. |
(...skipping 9555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13713 return reinterpret_cast<RawMirrorReference*>(raw); | 13683 return reinterpret_cast<RawMirrorReference*>(raw); |
13714 } | 13684 } |
13715 | 13685 |
13716 | 13686 |
13717 const char* MirrorReference::ToCString() const { | 13687 const char* MirrorReference::ToCString() const { |
13718 return "_MirrorReference"; | 13688 return "_MirrorReference"; |
13719 } | 13689 } |
13720 | 13690 |
13721 | 13691 |
13722 } // namespace dart | 13692 } // namespace dart |
OLD | NEW |