| 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 3369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3380 // functions, since they are not 'top-level' parsed. | 3380 // functions, since they are not 'top-level' parsed. |
| 3381 // However, they are already set when the local function is compiled, since | 3381 // However, they are already set when the local function is compiled, since |
| 3382 // the local function was parsed when its parent was compiled. | 3382 // the local function was parsed when its parent was compiled. |
| 3383 if (func.parameter_types() == Object::empty_array().raw()) { | 3383 if (func.parameter_types() == Object::empty_array().raw()) { |
| 3384 AddFormalParamsToFunction(¶ms, func); | 3384 AddFormalParamsToFunction(¶ms, func); |
| 3385 } | 3385 } |
| 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, | |
| 3391 // which are not allowed in non-constructor functions. | |
| 3392 if (params.has_field_initializer) { | |
| 3393 for (int i = 0; i < params.parameters->length(); i++) { | |
| 3394 ParamDesc& param = (*params.parameters)[i]; | |
| 3395 if (param.is_field_initializer) { | |
| 3396 ReportError(param.name_pos, | |
| 3397 "field initializer only allowed in constructors"); | |
| 3398 } | |
| 3399 } | |
| 3400 } | |
| 3401 // Populate function scope with the formal parameters. | 3390 // Populate function scope with the formal parameters. |
| 3402 AddFormalParamsToScope(¶ms, current_block_->scope); | 3391 AddFormalParamsToScope(¶ms, current_block_->scope); |
| 3403 | 3392 |
| 3404 if (I->type_checks() && | 3393 if (I->type_checks() && |
| 3405 (FunctionLevel() > 0)) { | 3394 (FunctionLevel() > 0)) { |
| 3406 // We are parsing, but not compiling, a local function. | 3395 // We are parsing, but not compiling, a local function. |
| 3407 // The instantiator may be required at run time for generic type checks. | 3396 // The instantiator may be required at run time for generic type checks. |
| 3408 if (IsInstantiatorRequired()) { | 3397 if (IsInstantiatorRequired()) { |
| 3409 // Make sure that the receiver of the enclosing instance function | 3398 // Make sure that the receiver of the enclosing instance function |
| 3410 // (or implicit first parameter of an enclosing factory) is marked as | 3399 // (or implicit first parameter of an enclosing factory) is marked as |
| (...skipping 11229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14640 const ArgumentListNode& function_args, | 14629 const ArgumentListNode& function_args, |
| 14641 const LocalVariable* temp_for_last_arg, | 14630 const LocalVariable* temp_for_last_arg, |
| 14642 bool is_super_invocation) { | 14631 bool is_super_invocation) { |
| 14643 UNREACHABLE(); | 14632 UNREACHABLE(); |
| 14644 return NULL; | 14633 return NULL; |
| 14645 } | 14634 } |
| 14646 | 14635 |
| 14647 } // namespace dart | 14636 } // namespace dart |
| 14648 | 14637 |
| 14649 #endif // DART_PRECOMPILED_RUNTIME | 14638 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |