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 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 parameter.is_field_initializer = true; | 1027 parameter.is_field_initializer = true; |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 // At this point, we must see an identifier for the parameter name. | 1030 // At this point, we must see an identifier for the parameter name. |
| 1031 parameter.name_pos = token_index_; | 1031 parameter.name_pos = token_index_; |
| 1032 parameter.name = ExpectIdentifier("parameter name expected"); | 1032 parameter.name = ExpectIdentifier("parameter name expected"); |
| 1033 if (parameter.is_field_initializer) { | 1033 if (parameter.is_field_initializer) { |
| 1034 params->has_field_initializer = true; | 1034 params->has_field_initializer = true; |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 // Check that the formal parameter is not repeated. | |
| 1038 const intptr_t num_existing_parameters = | |
| 1039 params->num_fixed_parameters + params->num_optional_parameters; | |
| 1040 for (intptr_t i = 0; i < num_existing_parameters; i++) { | |
| 1041 ParamDesc& existing_parameter = (*params->parameters)[i]; | |
| 1042 if (existing_parameter.name->Equals(*parameter.name)) { | |
| 1043 ErrorMsg(parameter.name_pos, "repeated formal parameter"); | |
|
hausner
2012/05/23 21:34:39
In other places we use the phrase "duplicate", so
| |
| 1044 } | |
| 1045 } | |
| 1046 | |
| 1037 if (CurrentToken() == Token::kLPAREN) { | 1047 if (CurrentToken() == Token::kLPAREN) { |
| 1038 // This parameter is probably a closure. If we saw the keyword 'var' | 1048 // This parameter is probably a closure. If we saw the keyword 'var' |
| 1039 // or 'final', a closure is not legal here and we ignore the | 1049 // or 'final', a closure is not legal here and we ignore the |
| 1040 // opening parens. | 1050 // opening parens. |
| 1041 if (!var_seen && !parameter.is_final) { | 1051 if (!var_seen && !parameter.is_final) { |
| 1042 // The parsed parameter type is actually the function result type. | 1052 // The parsed parameter type is actually the function result type. |
| 1043 const AbstractType& result_type = | 1053 const AbstractType& result_type = |
| 1044 AbstractType::Handle(parameter.type->raw()); | 1054 AbstractType::Handle(parameter.type->raw()); |
| 1045 | 1055 |
| 1046 // Finish parsing the function type parameter. | 1056 // Finish parsing the function type parameter. |
| (...skipping 7447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8494 void Parser::SkipQualIdent() { | 8504 void Parser::SkipQualIdent() { |
| 8495 ASSERT(IsIdentifier()); | 8505 ASSERT(IsIdentifier()); |
| 8496 ConsumeToken(); | 8506 ConsumeToken(); |
| 8497 if (CurrentToken() == Token::kPERIOD) { | 8507 if (CurrentToken() == Token::kPERIOD) { |
| 8498 ConsumeToken(); // Consume the kPERIOD token. | 8508 ConsumeToken(); // Consume the kPERIOD token. |
| 8499 ExpectIdentifier("identifier expected after '.'"); | 8509 ExpectIdentifier("identifier expected after '.'"); |
| 8500 } | 8510 } |
| 8501 } | 8511 } |
| 8502 | 8512 |
| 8503 } // namespace dart | 8513 } // namespace dart |
| OLD | NEW |