Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: runtime/vm/object.cc

Issue 1569213003: Eliminate phase parameter in constructors (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5854 matching lines...) Expand 10 before | Expand all | Expand 10 after
5865 } 5865 }
5866 5866
5867 5867
5868 intptr_t Function::NumParameters() const { 5868 intptr_t Function::NumParameters() const {
5869 return num_fixed_parameters() + NumOptionalParameters(); 5869 return num_fixed_parameters() + NumOptionalParameters();
5870 } 5870 }
5871 5871
5872 5872
5873 intptr_t Function::NumImplicitParameters() const { 5873 intptr_t Function::NumImplicitParameters() const {
5874 if (kind() == RawFunction::kConstructor) { 5874 if (kind() == RawFunction::kConstructor) {
5875 if (is_static()) { 5875 // Type arguments for factory; instance for generative constructor.
5876 ASSERT(IsFactory()); 5876 return 1;
5877 return 1; // Type arguments.
5878 } else {
5879 ASSERT(IsGenerativeConstructor());
5880 return 2; // Instance, phase.
5881 }
5882 } 5877 }
5883 if ((kind() == RawFunction::kClosureFunction) || 5878 if ((kind() == RawFunction::kClosureFunction) ||
5884 (kind() == RawFunction::kSignatureFunction)) { 5879 (kind() == RawFunction::kSignatureFunction)) {
5885 return 1; // Closure object. 5880 return 1; // Closure object.
5886 } 5881 }
5887 if (!is_static()) { 5882 if (!is_static()) {
5888 // Closure functions defined inside instance (i.e. non-static) functions are 5883 // Closure functions defined inside instance (i.e. non-static) functions are
5889 // marked as non-static, but they do not have a receiver. 5884 // marked as non-static, but they do not have a receiver.
5890 // Closures are handled above. 5885 // Closures are handled above.
5891 ASSERT((kind() != RawFunction::kClosureFunction) && 5886 ASSERT((kind() != RawFunction::kClosureFunction) &&
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
6250 Heap::Space space) const { 6245 Heap::Space space) const {
6251 const intptr_t num_fixed_params = num_fixed_parameters(); 6246 const intptr_t num_fixed_params = num_fixed_parameters();
6252 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); 6247 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
6253 const intptr_t num_opt_named_params = NumOptionalNamedParameters(); 6248 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
6254 const intptr_t other_num_fixed_params = other.num_fixed_parameters(); 6249 const intptr_t other_num_fixed_params = other.num_fixed_parameters();
6255 const intptr_t other_num_opt_pos_params = 6250 const intptr_t other_num_opt_pos_params =
6256 other.NumOptionalPositionalParameters(); 6251 other.NumOptionalPositionalParameters();
6257 const intptr_t other_num_opt_named_params = 6252 const intptr_t other_num_opt_named_params =
6258 other.NumOptionalNamedParameters(); 6253 other.NumOptionalNamedParameters();
6259 // This function requires the same arguments or less and accepts the same 6254 // This function requires the same arguments or less and accepts the same
6260 // arguments or more. 6255 // arguments or more. We can ignore implicit parameters.
6261 // A generative constructor may be compared to a redirecting factory and be
6262 // compatible although it has an additional phase parameter.
6263 // More generally, we can ignore implicit parameters.
6264 const intptr_t num_ignored_params = NumImplicitParameters(); 6256 const intptr_t num_ignored_params = NumImplicitParameters();
6265 const intptr_t other_num_ignored_params = other.NumImplicitParameters(); 6257 const intptr_t other_num_ignored_params = other.NumImplicitParameters();
6266 if (((num_fixed_params - num_ignored_params) > 6258 if (((num_fixed_params - num_ignored_params) >
6267 (other_num_fixed_params - other_num_ignored_params)) || 6259 (other_num_fixed_params - other_num_ignored_params)) ||
6268 ((num_fixed_params - num_ignored_params + num_opt_pos_params) < 6260 ((num_fixed_params - num_ignored_params + num_opt_pos_params) <
6269 (other_num_fixed_params - other_num_ignored_params + 6261 (other_num_fixed_params - other_num_ignored_params +
6270 other_num_opt_pos_params)) || 6262 other_num_opt_pos_params)) ||
6271 (num_opt_named_params < other_num_opt_named_params)) { 6263 (num_opt_named_params < other_num_opt_named_params)) {
6272 return false; 6264 return false;
6273 } 6265 }
(...skipping 15767 matching lines...) Expand 10 before | Expand all | Expand 10 after
22041 return tag_label.ToCString(); 22033 return tag_label.ToCString();
22042 } 22034 }
22043 22035
22044 22036
22045 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 22037 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
22046 Instance::PrintJSONImpl(stream, ref); 22038 Instance::PrintJSONImpl(stream, ref);
22047 } 22039 }
22048 22040
22049 22041
22050 } // namespace dart 22042 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698