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