| 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/parser.h" | 5 #include "vm/parser.h" |
| 6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
| 7 | 7 |
| 8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 3279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3290 ParamList discarded_params; | 3290 ParamList discarded_params; |
| 3291 ParseFormalParameterList(allow_explicit_default_values, | 3291 ParseFormalParameterList(allow_explicit_default_values, |
| 3292 false, | 3292 false, |
| 3293 &discarded_params); | 3293 &discarded_params); |
| 3294 } | 3294 } |
| 3295 } else { | 3295 } else { |
| 3296 ParseFormalParameterList(allow_explicit_default_values, false, ¶ms); | 3296 ParseFormalParameterList(allow_explicit_default_values, false, ¶ms); |
| 3297 | 3297 |
| 3298 // The number of parameters and their type are not yet set in local | 3298 // The number of parameters and their type are not yet set in local |
| 3299 // functions, since they are not 'top-level' parsed. | 3299 // functions, since they are not 'top-level' parsed. |
| 3300 if (func.IsLocalFunction()) { | 3300 // However, they are already set when the local function is compiled, since |
| 3301 // the local function was parsed when its parent was compiled. |
| 3302 if (func.parameter_types() == Object::empty_array().raw()) { |
| 3301 AddFormalParamsToFunction(¶ms, func); | 3303 AddFormalParamsToFunction(¶ms, func); |
| 3302 } | 3304 } |
| 3303 SetupDefaultsForOptionalParams(params); | 3305 SetupDefaultsForOptionalParams(params); |
| 3304 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); | 3306 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); |
| 3305 ASSERT(func.NumParameters() == params.parameters->length()); | 3307 ASSERT(func.NumParameters() == params.parameters->length()); |
| 3306 | 3308 |
| 3307 // Check whether the function has any field initializer formal parameters, | 3309 // Check whether the function has any field initializer formal parameters, |
| 3308 // which are not allowed in non-constructor functions. | 3310 // which are not allowed in non-constructor functions. |
| 3309 if (params.has_field_initializer) { | 3311 if (params.has_field_initializer) { |
| 3310 for (int i = 0; i < params.parameters->length(); i++) { | 3312 for (int i = 0; i < params.parameters->length(); i++) { |
| (...skipping 3969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7280 const Script& script = Script::Handle(Class::Handle(func.Owner()).script()); | 7282 const Script& script = Script::Handle(Class::Handle(func.Owner()).script()); |
| 7281 Report::MessageF(Report::kError, | 7283 Report::MessageF(Report::kError, |
| 7282 script, func.token_pos(), Report::AtLocation, | 7284 script, func.token_pos(), Report::AtLocation, |
| 7283 "too many formal parameters"); | 7285 "too many formal parameters"); |
| 7284 } | 7286 } |
| 7285 func.set_num_fixed_parameters(params->num_fixed_parameters); | 7287 func.set_num_fixed_parameters(params->num_fixed_parameters); |
| 7286 func.SetNumOptionalParameters(params->num_optional_parameters, | 7288 func.SetNumOptionalParameters(params->num_optional_parameters, |
| 7287 params->has_optional_positional_parameters); | 7289 params->has_optional_positional_parameters); |
| 7288 const int num_parameters = params->parameters->length(); | 7290 const int num_parameters = params->parameters->length(); |
| 7289 ASSERT(num_parameters == func.NumParameters()); | 7291 ASSERT(num_parameters == func.NumParameters()); |
| 7292 ASSERT(func.parameter_types() == Object::empty_array().raw()); |
| 7293 ASSERT(func.parameter_names() == Object::empty_array().raw()); |
| 7290 func.set_parameter_types(Array::Handle(Array::New(num_parameters, | 7294 func.set_parameter_types(Array::Handle(Array::New(num_parameters, |
| 7291 Heap::kOld))); | 7295 Heap::kOld))); |
| 7292 func.set_parameter_names(Array::Handle(Array::New(num_parameters, | 7296 func.set_parameter_names(Array::Handle(Array::New(num_parameters, |
| 7293 Heap::kOld))); | 7297 Heap::kOld))); |
| 7294 for (int i = 0; i < num_parameters; i++) { | 7298 for (int i = 0; i < num_parameters; i++) { |
| 7295 ParamDesc& param_desc = (*params->parameters)[i]; | 7299 ParamDesc& param_desc = (*params->parameters)[i]; |
| 7296 func.SetParameterTypeAt(i, *param_desc.type); | 7300 func.SetParameterTypeAt(i, *param_desc.type); |
| 7297 func.SetParameterNameAt(i, *param_desc.name); | 7301 func.SetParameterNameAt(i, *param_desc.name); |
| 7298 } | 7302 } |
| 7299 } | 7303 } |
| (...skipping 7179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14479 const ArgumentListNode& function_args, | 14483 const ArgumentListNode& function_args, |
| 14480 const LocalVariable* temp_for_last_arg, | 14484 const LocalVariable* temp_for_last_arg, |
| 14481 bool is_super_invocation) { | 14485 bool is_super_invocation) { |
| 14482 UNREACHABLE(); | 14486 UNREACHABLE(); |
| 14483 return NULL; | 14487 return NULL; |
| 14484 } | 14488 } |
| 14485 | 14489 |
| 14486 } // namespace dart | 14490 } // namespace dart |
| 14487 | 14491 |
| 14488 #endif // DART_PRECOMPILED_RUNTIME | 14492 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |