Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: runtime/vm/parser.cc

Issue 10426002: Disallow repeated type parameters (issues 2239 & 2240). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3124 matching lines...) Expand 10 before | Expand all | Expand 10 after
3135 3135
3136 3136
3137 void Parser::ParseTypeParameters(const Class& cls) { 3137 void Parser::ParseTypeParameters(const Class& cls) {
3138 TRACE_PARSER("ParseTypeParameters"); 3138 TRACE_PARSER("ParseTypeParameters");
3139 if (CurrentToken() == Token::kLT) { 3139 if (CurrentToken() == Token::kLT) {
3140 const GrowableObjectArray& type_parameters_array = 3140 const GrowableObjectArray& type_parameters_array =
3141 GrowableObjectArray::Handle(GrowableObjectArray::New()); 3141 GrowableObjectArray::Handle(GrowableObjectArray::New());
3142 const GrowableObjectArray& bounds_array = 3142 const GrowableObjectArray& bounds_array =
3143 GrowableObjectArray::Handle(GrowableObjectArray::New()); 3143 GrowableObjectArray::Handle(GrowableObjectArray::New());
3144 intptr_t index = 0; 3144 intptr_t index = 0;
3145 AbstractType& type_parameter = TypeParameter::Handle(); 3145 TypeParameter& type_parameter = TypeParameter::Handle();
3146 TypeParameter& existing_type_parameter = TypeParameter::Handle();
3147 String& existing_type_parameter_name = String::Handle();
3146 AbstractType& bound = Type::Handle(); 3148 AbstractType& bound = Type::Handle();
3147 do { 3149 do {
3148 ConsumeToken(); 3150 ConsumeToken();
3149 if (CurrentToken() != Token::kIDENT) { 3151 if (CurrentToken() != Token::kIDENT) {
3150 ErrorMsg("type parameter name expected"); 3152 ErrorMsg("type parameter name expected");
3151 } 3153 }
3152 String& type_parameter_name = *CurrentLiteral(); 3154 String& type_parameter_name = *CurrentLiteral();
3153 type_parameter = TypeParameter::New(cls, 3155 type_parameter = TypeParameter::New(cls,
3154 index, 3156 index,
3155 type_parameter_name, 3157 type_parameter_name,
3156 token_index_); 3158 token_index_);
3159 // Check that the type parameter is not repeated.
3160 for (intptr_t i = 0; i < index; i++) {
3161 existing_type_parameter ^= type_parameters_array.At(i);
3162 existing_type_parameter_name = existing_type_parameter.Name();
3163 if (existing_type_parameter_name.Equals(type_parameter_name)) {
3164 ErrorMsg("repeated type parameter");
3165 }
3166 }
3157 ConsumeToken(); 3167 ConsumeToken();
3158 bound = Type::DynamicType(); 3168 bound = Type::DynamicType();
3159 if (CurrentToken() == Token::kEXTENDS) { 3169 if (CurrentToken() == Token::kEXTENDS) {
3160 ConsumeToken(); 3170 ConsumeToken();
3161 // A bound may refer to the owner of the type parameter it applies to, 3171 // A bound may refer to the owner of the type parameter it applies to,
3162 // i.e. to the class or interface currently being parsed. 3172 // i.e. to the class or interface currently being parsed.
3163 // Postpone resolution in order to avoid resolving the class and its 3173 // Postpone resolution in order to avoid resolving the class and its
3164 // type parameters, as they are not fully parsed yet. 3174 // type parameters, as they are not fully parsed yet.
3165 bound = ParseType(ClassFinalizer::kDoNotResolve); 3175 bound = ParseType(ClassFinalizer::kDoNotResolve);
3166 } 3176 }
(...skipping 5317 matching lines...) Expand 10 before | Expand all | Expand 10 after
8484 void Parser::SkipQualIdent() { 8494 void Parser::SkipQualIdent() {
8485 ASSERT(IsIdentifier()); 8495 ASSERT(IsIdentifier());
8486 ConsumeToken(); 8496 ConsumeToken();
8487 if (CurrentToken() == Token::kPERIOD) { 8497 if (CurrentToken() == Token::kPERIOD) {
8488 ConsumeToken(); // Consume the kPERIOD token. 8498 ConsumeToken(); // Consume the kPERIOD token.
8489 ExpectIdentifier("identifier expected after '.'"); 8499 ExpectIdentifier("identifier expected after '.'");
8490 } 8500 }
8491 } 8501 }
8492 8502
8493 } // namespace dart 8503 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698