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

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

Issue 9960084: Introduce a flag to disable string operator + (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
« runtime/lib/string.dart ('K') | « runtime/vm/bootstrap_natives.h ('k') | 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 "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"
11 #include "vm/dart_api_impl.h" 11 #include "vm/dart_api_impl.h"
12 #include "vm/dart_entry.h" 12 #include "vm/dart_entry.h"
13 #include "vm/flags.h" 13 #include "vm/flags.h"
14 #include "vm/growable_array.h" 14 #include "vm/growable_array.h"
15 #include "vm/longjump.h" 15 #include "vm/longjump.h"
16 #include "vm/native_entry.h" 16 #include "vm/native_entry.h"
17 #include "vm/object.h" 17 #include "vm/object.h"
18 #include "vm/object_store.h" 18 #include "vm/object_store.h"
19 #include "vm/resolver.h" 19 #include "vm/resolver.h"
20 #include "vm/scopes.h" 20 #include "vm/scopes.h"
21 21
22 namespace dart { 22 namespace dart {
23 23
24 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); 24 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements.");
25 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); 25 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks.");
26 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); 26 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations.");
27 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); 27 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors.");
28 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); 28 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings.");
29 DEFINE_FLAG(bool, allow_string_plus, true, "Allow + operator on strings.");
29 30
30 static void CheckedModeHandler(bool value) { 31 static void CheckedModeHandler(bool value) {
31 FLAG_enable_asserts = value; 32 FLAG_enable_asserts = value;
32 FLAG_enable_type_checks = value; 33 FLAG_enable_type_checks = value;
33 } 34 }
34 35
35 DEFINE_FLAG_HANDLER(CheckedModeHandler, 36 DEFINE_FLAG_HANDLER(CheckedModeHandler,
36 enable_checked_mode, 37 enable_checked_mode,
37 "Enabled checked mode."); 38 "Enabled checked mode.");
38 39
(...skipping 5656 matching lines...) Expand 10 before | Expand all | Expand 10 after
5695 || Token::IsEqualityOperator(op_kind)) { 5696 || Token::IsEqualityOperator(op_kind)) {
5696 left_operand = new ComparisonNode( 5697 left_operand = new ComparisonNode(
5697 op_pos, op_kind, left_operand, right_operand); 5698 op_pos, op_kind, left_operand, right_operand);
5698 break; // Equality and relational operators cannot be chained. 5699 break; // Equality and relational operators cannot be chained.
5699 } else { 5700 } else {
5700 StringConcatNode* str_concat = NULL; 5701 StringConcatNode* str_concat = NULL;
5701 if (op_kind == Token::kADD) { 5702 if (op_kind == Token::kADD) {
5702 if (left_operand->IsLiteralNode()) { 5703 if (left_operand->IsLiteralNode()) {
5703 LiteralNode* lit = left_operand->AsLiteralNode(); 5704 LiteralNode* lit = left_operand->AsLiteralNode();
5704 if (lit->literal().IsString()) { 5705 if (lit->literal().IsString()) {
5705 str_concat = new StringConcatNode(lit->token_index()); 5706 if (FLAG_allow_string_plus) {
5706 str_concat->AddExpr(lit); 5707 str_concat = new StringConcatNode(lit->token_index());
5708 str_concat->AddExpr(lit);
5709 } else {
5710 ErrorMsg(op_pos, "operator + on strings no longer allowed");
5711 }
5707 } 5712 }
5708 } else if (left_operand->IsStringConcatNode()) { 5713 } else if (left_operand->IsStringConcatNode()) {
5709 str_concat = left_operand->AsStringConcatNode(); 5714 str_concat = left_operand->AsStringConcatNode();
5710 } 5715 }
5711 } 5716 }
5712 if (str_concat != NULL) { 5717 if (str_concat != NULL) {
5713 str_concat->AddExpr(right_operand); 5718 str_concat->AddExpr(right_operand);
5714 left_operand = str_concat; 5719 left_operand = str_concat;
5715 } else { 5720 } else {
5716 left_operand = OptimizeBinaryOpNode( 5721 left_operand = OptimizeBinaryOpNode(
(...skipping 2562 matching lines...) Expand 10 before | Expand all | Expand 10 after
8279 void Parser::SkipQualIdent() { 8284 void Parser::SkipQualIdent() {
8280 ASSERT(IsIdentifier()); 8285 ASSERT(IsIdentifier());
8281 ConsumeToken(); 8286 ConsumeToken();
8282 if (CurrentToken() == Token::kPERIOD) { 8287 if (CurrentToken() == Token::kPERIOD) {
8283 ConsumeToken(); // Consume the kPERIOD token. 8288 ConsumeToken(); // Consume the kPERIOD token.
8284 ExpectIdentifier("identifier expected after '.'"); 8289 ExpectIdentifier("identifier expected after '.'");
8285 } 8290 }
8286 } 8291 }
8287 8292
8288 } // namespace dart 8293 } // namespace dart
OLDNEW
« runtime/lib/string.dart ('K') | « runtime/vm/bootstrap_natives.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698