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

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

Issue 11085003: Convert String to a class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove left-over List change in comment. Created 8 years, 2 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
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 5031 matching lines...) Expand 10 before | Expand all | Expand 10 after
5042 bool no_check = type.IsDynamicType(); 5042 bool no_check = type.IsDynamicType();
5043 if ((CurrentToken() == Token::kINTEGER) && 5043 if ((CurrentToken() == Token::kINTEGER) &&
5044 (no_check || type.IsIntType() || type.IsNumberType())) { 5044 (no_check || type.IsIntType() || type.IsNumberType())) {
5045 *value = CurrentIntegerLiteral(); 5045 *value = CurrentIntegerLiteral();
5046 return true; 5046 return true;
5047 } else if ((CurrentToken() == Token::kDOUBLE) && 5047 } else if ((CurrentToken() == Token::kDOUBLE) &&
5048 (no_check || type.IsDoubleType() || type.IsNumberType())) { 5048 (no_check || type.IsDoubleType() || type.IsNumberType())) {
5049 *value = CurrentDoubleLiteral(); 5049 *value = CurrentDoubleLiteral();
5050 return true; 5050 return true;
5051 } else if ((CurrentToken() == Token::kSTRING) && 5051 } else if ((CurrentToken() == Token::kSTRING) &&
5052 (no_check || type.IsStringInterface())) { 5052 (no_check || type.IsStringType())) {
5053 *value = CurrentLiteral()->raw(); 5053 *value = CurrentLiteral()->raw();
5054 return true; 5054 return true;
5055 } else if ((CurrentToken() == Token::kTRUE) && 5055 } else if ((CurrentToken() == Token::kTRUE) &&
5056 (no_check || type.IsBoolType())) { 5056 (no_check || type.IsBoolType())) {
5057 *value = Bool::True(); 5057 *value = Bool::True();
5058 return true; 5058 return true;
5059 } else if ((CurrentToken() == Token::kFALSE) && 5059 } else if ((CurrentToken() == Token::kFALSE) &&
5060 (no_check || type.IsBoolType())) { 5060 (no_check || type.IsBoolType())) {
5061 *value = Bool::False(); 5061 *value = Bool::False();
5062 return true; 5062 return true;
(...skipping 3533 matching lines...) Expand 10 before | Expand all | Expand 10 after
8596 // Map literals take two type arguments. 8596 // Map literals take two type arguments.
8597 if (map_type_arguments.Length() < 2) { 8597 if (map_type_arguments.Length() < 2) {
8598 // TODO(hausner): Remove legacy syntax support. 8598 // TODO(hausner): Remove legacy syntax support.
8599 // We temporarily accept a single type argument. 8599 // We temporarily accept a single type argument.
8600 if (FLAG_warn_legacy_map_literal) { 8600 if (FLAG_warn_legacy_map_literal) {
8601 Warning(type_pos, 8601 Warning(type_pos,
8602 "a map literal takes two type arguments specifying " 8602 "a map literal takes two type arguments specifying "
8603 "the key type and the value type"); 8603 "the key type and the value type");
8604 } 8604 }
8605 TypeArguments& type_array = TypeArguments::Handle(TypeArguments::New(2)); 8605 TypeArguments& type_array = TypeArguments::Handle(TypeArguments::New(2));
8606 type_array.SetTypeAt(0, Type::Handle(Type::StringInterface())); 8606 type_array.SetTypeAt(0, Type::Handle(Type::StringType()));
8607 type_array.SetTypeAt(1, value_type); 8607 type_array.SetTypeAt(1, value_type);
8608 map_type_arguments = type_array.raw(); 8608 map_type_arguments = type_array.raw();
8609 } else if (map_type_arguments.Length() > 2) { 8609 } else if (map_type_arguments.Length() > 2) {
8610 ErrorMsg(type_pos, 8610 ErrorMsg(type_pos,
8611 "a map literal takes two type arguments specifying " 8611 "a map literal takes two type arguments specifying "
8612 "the key type and the value type"); 8612 "the key type and the value type");
8613 } else { 8613 } else {
8614 const AbstractType& key_type = 8614 const AbstractType& key_type =
8615 AbstractType::Handle(map_type_arguments.TypeAt(0)); 8615 AbstractType::Handle(map_type_arguments.TypeAt(0));
8616 value_type = map_type_arguments.TypeAt(1); 8616 value_type = map_type_arguments.TypeAt(1);
8617 if (!key_type.IsStringInterface()) { 8617 if (!key_type.IsStringType()) {
8618 ErrorMsg(type_pos, "the key type of a map literal must be 'String'"); 8618 ErrorMsg(type_pos, "the key type of a map literal must be 'String'");
8619 } 8619 }
8620 } 8620 }
8621 if (is_const && !value_type.IsInstantiated()) { 8621 if (is_const && !value_type.IsInstantiated()) {
8622 ErrorMsg(type_pos, 8622 ErrorMsg(type_pos,
8623 "the type argument of a constant map literal cannot include " 8623 "the type argument of a constant map literal cannot include "
8624 "a type variable"); 8624 "a type variable");
8625 } 8625 }
8626 } 8626 }
8627 ASSERT(map_type_arguments.IsNull() || (map_type_arguments.Length() == 2)); 8627 ASSERT(map_type_arguments.IsNull() || (map_type_arguments.Length() == 2));
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
9691 void Parser::SkipQualIdent() { 9691 void Parser::SkipQualIdent() {
9692 ASSERT(IsIdentifier()); 9692 ASSERT(IsIdentifier());
9693 ConsumeToken(); 9693 ConsumeToken();
9694 if (CurrentToken() == Token::kPERIOD) { 9694 if (CurrentToken() == Token::kPERIOD) {
9695 ConsumeToken(); // Consume the kPERIOD token. 9695 ConsumeToken(); // Consume the kPERIOD token.
9696 ExpectIdentifier("identifier expected after '.'"); 9696 ExpectIdentifier("identifier expected after '.'");
9697 } 9697 }
9698 } 9698 }
9699 9699
9700 } // namespace dart 9700 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698