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

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

Issue 10928160: Limit the maximum number of formal parameters (32K fixed and 32K optional) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('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 3917 matching lines...) Expand 10 before | Expand all | Expand 10 after
3928 } 3928 }
3929 3929
3930 3930
3931 void Function::set_kind_tag(intptr_t value) const { 3931 void Function::set_kind_tag(intptr_t value) const {
3932 raw_ptr()->kind_tag_ = value; 3932 raw_ptr()->kind_tag_ = value;
3933 } 3933 }
3934 3934
3935 3935
3936 void Function::set_num_fixed_parameters(intptr_t value) const { 3936 void Function::set_num_fixed_parameters(intptr_t value) const {
3937 ASSERT(value >= 0); 3937 ASSERT(value >= 0);
3938 raw_ptr()->num_fixed_parameters_ = value; 3938 ASSERT(Utils::IsInt(16, value));
3939 raw_ptr()->num_fixed_parameters_ = static_cast<int16_t>(value);
3939 } 3940 }
3940 3941
3941 3942
3942 void Function::set_num_optional_positional_parameters(intptr_t value) const { 3943 void Function::set_num_optional_parameters(intptr_t value) const {
3943 ASSERT(value >= 0); 3944 // A positive value indicates positional params, a negative one named params.
3944 raw_ptr()->num_optional_positional_parameters_ = value; 3945 ASSERT(Utils::IsInt(16, value));
3945 // Optional positional and optional named parameters are mutually exclusive. 3946 raw_ptr()->num_optional_parameters_ = static_cast<int16_t>(value);
3946 ASSERT((num_optional_positional_parameters() == 0) ||
3947 (num_optional_named_parameters() == 0));
3948 } 3947 }
3949 3948
3950 3949
3951 void Function::set_num_optional_named_parameters(intptr_t value) const { 3950 void Function::SetNumOptionalParameters(intptr_t num_optional_parameters,
3952 ASSERT(value >= 0); 3951 bool are_optional_positional) const {
3953 raw_ptr()->num_optional_named_parameters_ = value; 3952 ASSERT(num_optional_parameters >= 0);
3954 // Optional positional and optional named parameters are mutually exclusive. 3953 set_num_optional_parameters(are_optional_positional ?
3955 ASSERT((num_optional_positional_parameters() == 0) || 3954 num_optional_parameters :
3956 (num_optional_named_parameters() == 0)); 3955 -num_optional_parameters);
3957 } 3956 }
3958 3957
3959 3958
3960 bool Function::is_optimizable() const { 3959 bool Function::is_optimizable() const {
3961 return OptimizableBit::decode(raw_ptr()->kind_tag_) && 3960 return OptimizableBit::decode(raw_ptr()->kind_tag_) &&
3962 (script() != Script::null()) && 3961 (script() != Script::null()) &&
3963 !is_native(); 3962 !is_native();
3964 } 3963 }
3965 3964
3966 3965
(...skipping 14 matching lines...) Expand all
3981 raw_ptr()->kind_tag_ = NativeBit::update(value, bits); 3980 raw_ptr()->kind_tag_ = NativeBit::update(value, bits);
3982 } 3981 }
3983 3982
3984 3983
3985 void Function::set_is_abstract(bool value) const { 3984 void Function::set_is_abstract(bool value) const {
3986 uword bits = raw_ptr()->kind_tag_; 3985 uword bits = raw_ptr()->kind_tag_;
3987 raw_ptr()->kind_tag_ = AbstractBit::update(value, bits); 3986 raw_ptr()->kind_tag_ = AbstractBit::update(value, bits);
3988 } 3987 }
3989 3988
3990 3989
3991 intptr_t Function::NumberOfParameters() const { 3990 intptr_t Function::NumParameters() const {
3992 return num_fixed_parameters() + 3991 return num_fixed_parameters() + NumOptionalParameters();
3993 num_optional_positional_parameters() + num_optional_named_parameters();
3994 } 3992 }
3995 3993
3996 3994
3997 intptr_t Function::NumberOfImplicitParameters() const { 3995 intptr_t Function::NumImplicitParameters() const {
3998 if (kind() == RawFunction::kConstructor) { 3996 if (kind() == RawFunction::kConstructor) {
3999 if (is_static()) { 3997 if (is_static()) {
4000 ASSERT(IsFactory()); 3998 ASSERT(IsFactory());
4001 return 1; // Type arguments. 3999 return 1; // Type arguments.
4002 } else { 4000 } else {
4003 ASSERT(IsConstructor()); 4001 ASSERT(IsConstructor());
4004 return 2; // Instance, phase. 4002 return 2; // Instance, phase.
4005 } 4003 }
4006 } 4004 }
4007 if (!is_static() && (kind() != RawFunction::kClosureFunction)) { 4005 if (!is_static() && (kind() != RawFunction::kClosureFunction)) {
4008 // Closure functions defined inside instance (i.e. non-static) functions are 4006 // Closure functions defined inside instance (i.e. non-static) functions are
4009 // marked as non-static, but they do not have a receiver. 4007 // marked as non-static, but they do not have a receiver.
4010 return 1; // Receiver. 4008 return 1; // Receiver.
4011 } 4009 }
4012 return 0; // No implicit parameters. 4010 return 0; // No implicit parameters.
4013 } 4011 }
4014 4012
4015 4013
4016 void Function::SetNumberOfParameters(intptr_t num_fixed_parameters,
4017 intptr_t num_optional_parameters,
4018 bool are_optional_positional) const {
4019 set_num_fixed_parameters(num_fixed_parameters);
4020 if (are_optional_positional) {
4021 set_num_optional_positional_parameters(num_optional_parameters);
4022 set_num_optional_named_parameters(0);
4023 } else {
4024 set_num_optional_positional_parameters(0);
4025 set_num_optional_named_parameters(num_optional_parameters);
4026 }
4027 }
4028
4029
4030 bool Function::AreValidArgumentCounts(int num_arguments, 4014 bool Function::AreValidArgumentCounts(int num_arguments,
4031 int num_named_arguments, 4015 int num_named_arguments,
4032 String* error_message) const { 4016 String* error_message) const {
4033 if (FLAG_reject_named_argument_as_positional) { 4017 if (FLAG_reject_named_argument_as_positional) {
4034 if (num_named_arguments > num_optional_named_parameters()) { 4018 if (num_named_arguments > NumOptionalNamedParameters()) {
4035 if (error_message != NULL) { 4019 if (error_message != NULL) {
4036 const intptr_t kMessageBufferSize = 64; 4020 const intptr_t kMessageBufferSize = 64;
4037 char message_buffer[kMessageBufferSize]; 4021 char message_buffer[kMessageBufferSize];
4038 OS::SNPrint(message_buffer, 4022 OS::SNPrint(message_buffer,
4039 kMessageBufferSize, 4023 kMessageBufferSize,
4040 "%d named passed, at most %"Pd" expected", 4024 "%d named passed, at most %"Pd" expected",
4041 num_named_arguments, 4025 num_named_arguments,
4042 num_optional_named_parameters()); 4026 NumOptionalNamedParameters());
4043 *error_message = String::New(message_buffer); 4027 *error_message = String::New(message_buffer);
4044 } 4028 }
4045 return false; // Too many named arguments. 4029 return false; // Too many named arguments.
4046 } 4030 }
4047 const int num_pos_args = num_arguments - num_named_arguments; 4031 const int num_pos_args = num_arguments - num_named_arguments;
4048 const int num_opt_pos_params = num_optional_positional_parameters(); 4032 const int num_opt_pos_params = NumOptionalPositionalParameters();
4049 const int num_pos_params = num_fixed_parameters() + num_opt_pos_params; 4033 const int num_pos_params = num_fixed_parameters() + num_opt_pos_params;
4050 if (num_pos_args > num_pos_params) { 4034 if (num_pos_args > num_pos_params) {
4051 if (error_message != NULL) { 4035 if (error_message != NULL) {
4052 const intptr_t kMessageBufferSize = 64; 4036 const intptr_t kMessageBufferSize = 64;
4053 char message_buffer[kMessageBufferSize]; 4037 char message_buffer[kMessageBufferSize];
4054 // Hide implicit parameters to the user. 4038 // Hide implicit parameters to the user.
4055 const intptr_t num_hidden_params = NumberOfImplicitParameters(); 4039 const intptr_t num_hidden_params = NumImplicitParameters();
4056 OS::SNPrint(message_buffer, 4040 OS::SNPrint(message_buffer,
4057 kMessageBufferSize, 4041 kMessageBufferSize,
4058 "%"Pd"%s passed, %s%"Pd" expected", 4042 "%"Pd"%s passed, %s%"Pd" expected",
4059 num_pos_args - num_hidden_params, 4043 num_pos_args - num_hidden_params,
4060 num_opt_pos_params > 0 ? " positional" : "", 4044 num_opt_pos_params > 0 ? " positional" : "",
4061 num_opt_pos_params > 0 ? "at most " : "", 4045 num_opt_pos_params > 0 ? "at most " : "",
4062 num_pos_params - num_hidden_params); 4046 num_pos_params - num_hidden_params);
4063 *error_message = String::New(message_buffer); 4047 *error_message = String::New(message_buffer);
4064 } 4048 }
4065 return false; // Too many fixed and/or positional arguments. 4049 return false; // Too many fixed and/or positional arguments.
4066 } 4050 }
4067 if (num_pos_args < num_fixed_parameters()) { 4051 if (num_pos_args < num_fixed_parameters()) {
4068 if (error_message != NULL) { 4052 if (error_message != NULL) {
4069 const intptr_t kMessageBufferSize = 64; 4053 const intptr_t kMessageBufferSize = 64;
4070 char message_buffer[kMessageBufferSize]; 4054 char message_buffer[kMessageBufferSize];
4071 // Hide implicit parameters to the user. 4055 // Hide implicit parameters to the user.
4072 const intptr_t num_hidden_params = NumberOfImplicitParameters(); 4056 const intptr_t num_hidden_params = NumImplicitParameters();
4073 OS::SNPrint(message_buffer, 4057 OS::SNPrint(message_buffer,
4074 kMessageBufferSize, 4058 kMessageBufferSize,
4075 "%"Pd"%s passed, %s%"Pd" expected", 4059 "%"Pd"%s passed, %s%"Pd" expected",
4076 num_pos_args - num_hidden_params, 4060 num_pos_args - num_hidden_params,
4077 num_opt_pos_params > 0 ? " positional" : "", 4061 num_opt_pos_params > 0 ? " positional" : "",
4078 num_opt_pos_params > 0 ? "at least " : "", 4062 num_opt_pos_params > 0 ? "at least " : "",
4079 num_fixed_parameters() - num_hidden_params); 4063 num_fixed_parameters() - num_hidden_params);
4080 *error_message = String::New(message_buffer); 4064 *error_message = String::New(message_buffer);
4081 } 4065 }
4082 return false; // Too few fixed and/or positional arguments. 4066 return false; // Too few fixed and/or positional arguments.
4083 } 4067 }
4084 return true; 4068 return true;
4085 } 4069 }
4086 4070
4087 // TODO(regis): Remove the following code once the flag is removed. 4071 // TODO(regis): Remove the following code once the flag is removed.
4088 4072
4089 if (num_arguments > NumberOfParameters()) { 4073 if (num_arguments > NumParameters()) {
4090 if (error_message != NULL) { 4074 if (error_message != NULL) {
4091 const intptr_t kMessageBufferSize = 64; 4075 const intptr_t kMessageBufferSize = 64;
4092 char message_buffer[kMessageBufferSize]; 4076 char message_buffer[kMessageBufferSize];
4093 // Hide implicit parameters to the user. 4077 // Hide implicit parameters to the user.
4094 const intptr_t num_hidden_params = NumberOfImplicitParameters(); 4078 const intptr_t num_hidden_params = NumImplicitParameters();
4095 OS::SNPrint(message_buffer, 4079 OS::SNPrint(message_buffer,
4096 kMessageBufferSize, 4080 kMessageBufferSize,
4097 "%"Pd" passed, %s%"Pd" expected", 4081 "%"Pd" passed, %s%"Pd" expected",
4098 num_arguments - num_hidden_params, 4082 num_arguments - num_hidden_params,
4099 HasOptionalParameters() ? "at most " : "", 4083 HasOptionalParameters() ? "at most " : "",
4100 NumberOfParameters() - num_hidden_params); 4084 NumParameters() - num_hidden_params);
4101 *error_message = String::New(message_buffer); 4085 *error_message = String::New(message_buffer);
4102 } 4086 }
4103 return false; // Too many arguments. 4087 return false; // Too many arguments.
4104 } 4088 }
4105 const int num_positional_args = num_arguments - num_named_arguments; 4089 const int num_positional_args = num_arguments - num_named_arguments;
4106 if (num_positional_args < num_fixed_parameters()) { 4090 if (num_positional_args < num_fixed_parameters()) {
4107 if (error_message != NULL) { 4091 if (error_message != NULL) {
4108 const intptr_t kMessageBufferSize = 64; 4092 const intptr_t kMessageBufferSize = 64;
4109 char message_buffer[kMessageBufferSize]; 4093 char message_buffer[kMessageBufferSize];
4110 // Hide implicit parameters to the user. 4094 // Hide implicit parameters to the user.
4111 const intptr_t num_hidden_params = NumberOfImplicitParameters(); 4095 const intptr_t num_hidden_params = NumImplicitParameters();
4112 OS::SNPrint(message_buffer, 4096 OS::SNPrint(message_buffer,
4113 kMessageBufferSize, 4097 kMessageBufferSize,
4114 "%"Pd" %spassed, %"Pd" expected", 4098 "%"Pd" %spassed, %"Pd" expected",
4115 num_positional_args - num_hidden_params, 4099 num_positional_args - num_hidden_params,
4116 HasOptionalParameters() ? "positional " : "", 4100 HasOptionalParameters() ? "positional " : "",
4117 num_fixed_parameters() - num_hidden_params); 4101 num_fixed_parameters() - num_hidden_params);
4118 *error_message = String::New(message_buffer); 4102 *error_message = String::New(message_buffer);
4119 } 4103 }
4120 return false; // Too few arguments. 4104 return false; // Too few arguments.
4121 } 4105 }
(...skipping 12 matching lines...) Expand all
4134 return false; 4118 return false;
4135 } 4119 }
4136 // Verify that all argument names are valid parameter names. 4120 // Verify that all argument names are valid parameter names.
4137 String& argument_name = String::Handle(); 4121 String& argument_name = String::Handle();
4138 String& parameter_name = String::Handle(); 4122 String& parameter_name = String::Handle();
4139 for (int i = 0; i < num_named_arguments; i++) { 4123 for (int i = 0; i < num_named_arguments; i++) {
4140 argument_name ^= argument_names.At(i); 4124 argument_name ^= argument_names.At(i);
4141 ASSERT(argument_name.IsSymbol()); 4125 ASSERT(argument_name.IsSymbol());
4142 bool found = false; 4126 bool found = false;
4143 const int num_positional_args = num_arguments - num_named_arguments; 4127 const int num_positional_args = num_arguments - num_named_arguments;
4144 const int num_parameters = NumberOfParameters(); 4128 const int num_parameters = NumParameters();
4145 for (int j = num_positional_args; !found && (j < num_parameters); j++) { 4129 for (int j = num_positional_args; !found && (j < num_parameters); j++) {
4146 parameter_name ^= ParameterNameAt(j); 4130 parameter_name ^= ParameterNameAt(j);
4147 ASSERT(argument_name.IsSymbol()); 4131 ASSERT(argument_name.IsSymbol());
4148 if (argument_name.Equals(parameter_name)) { 4132 if (argument_name.Equals(parameter_name)) {
4149 found = true; 4133 found = true;
4150 } 4134 }
4151 } 4135 }
4152 if (!found) { 4136 if (!found) {
4153 if (error_message != NULL) { 4137 if (error_message != NULL) {
4154 const intptr_t kMessageBufferSize = 64; 4138 const intptr_t kMessageBufferSize = 64;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4215 4199
4216 const char* Function::ToFullyQualifiedCString() const { 4200 const char* Function::ToFullyQualifiedCString() const {
4217 char* chars = NULL; 4201 char* chars = NULL;
4218 ConstructFunctionFullyQualifiedCString(*this, &chars, 0); 4202 ConstructFunctionFullyQualifiedCString(*this, &chars, 0);
4219 return chars; 4203 return chars;
4220 } 4204 }
4221 4205
4222 4206
4223 bool Function::HasCompatibleParametersWith(const Function& other) const { 4207 bool Function::HasCompatibleParametersWith(const Function& other) const {
4224 const intptr_t num_fixed_params = num_fixed_parameters(); 4208 const intptr_t num_fixed_params = num_fixed_parameters();
4225 const intptr_t num_opt_pos_params = num_optional_positional_parameters(); 4209 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
4226 const intptr_t num_opt_named_params = num_optional_named_parameters(); 4210 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
4227 const intptr_t other_num_fixed_params = other.num_fixed_parameters(); 4211 const intptr_t other_num_fixed_params = other.num_fixed_parameters();
4228 const intptr_t other_num_opt_pos_params = 4212 const intptr_t other_num_opt_pos_params =
4229 other.num_optional_positional_parameters(); 4213 other.NumOptionalPositionalParameters();
4230 const intptr_t other_num_opt_named_params = 4214 const intptr_t other_num_opt_named_params =
4231 other.num_optional_named_parameters(); 4215 other.NumOptionalNamedParameters();
4232 if (FLAG_reject_named_argument_as_positional) { 4216 if (FLAG_reject_named_argument_as_positional) {
4233 // The default values of optional parameters can differ. 4217 // The default values of optional parameters can differ.
4234 if ((num_fixed_params != other_num_fixed_params) || 4218 if ((num_fixed_params != other_num_fixed_params) ||
4235 (num_opt_pos_params < other_num_opt_pos_params) || 4219 (num_opt_pos_params < other_num_opt_pos_params) ||
4236 (num_opt_named_params < other_num_opt_named_params)) { 4220 (num_opt_named_params < other_num_opt_named_params)) {
4237 return false; 4221 return false;
4238 } 4222 }
4239 if (other_num_opt_named_params == 0) { 4223 if (other_num_opt_named_params == 0) {
4240 return true; 4224 return true;
4241 } 4225 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
4339 return true; 4323 return true;
4340 } 4324 }
4341 4325
4342 4326
4343 bool Function::TypeTest(TypeTestKind test_kind, 4327 bool Function::TypeTest(TypeTestKind test_kind,
4344 const AbstractTypeArguments& type_arguments, 4328 const AbstractTypeArguments& type_arguments,
4345 const Function& other, 4329 const Function& other,
4346 const AbstractTypeArguments& other_type_arguments, 4330 const AbstractTypeArguments& other_type_arguments,
4347 Error* malformed_error) const { 4331 Error* malformed_error) const {
4348 const intptr_t num_fixed_params = num_fixed_parameters(); 4332 const intptr_t num_fixed_params = num_fixed_parameters();
4349 const intptr_t num_opt_pos_params = num_optional_positional_parameters(); 4333 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
4350 const intptr_t num_opt_named_params = num_optional_named_parameters(); 4334 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
4351 const intptr_t other_num_fixed_params = other.num_fixed_parameters(); 4335 const intptr_t other_num_fixed_params = other.num_fixed_parameters();
4352 const intptr_t other_num_opt_pos_params = 4336 const intptr_t other_num_opt_pos_params =
4353 other.num_optional_positional_parameters(); 4337 other.NumOptionalPositionalParameters();
4354 const intptr_t other_num_opt_named_params = 4338 const intptr_t other_num_opt_named_params =
4355 other.num_optional_named_parameters(); 4339 other.NumOptionalNamedParameters();
4356 if ((num_fixed_params != other_num_fixed_params) || 4340 if ((num_fixed_params != other_num_fixed_params) ||
4357 (num_opt_pos_params < other_num_opt_pos_params) || 4341 (num_opt_pos_params < other_num_opt_pos_params) ||
4358 (num_opt_named_params < other_num_opt_named_params)) { 4342 (num_opt_named_params < other_num_opt_named_params)) {
4359 return false; 4343 return false;
4360 } 4344 }
4361 // Check the result type. 4345 // Check the result type.
4362 AbstractType& other_res_type = AbstractType::Handle(other.result_type()); 4346 AbstractType& other_res_type = AbstractType::Handle(other.result_type());
4363 if (!other_res_type.IsInstantiated()) { 4347 if (!other_res_type.IsInstantiated()) {
4364 other_res_type = other_res_type.InstantiateFrom(other_type_arguments); 4348 other_res_type = other_res_type.InstantiateFrom(other_type_arguments);
4365 } 4349 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
4502 result.set_name(name); 4486 result.set_name(name);
4503 result.set_kind(kind); 4487 result.set_kind(kind);
4504 result.set_is_static(is_static); 4488 result.set_is_static(is_static);
4505 result.set_is_const(is_const); 4489 result.set_is_const(is_const);
4506 result.set_is_abstract(is_abstract); 4490 result.set_is_abstract(is_abstract);
4507 result.set_is_external(is_external); 4491 result.set_is_external(is_external);
4508 result.set_owner(owner); 4492 result.set_owner(owner);
4509 result.set_token_pos(token_pos); 4493 result.set_token_pos(token_pos);
4510 result.set_end_token_pos(token_pos); 4494 result.set_end_token_pos(token_pos);
4511 result.set_num_fixed_parameters(0); 4495 result.set_num_fixed_parameters(0);
4512 result.set_num_optional_positional_parameters(0); 4496 result.set_num_optional_parameters(0);
4513 result.set_num_optional_named_parameters(0);
4514 result.set_usage_counter(0); 4497 result.set_usage_counter(0);
4515 result.set_deoptimization_counter(0); 4498 result.set_deoptimization_counter(0);
4516 result.set_is_optimizable(true); 4499 result.set_is_optimizable(true);
4517 result.set_has_finally(false); 4500 result.set_has_finally(false);
4518 result.set_is_native(false); 4501 result.set_is_native(false);
4519 return result.raw(); 4502 return result.raw();
4520 } 4503 }
4521 4504
4522 4505
4523 RawFunction* Function::NewClosureFunction(const String& name, 4506 RawFunction* Function::NewClosureFunction(const String& name,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4562 } 4545 }
4563 closure_function.set_context_scope(context_scope); 4546 closure_function.set_context_scope(context_scope);
4564 4547
4565 // Set closure function's result type to this result type. 4548 // Set closure function's result type to this result type.
4566 closure_function.set_result_type(AbstractType::Handle(result_type())); 4549 closure_function.set_result_type(AbstractType::Handle(result_type()));
4567 4550
4568 // Set closure function's formal parameters to this formal parameters, 4551 // Set closure function's formal parameters to this formal parameters,
4569 // removing the receiver if this is an instance method. 4552 // removing the receiver if this is an instance method.
4570 const int has_receiver = is_static() ? 0 : 1; 4553 const int has_receiver = is_static() ? 0 : 1;
4571 const int num_fixed_params = num_fixed_parameters() - has_receiver; 4554 const int num_fixed_params = num_fixed_parameters() - has_receiver;
4572 const int num_opt_pos_params = num_optional_positional_parameters(); 4555 const int num_opt_params = NumOptionalParameters();
4573 const int num_opt_named_params = num_optional_named_parameters(); 4556 const bool has_opt_pos_params = HasOptionalPositionalParameters();
4574 const int num_params = 4557 const int num_params = num_fixed_params + num_opt_params;
4575 num_fixed_params + num_opt_pos_params + num_opt_named_params;
4576 closure_function.set_num_fixed_parameters(num_fixed_params); 4558 closure_function.set_num_fixed_parameters(num_fixed_params);
4577 closure_function.set_num_optional_positional_parameters(num_opt_pos_params); 4559 closure_function.SetNumOptionalParameters(num_opt_params, has_opt_pos_params);
4578 closure_function.set_num_optional_named_parameters(num_opt_named_params);
4579 closure_function.set_parameter_types(Array::Handle(Array::New(num_params, 4560 closure_function.set_parameter_types(Array::Handle(Array::New(num_params,
4580 Heap::kOld))); 4561 Heap::kOld)));
4581 closure_function.set_parameter_names(Array::Handle(Array::New(num_params, 4562 closure_function.set_parameter_names(Array::Handle(Array::New(num_params,
4582 Heap::kOld))); 4563 Heap::kOld)));
4583 AbstractType& param_type = AbstractType::Handle(); 4564 AbstractType& param_type = AbstractType::Handle();
4584 String& param_name = String::Handle(); 4565 String& param_name = String::Handle();
4585 for (int i = 0; i < num_params; i++) { 4566 for (int i = 0; i < num_params; i++) {
4586 param_type = ParameterTypeAt(i + has_receiver); 4567 param_type = ParameterTypeAt(i + has_receiver);
4587 closure_function.SetParameterTypeAt(i, param_type); 4568 closure_function.SetParameterTypeAt(i, param_type);
4588 param_name = ParameterNameAt(i + has_receiver); 4569 param_name = ParameterNameAt(i + has_receiver);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
4661 pieces.Add(name); 4642 pieces.Add(name);
4662 } 4643 }
4663 if (i < num_type_parameters - 1) { 4644 if (i < num_type_parameters - 1) {
4664 pieces.Add(kCommaSpace); 4645 pieces.Add(kCommaSpace);
4665 } 4646 }
4666 } 4647 }
4667 pieces.Add(kRAngleBracket); 4648 pieces.Add(kRAngleBracket);
4668 } 4649 }
4669 } 4650 }
4670 AbstractType& param_type = AbstractType::Handle(); 4651 AbstractType& param_type = AbstractType::Handle();
4671 const intptr_t num_params = NumberOfParameters(); 4652 const intptr_t num_params = NumParameters();
4672 const intptr_t num_fixed_params = num_fixed_parameters(); 4653 const intptr_t num_fixed_params = num_fixed_parameters();
4673 const intptr_t num_opt_pos_params = num_optional_positional_parameters(); 4654 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
4674 const intptr_t num_opt_named_params = num_optional_named_parameters(); 4655 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
4675 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params; 4656 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params;
4676 ASSERT((num_fixed_params + num_opt_params) == num_params); 4657 ASSERT((num_fixed_params + num_opt_params) == num_params);
4677 pieces.Add(kLParen); 4658 pieces.Add(kLParen);
4678 for (intptr_t i = 0; i < num_fixed_params; i++) { 4659 for (intptr_t i = 0; i < num_fixed_params; i++) {
4679 param_type = ParameterTypeAt(i); 4660 param_type = ParameterTypeAt(i);
4680 ASSERT(!param_type.IsNull()); 4661 ASSERT(!param_type.IsNull());
4681 if (instantiate && !param_type.IsInstantiated()) { 4662 if (instantiate && !param_type.IsInstantiated()) {
4682 param_type = param_type.InstantiateFrom(instantiator); 4663 param_type = param_type.InstantiateFrom(instantiator);
4683 } 4664 }
4684 name = param_type.BuildName(name_visibility); 4665 name = param_type.BuildName(name_visibility);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4729 const Array& strings = Array::Handle(Array::MakeArray(pieces)); 4710 const Array& strings = Array::Handle(Array::MakeArray(pieces));
4730 return Symbols::New(String::Handle(String::ConcatAll(strings))); 4711 return Symbols::New(String::Handle(String::ConcatAll(strings)));
4731 } 4712 }
4732 4713
4733 4714
4734 bool Function::HasInstantiatedSignature() const { 4715 bool Function::HasInstantiatedSignature() const {
4735 AbstractType& type = AbstractType::Handle(result_type()); 4716 AbstractType& type = AbstractType::Handle(result_type());
4736 if (!type.IsInstantiated()) { 4717 if (!type.IsInstantiated()) {
4737 return false; 4718 return false;
4738 } 4719 }
4739 const intptr_t num_parameters = NumberOfParameters(); 4720 const intptr_t num_parameters = NumParameters();
4740 for (intptr_t i = 0; i < num_parameters; i++) { 4721 for (intptr_t i = 0; i < num_parameters; i++) {
4741 type = ParameterTypeAt(i); 4722 type = ParameterTypeAt(i);
4742 if (!type.IsInstantiated()) { 4723 if (!type.IsInstantiated()) {
4743 return false; 4724 return false;
4744 } 4725 }
4745 } 4726 }
4746 return true; 4727 return true;
4747 } 4728 }
4748 4729
4749 4730
(...skipping 6752 matching lines...) Expand 10 before | Expand all | Expand 10 after
11502 } 11483 }
11503 return result.raw(); 11484 return result.raw();
11504 } 11485 }
11505 11486
11506 11487
11507 const char* WeakProperty::ToCString() const { 11488 const char* WeakProperty::ToCString() const {
11508 return "_WeakProperty"; 11489 return "_WeakProperty";
11509 } 11490 }
11510 11491
11511 } // namespace dart 11492 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698