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

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

Issue 12940010: Update function subtyping rules to latest spec (issue 9057). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-compiler.status » ('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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 3883 matching lines...) Expand 10 before | Expand all | Expand 10 after
3894 const intptr_t other_num_fixed_params = other.num_fixed_parameters(); 3894 const intptr_t other_num_fixed_params = other.num_fixed_parameters();
3895 const intptr_t other_num_opt_pos_params = 3895 const intptr_t other_num_opt_pos_params =
3896 other.NumOptionalPositionalParameters(); 3896 other.NumOptionalPositionalParameters();
3897 const intptr_t other_num_opt_named_params = 3897 const intptr_t other_num_opt_named_params =
3898 other.NumOptionalNamedParameters(); 3898 other.NumOptionalNamedParameters();
3899 // A generative constructor may be compared to a redirecting factory and be 3899 // A generative constructor may be compared to a redirecting factory and be
3900 // compatible although it has an additional phase parameter. 3900 // compatible although it has an additional phase parameter.
3901 const intptr_t num_ignored_params = 3901 const intptr_t num_ignored_params =
3902 (other.IsRedirectingFactory() && IsConstructor()) ? 1 : 0; 3902 (other.IsRedirectingFactory() && IsConstructor()) ? 1 : 0;
3903 // The default values of optional parameters can differ. 3903 // The default values of optional parameters can differ.
3904 if (((num_fixed_params - num_ignored_params) != other_num_fixed_params) || 3904 // This function requires the same arguments or less and accepts the same
3905 (num_opt_pos_params < other_num_opt_pos_params) || 3905 // arguments or more.
3906 if (((num_fixed_params - num_ignored_params) > other_num_fixed_params) ||
3907 ((num_fixed_params - num_ignored_params) + num_opt_pos_params <
3908 other_num_fixed_params + other_num_opt_pos_params) ||
3906 (num_opt_named_params < other_num_opt_named_params)) { 3909 (num_opt_named_params < other_num_opt_named_params)) {
3907 return false; 3910 return false;
3908 } 3911 }
3909 if (other_num_opt_named_params == 0) { 3912 if (other_num_opt_named_params == 0) {
3910 return true; 3913 return true;
3911 } 3914 }
3912 // Check that for each optional named parameter of the other function there 3915 // Check that for each optional named parameter of the other function there
3913 // exists an optional named parameter of this function with an identical 3916 // exists an optional named parameter of this function with an identical
3914 // name. 3917 // name.
3915 // Note that SetParameterNameAt() guarantees that names are symbols, so we 3918 // Note that SetParameterNameAt() guarantees that names are symbols, so we
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 const AbstractTypeArguments& other_type_arguments, 3995 const AbstractTypeArguments& other_type_arguments,
3993 Error* malformed_error) const { 3996 Error* malformed_error) const {
3994 const intptr_t num_fixed_params = num_fixed_parameters(); 3997 const intptr_t num_fixed_params = num_fixed_parameters();
3995 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); 3998 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
3996 const intptr_t num_opt_named_params = NumOptionalNamedParameters(); 3999 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
3997 const intptr_t other_num_fixed_params = other.num_fixed_parameters(); 4000 const intptr_t other_num_fixed_params = other.num_fixed_parameters();
3998 const intptr_t other_num_opt_pos_params = 4001 const intptr_t other_num_opt_pos_params =
3999 other.NumOptionalPositionalParameters(); 4002 other.NumOptionalPositionalParameters();
4000 const intptr_t other_num_opt_named_params = 4003 const intptr_t other_num_opt_named_params =
4001 other.NumOptionalNamedParameters(); 4004 other.NumOptionalNamedParameters();
4002 if ((num_fixed_params != other_num_fixed_params) || 4005 // This function requires the same arguments or less and accepts the same
4003 (num_opt_pos_params < other_num_opt_pos_params) || 4006 // arguments or more.
4007 if ((num_fixed_params > other_num_fixed_params) ||
4008 (num_fixed_params + num_opt_pos_params <
4009 other_num_fixed_params + other_num_opt_pos_params) ||
4004 (num_opt_named_params < other_num_opt_named_params)) { 4010 (num_opt_named_params < other_num_opt_named_params)) {
4005 return false; 4011 return false;
4006 } 4012 }
4007 // Check the result type. 4013 // Check the result type.
4008 AbstractType& other_res_type = AbstractType::Handle(other.result_type()); 4014 AbstractType& other_res_type = AbstractType::Handle(other.result_type());
4009 if (!other_res_type.IsInstantiated()) { 4015 if (!other_res_type.IsInstantiated()) {
4010 other_res_type = other_res_type.InstantiateFrom(other_type_arguments, 4016 other_res_type = other_res_type.InstantiateFrom(other_type_arguments,
4011 malformed_error); 4017 malformed_error);
4012 ASSERT((malformed_error == NULL) || malformed_error->IsNull()); 4018 ASSERT((malformed_error == NULL) || malformed_error->IsNull());
4013 } 4019 }
(...skipping 12 matching lines...) Expand all
4026 return false; 4032 return false;
4027 } 4033 }
4028 } else { 4034 } else {
4029 ASSERT(test_kind == kIsMoreSpecificThan); 4035 ASSERT(test_kind == kIsMoreSpecificThan);
4030 if (!res_type.IsMoreSpecificThan(other_res_type, malformed_error)) { 4036 if (!res_type.IsMoreSpecificThan(other_res_type, malformed_error)) {
4031 return false; 4037 return false;
4032 } 4038 }
4033 } 4039 }
4034 } 4040 }
4035 // Check the types of fixed and optional positional parameters. 4041 // Check the types of fixed and optional positional parameters.
4036 for (intptr_t i = 0; i < num_fixed_params + other_num_opt_pos_params; i++) { 4042 for (intptr_t i = 0;
4043 i < other_num_fixed_params + other_num_opt_pos_params; i++) {
4037 if (!TestParameterType(test_kind, 4044 if (!TestParameterType(test_kind,
4038 i, i, type_arguments, other, other_type_arguments, 4045 i, i, type_arguments, other, other_type_arguments,
4039 malformed_error)) { 4046 malformed_error)) {
4040 return false; 4047 return false;
4041 } 4048 }
4042 } 4049 }
4043 // Check the names and types of optional named parameters. 4050 // Check the names and types of optional named parameters.
4044 if (other_num_opt_named_params == 0) { 4051 if (other_num_opt_named_params == 0) {
4045 return true; 4052 return true;
4046 } 4053 }
(...skipping 9622 matching lines...) Expand 10 before | Expand all | Expand 10 after
13669 } 13676 }
13670 return result.raw(); 13677 return result.raw();
13671 } 13678 }
13672 13679
13673 13680
13674 const char* WeakProperty::ToCString() const { 13681 const char* WeakProperty::ToCString() const {
13675 return "_WeakProperty"; 13682 return "_WeakProperty";
13676 } 13683 }
13677 13684
13678 } // namespace dart 13685 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698