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

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

Issue 11343044: Disallow 'dynamic' as type parameter name (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 3574 matching lines...) Expand 10 before | Expand all | Expand 10 after
3585 const GrowableObjectArray& type_parameters_array = 3585 const GrowableObjectArray& type_parameters_array =
3586 GrowableObjectArray::Handle(GrowableObjectArray::New()); 3586 GrowableObjectArray::Handle(GrowableObjectArray::New());
3587 intptr_t index = 0; 3587 intptr_t index = 0;
3588 TypeParameter& type_parameter = TypeParameter::Handle(); 3588 TypeParameter& type_parameter = TypeParameter::Handle();
3589 TypeParameter& existing_type_parameter = TypeParameter::Handle(); 3589 TypeParameter& existing_type_parameter = TypeParameter::Handle();
3590 String& existing_type_parameter_name = String::Handle(); 3590 String& existing_type_parameter_name = String::Handle();
3591 AbstractType& type_parameter_bound = Type::Handle(); 3591 AbstractType& type_parameter_bound = Type::Handle();
3592 do { 3592 do {
3593 ConsumeToken(); 3593 ConsumeToken();
3594 SkipMetadata(); 3594 SkipMetadata();
3595 if (CurrentToken() != Token::kIDENT) {
3596 ErrorMsg("type parameter name expected");
3597 }
3598 String& type_parameter_name = *CurrentLiteral();
3599 const intptr_t type_parameter_pos = TokenPos(); 3595 const intptr_t type_parameter_pos = TokenPos();
3596 String& type_parameter_name =
3597 *ExpectClassIdentifier("type parameter expected");
3600 // Check for duplicate type parameters. 3598 // Check for duplicate type parameters.
3601 for (intptr_t i = 0; i < index; i++) { 3599 for (intptr_t i = 0; i < index; i++) {
3602 existing_type_parameter ^= type_parameters_array.At(i); 3600 existing_type_parameter ^= type_parameters_array.At(i);
3603 existing_type_parameter_name = existing_type_parameter.name(); 3601 existing_type_parameter_name = existing_type_parameter.name();
3604 if (existing_type_parameter_name.Equals(type_parameter_name)) { 3602 if (existing_type_parameter_name.Equals(type_parameter_name)) {
3605 ErrorMsg("duplicate type parameter '%s'", 3603 ErrorMsg(type_parameter_pos, "duplicate type parameter '%s'",
3606 type_parameter_name.ToCString()); 3604 type_parameter_name.ToCString());
3607 } 3605 }
3608 } 3606 }
3609 ConsumeToken();
3610 if (CurrentToken() == Token::kEXTENDS) { 3607 if (CurrentToken() == Token::kEXTENDS) {
3611 ConsumeToken(); 3608 ConsumeToken();
3612 // A bound may refer to the owner of the type parameter it applies to, 3609 // A bound may refer to the owner of the type parameter it applies to,
3613 // i.e. to the class or interface currently being parsed. 3610 // i.e. to the class or interface currently being parsed.
3614 // Postpone resolution in order to avoid resolving the class and its 3611 // Postpone resolution in order to avoid resolving the class and its
3615 // type parameters, as they are not fully parsed yet. 3612 // type parameters, as they are not fully parsed yet.
3616 type_parameter_bound = ParseType(ClassFinalizer::kDoNotResolve); 3613 type_parameter_bound = ParseType(ClassFinalizer::kDoNotResolve);
3617 } else { 3614 } else {
3618 type_parameter_bound = isolate->object_store()->object_type(); 3615 type_parameter_bound = isolate->object_store()->object_type();
3619 } 3616 }
(...skipping 2960 matching lines...) Expand 10 before | Expand all | Expand 10 after
6580 } 6577 }
6581 6578
6582 6579
6583 void Parser::UnexpectedToken() { 6580 void Parser::UnexpectedToken() {
6584 ErrorMsg("unexpected token '%s'", 6581 ErrorMsg("unexpected token '%s'",
6585 CurrentToken() == Token::kIDENT ? 6582 CurrentToken() == Token::kIDENT ?
6586 CurrentLiteral()->ToCString() : Token::Str(CurrentToken())); 6583 CurrentLiteral()->ToCString() : Token::Str(CurrentToken()));
6587 } 6584 }
6588 6585
6589 6586
6590 String* Parser::ExpectClassIdentifier(const char* msg) { 6587 String* Parser::ExpectClassIdentifier(const char* msg) {
regis 2012/10/30 16:53:10 Nitpicking: the name ExpectClassIdentifier is not
hausner 2012/10/30 17:44:20 Changed to ExpectUserDefinedTypeIdentifier as disc
6591 if (CurrentToken() != Token::kIDENT) { 6588 if (CurrentToken() != Token::kIDENT) {
6592 ErrorMsg("%s", msg); 6589 ErrorMsg("%s", msg);
6593 } 6590 }
6594 String* ident = CurrentLiteral(); 6591 String* ident = CurrentLiteral();
6595 // TODO(hausner): Remove check for 'Dynamic' once support for upper-case 6592 // TODO(hausner): Remove check for 'Dynamic' once support for upper-case
6596 // type dynamic is gone. 6593 // type dynamic is gone.
6597 if (ident->Equals("Dynamic") || ident->Equals("dynamic")) { 6594 if (ident->Equals("Dynamic") || ident->Equals("dynamic")) {
6598 ErrorMsg("%s", msg); 6595 ErrorMsg("%s", msg);
6599 } 6596 }
6600 ConsumeToken(); 6597 ConsumeToken();
(...skipping 3242 matching lines...) Expand 10 before | Expand all | Expand 10 after
9843 void Parser::SkipQualIdent() { 9840 void Parser::SkipQualIdent() {
9844 ASSERT(IsIdentifier()); 9841 ASSERT(IsIdentifier());
9845 ConsumeToken(); 9842 ConsumeToken();
9846 if (CurrentToken() == Token::kPERIOD) { 9843 if (CurrentToken() == Token::kPERIOD) {
9847 ConsumeToken(); // Consume the kPERIOD token. 9844 ConsumeToken(); // Consume the kPERIOD token.
9848 ExpectIdentifier("identifier expected after '.'"); 9845 ExpectIdentifier("identifier expected after '.'");
9849 } 9846 }
9850 } 9847 }
9851 9848
9852 } // namespace dart 9849 } // 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