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

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

Issue 26726004: Optimize away empty string sections in string interpolation (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « no previous file | no next file » | 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 3377 matching lines...) Expand 10 before | Expand all | Expand 10 after
3388 current_class(), 3388 current_class(),
3389 field->name_pos); 3389 field->name_pos);
3390 class_field.set_type(*field->type); 3390 class_field.set_type(*field->type);
3391 class_field.set_has_initializer(has_initializer); 3391 class_field.set_has_initializer(has_initializer);
3392 members->AddField(class_field); 3392 members->AddField(class_field);
3393 if (field->metadata_pos >= 0) { 3393 if (field->metadata_pos >= 0) {
3394 library_.AddFieldMetadata(class_field, field->metadata_pos); 3394 library_.AddFieldMetadata(class_field, field->metadata_pos);
3395 } 3395 }
3396 3396
3397 // For static final fields (this includes static const fields), set value to 3397 // For static final fields (this includes static const fields), set value to
3398 // "uninitialized" and create a kFinalImplicitGetter getter method. 3398 // "uninitialized" and create a kImplicitStaticFinalGetter getter method.
3399 if (field->has_static && has_initializer) { 3399 if (field->has_static && has_initializer) {
3400 class_field.set_value(init_value); 3400 class_field.set_value(init_value);
3401 if (!has_simple_literal) { 3401 if (!has_simple_literal) {
3402 String& getter_name = String::Handle(Field::GetterSymbol(*field->name)); 3402 String& getter_name = String::Handle(Field::GetterSymbol(*field->name));
3403 getter = Function::New(getter_name, 3403 getter = Function::New(getter_name,
3404 RawFunction::kImplicitStaticFinalGetter, 3404 RawFunction::kImplicitStaticFinalGetter,
3405 field->has_static, 3405 field->has_static,
3406 field->has_const, 3406 field->has_const,
3407 /* is_abstract = */ false, 3407 /* is_abstract = */ false,
3408 /* is_external = */ false, 3408 /* is_external = */ false,
(...skipping 6629 matching lines...) Expand 10 before | Expand all | Expand 10 after
10038 (l1_token != Token::kINTERPOL_START)) { 10038 (l1_token != Token::kINTERPOL_START)) {
10039 // Common case: no interpolation. 10039 // Common case: no interpolation.
10040 primary = new LiteralNode(literal_start, *CurrentLiteral()); 10040 primary = new LiteralNode(literal_start, *CurrentLiteral());
10041 ConsumeToken(); 10041 ConsumeToken();
10042 return primary; 10042 return primary;
10043 } 10043 }
10044 // String interpolation needed. 10044 // String interpolation needed.
10045 bool is_compiletime_const = true; 10045 bool is_compiletime_const = true;
10046 GrowableArray<AstNode*> values_list; 10046 GrowableArray<AstNode*> values_list;
10047 while (CurrentToken() == Token::kSTRING) { 10047 while (CurrentToken() == Token::kSTRING) {
10048 values_list.Add(new LiteralNode(TokenPos(), *CurrentLiteral())); 10048 if (CurrentLiteral()->Length() > 0) {
10049 // Only add non-empty string sections to the values list
10050 // that will be concatenated.
10051 values_list.Add(new LiteralNode(TokenPos(), *CurrentLiteral()));
10052 }
10049 ConsumeToken(); 10053 ConsumeToken();
10050 while ((CurrentToken() == Token::kINTERPOL_VAR) || 10054 while ((CurrentToken() == Token::kINTERPOL_VAR) ||
10051 (CurrentToken() == Token::kINTERPOL_START)) { 10055 (CurrentToken() == Token::kINTERPOL_START)) {
10052 AstNode* expr = NULL; 10056 AstNode* expr = NULL;
10053 const intptr_t expr_pos = TokenPos(); 10057 const intptr_t expr_pos = TokenPos();
10054 if (CurrentToken() == Token::kINTERPOL_VAR) { 10058 if (CurrentToken() == Token::kINTERPOL_VAR) {
10055 expr = ResolveIdent(TokenPos(), *CurrentLiteral(), true); 10059 expr = ResolveIdent(TokenPos(), *CurrentLiteral(), true);
10056 ConsumeToken(); 10060 ConsumeToken();
10057 } else { 10061 } else {
10058 ASSERT(CurrentToken() == Token::kINTERPOL_START); 10062 ASSERT(CurrentToken() == Token::kINTERPOL_START);
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
10615 void Parser::SkipQualIdent() { 10619 void Parser::SkipQualIdent() {
10616 ASSERT(IsIdentifier()); 10620 ASSERT(IsIdentifier());
10617 ConsumeToken(); 10621 ConsumeToken();
10618 if (CurrentToken() == Token::kPERIOD) { 10622 if (CurrentToken() == Token::kPERIOD) {
10619 ConsumeToken(); // Consume the kPERIOD token. 10623 ConsumeToken(); // Consume the kPERIOD token.
10620 ExpectIdentifier("identifier expected after '.'"); 10624 ExpectIdentifier("identifier expected after '.'");
10621 } 10625 }
10622 } 10626 }
10623 10627
10624 } // namespace dart 10628 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698