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/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 3375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3386 SetupDefaultsForOptionalParams(params); | 3386 SetupDefaultsForOptionalParams(params); |
| 3387 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); | 3387 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); |
| 3388 ASSERT(func.NumParameters() == params.parameters->length()); | 3388 ASSERT(func.NumParameters() == params.parameters->length()); |
| 3389 | 3389 |
| 3390 // Check whether the function has any field initializer formal parameters, | 3390 // Check whether the function has any field initializer formal parameters, |
| 3391 // which are not allowed in non-constructor functions. | 3391 // which are not allowed in non-constructor functions. |
| 3392 if (params.has_field_initializer) { | 3392 if (params.has_field_initializer) { |
| 3393 for (int i = 0; i < params.parameters->length(); i++) { | 3393 for (int i = 0; i < params.parameters->length(); i++) { |
| 3394 ParamDesc& param = (*params.parameters)[i]; | 3394 ParamDesc& param = (*params.parameters)[i]; |
| 3395 if (param.is_field_initializer) { | 3395 if (param.is_field_initializer) { |
| 3396 ReportError(param.name_pos, | 3396 ReportError(param.name_pos, |
|
hausner
2016/07/14 09:02:45
DBC: why does this check not cover the cases in th
regis
2016/07/14 17:00:47
There are 14 different call sites to ParseFormalPa
| |
| 3397 "field initializer only allowed in constructors"); | 3397 "field initializer only allowed in constructors"); |
| 3398 } | 3398 } |
| 3399 } | 3399 } |
| 3400 } | 3400 } |
| 3401 // Populate function scope with the formal parameters. | 3401 // Populate function scope with the formal parameters. |
| 3402 AddFormalParamsToScope(¶ms, current_block_->scope); | 3402 AddFormalParamsToScope(¶ms, current_block_->scope); |
| 3403 | 3403 |
| 3404 if (I->type_checks() && | 3404 if (I->type_checks() && |
| 3405 (FunctionLevel() > 0)) { | 3405 (FunctionLevel() > 0)) { |
| 3406 // We are parsing, but not compiling, a local function. | 3406 // We are parsing, but not compiling, a local function. |
| (...skipping 3983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7390 ASSERT(func.parameter_types() == Object::empty_array().raw()); | 7390 ASSERT(func.parameter_types() == Object::empty_array().raw()); |
| 7391 ASSERT(func.parameter_names() == Object::empty_array().raw()); | 7391 ASSERT(func.parameter_names() == Object::empty_array().raw()); |
| 7392 func.set_parameter_types(Array::Handle(Array::New(num_parameters, | 7392 func.set_parameter_types(Array::Handle(Array::New(num_parameters, |
| 7393 Heap::kOld))); | 7393 Heap::kOld))); |
| 7394 func.set_parameter_names(Array::Handle(Array::New(num_parameters, | 7394 func.set_parameter_names(Array::Handle(Array::New(num_parameters, |
| 7395 Heap::kOld))); | 7395 Heap::kOld))); |
| 7396 for (int i = 0; i < num_parameters; i++) { | 7396 for (int i = 0; i < num_parameters; i++) { |
| 7397 ParamDesc& param_desc = (*params->parameters)[i]; | 7397 ParamDesc& param_desc = (*params->parameters)[i]; |
| 7398 func.SetParameterTypeAt(i, *param_desc.type); | 7398 func.SetParameterTypeAt(i, *param_desc.type); |
| 7399 func.SetParameterNameAt(i, *param_desc.name); | 7399 func.SetParameterNameAt(i, *param_desc.name); |
| 7400 if (param_desc.is_field_initializer && !func.IsGenerativeConstructor()) { | |
| 7401 // Redirecting constructors are detected later in ParseConstructor. | |
| 7402 ReportError(param_desc.name_pos, | |
| 7403 "only generative constructors may have " | |
| 7404 "initializing formal parameters"); | |
| 7405 } | |
| 7400 } | 7406 } |
| 7401 } | 7407 } |
| 7402 | 7408 |
| 7403 | 7409 |
| 7404 // Populate local scope with the formal parameters. | 7410 // Populate local scope with the formal parameters. |
| 7405 void Parser::AddFormalParamsToScope(const ParamList* params, | 7411 void Parser::AddFormalParamsToScope(const ParamList* params, |
| 7406 LocalScope* scope) { | 7412 LocalScope* scope) { |
| 7407 ASSERT((params != NULL) && (params->parameters != NULL)); | 7413 ASSERT((params != NULL) && (params->parameters != NULL)); |
| 7408 ASSERT(scope != NULL); | 7414 ASSERT(scope != NULL); |
| 7409 const int num_parameters = params->parameters->length(); | 7415 const int num_parameters = params->parameters->length(); |
| (...skipping 7260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14670 const ArgumentListNode& function_args, | 14676 const ArgumentListNode& function_args, |
| 14671 const LocalVariable* temp_for_last_arg, | 14677 const LocalVariable* temp_for_last_arg, |
| 14672 bool is_super_invocation) { | 14678 bool is_super_invocation) { |
| 14673 UNREACHABLE(); | 14679 UNREACHABLE(); |
| 14674 return NULL; | 14680 return NULL; |
| 14675 } | 14681 } |
| 14676 | 14682 |
| 14677 } // namespace dart | 14683 } // namespace dart |
| 14678 | 14684 |
| 14679 #endif // DART_PRECOMPILED_RUNTIME | 14685 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |