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

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

Issue 22835005: Fix top-level map literals (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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/language/compile_time_constant_c_test.dart » ('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 "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 9219 matching lines...) Expand 10 before | Expand all | Expand 10 after
9230 arguments); 9230 arguments);
9231 } 9231 }
9232 9232
9233 9233
9234 static void AddKeyValuePair(GrowableArray<AstNode*>* pairs, 9234 static void AddKeyValuePair(GrowableArray<AstNode*>* pairs,
9235 bool is_const, 9235 bool is_const,
9236 AstNode* key, 9236 AstNode* key,
9237 AstNode* value) { 9237 AstNode* value) {
9238 if (is_const) { 9238 if (is_const) {
9239 ASSERT(key->IsLiteralNode()); 9239 ASSERT(key->IsLiteralNode());
9240 ASSERT(key->AsLiteralNode()->literal().IsString());
9241 const Instance& new_key = key->AsLiteralNode()->literal(); 9240 const Instance& new_key = key->AsLiteralNode()->literal();
9242 for (int i = 0; i < pairs->length(); i += 2) { 9241 for (int i = 0; i < pairs->length(); i += 2) {
9243 const Instance& key_i = 9242 const Instance& key_i =
9244 (*pairs)[i]->AsLiteralNode()->literal(); 9243 (*pairs)[i]->AsLiteralNode()->literal();
9245 ASSERT(key_i.IsString()); 9244 ASSERT(key_i.IsString());
9246 if (new_key.Equals(key_i)) { 9245 if (new_key.Equals(key_i)) {
9247 // Duplicate key found. The new value replaces the previously 9246 // Duplicate key found. The new value replaces the previously
9248 // defined value. 9247 // defined value.
9249 (*pairs)[i + 1] = value; 9248 (*pairs)[i + 1] = value;
9250 return; 9249 return;
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
10039 if (CurrentToken() == Token::kINDEX) { 10038 if (CurrentToken() == Token::kINDEX) {
10040 // Empty list literal. 10039 // Empty list literal.
10041 ConsumeToken(); 10040 ConsumeToken();
10042 return; 10041 return;
10043 } 10042 }
10044 ExpectToken(Token::kLBRACK); 10043 ExpectToken(Token::kLBRACK);
10045 while (CurrentToken() != Token::kRBRACK) { 10044 while (CurrentToken() != Token::kRBRACK) {
10046 SkipNestedExpr(); 10045 SkipNestedExpr();
10047 if (CurrentToken() == Token::kCOMMA) { 10046 if (CurrentToken() == Token::kCOMMA) {
10048 ConsumeToken(); 10047 ConsumeToken();
10048 } else {
10049 break;
10049 } 10050 }
10050 } 10051 }
10051 ExpectToken(Token::kRBRACK); 10052 ExpectToken(Token::kRBRACK);
10052 } 10053 }
10053 10054
10054 10055
10055 void Parser::SkipMapLiteral() { 10056 void Parser::SkipMapLiteral() {
10056 ExpectToken(Token::kLBRACE); 10057 ExpectToken(Token::kLBRACE);
10057 while (CurrentToken() == Token::kSTRING) { 10058 while (CurrentToken() != Token::kRBRACE) {
10058 SkipStringLiteral(); 10059 SkipNestedExpr();
10059 ExpectToken(Token::kCOLON); 10060 ExpectToken(Token::kCOLON);
10060 SkipNestedExpr(); 10061 SkipNestedExpr();
10061 if (CurrentToken() == Token::kCOMMA) { 10062 if (CurrentToken() == Token::kCOMMA) {
10062 ConsumeToken(); 10063 ConsumeToken();
10064 } else {
10065 break;
10063 } 10066 }
10064 } 10067 }
10065 ExpectToken(Token::kRBRACE); 10068 ExpectToken(Token::kRBRACE);
10066 } 10069 }
10067 10070
10068 10071
10069 void Parser::SkipActualParameters() { 10072 void Parser::SkipActualParameters() {
10070 ExpectToken(Token::kLPAREN); 10073 ExpectToken(Token::kLPAREN);
10071 while (CurrentToken() != Token::kRPAREN) { 10074 while (CurrentToken() != Token::kRPAREN) {
10072 if (IsIdentifier() && (LookaheadToken(1) == Token::kCOLON)) { 10075 if (IsIdentifier() && (LookaheadToken(1) == Token::kCOLON)) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
10288 void Parser::SkipQualIdent() { 10291 void Parser::SkipQualIdent() {
10289 ASSERT(IsIdentifier()); 10292 ASSERT(IsIdentifier());
10290 ConsumeToken(); 10293 ConsumeToken();
10291 if (CurrentToken() == Token::kPERIOD) { 10294 if (CurrentToken() == Token::kPERIOD) {
10292 ConsumeToken(); // Consume the kPERIOD token. 10295 ConsumeToken(); // Consume the kPERIOD token.
10293 ExpectIdentifier("identifier expected after '.'"); 10296 ExpectIdentifier("identifier expected after '.'");
10294 } 10297 }
10295 } 10298 }
10296 10299
10297 } // namespace dart 10300 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/compile_time_constant_c_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698