| OLD | NEW |
| 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, false, "Allow + operator on strings."); | |
| 30 | 29 |
| 31 static void CheckedModeHandler(bool value) { | 30 static void CheckedModeHandler(bool value) { |
| 32 FLAG_enable_asserts = value; | 31 FLAG_enable_asserts = value; |
| 33 FLAG_enable_type_checks = value; | 32 FLAG_enable_type_checks = value; |
| 34 } | 33 } |
| 35 | 34 |
| 36 DEFINE_FLAG_HANDLER(CheckedModeHandler, | 35 DEFINE_FLAG_HANDLER(CheckedModeHandler, |
| 37 enable_checked_mode, | 36 enable_checked_mode, |
| 38 "Enabled checked mode."); | 37 "Enabled checked mode."); |
| 39 | 38 |
| (...skipping 5891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5931 || Token::IsEqualityOperator(op_kind)) { | 5930 || Token::IsEqualityOperator(op_kind)) { |
| 5932 if (Token::IsInstanceofOperator(op_kind)) { | 5931 if (Token::IsInstanceofOperator(op_kind)) { |
| 5933 if (!right_operand->AsTypeNode()->type().IsInstantiated()) { | 5932 if (!right_operand->AsTypeNode()->type().IsInstantiated()) { |
| 5934 EnsureExpressionTemp(); | 5933 EnsureExpressionTemp(); |
| 5935 } | 5934 } |
| 5936 } | 5935 } |
| 5937 left_operand = new ComparisonNode( | 5936 left_operand = new ComparisonNode( |
| 5938 op_pos, op_kind, left_operand, right_operand); | 5937 op_pos, op_kind, left_operand, right_operand); |
| 5939 break; // Equality and relational operators cannot be chained. | 5938 break; // Equality and relational operators cannot be chained. |
| 5940 } else { | 5939 } else { |
| 5941 StringConcatNode* str_concat = NULL; | 5940 left_operand = OptimizeBinaryOpNode( |
| 5942 if (op_kind == Token::kADD) { | 5941 op_pos, op_kind, left_operand, right_operand); |
| 5943 if (left_operand->IsLiteralNode()) { | |
| 5944 LiteralNode* lit = left_operand->AsLiteralNode(); | |
| 5945 if (lit->literal().IsString()) { | |
| 5946 if (FLAG_allow_string_plus) { | |
| 5947 str_concat = new StringConcatNode(lit->token_index()); | |
| 5948 str_concat->AddExpr(lit); | |
| 5949 } else { | |
| 5950 ErrorMsg(op_pos, "operator + on strings no longer allowed"); | |
| 5951 } | |
| 5952 } | |
| 5953 } else if (left_operand->IsStringConcatNode()) { | |
| 5954 str_concat = left_operand->AsStringConcatNode(); | |
| 5955 } | |
| 5956 } | |
| 5957 if (str_concat != NULL) { | |
| 5958 str_concat->AddExpr(right_operand); | |
| 5959 left_operand = str_concat; | |
| 5960 } else { | |
| 5961 left_operand = OptimizeBinaryOpNode( | |
| 5962 op_pos, op_kind, left_operand, right_operand); | |
| 5963 } | |
| 5964 } | 5942 } |
| 5965 } | 5943 } |
| 5966 current_preced--; | 5944 current_preced--; |
| 5967 } | 5945 } |
| 5968 return left_operand; | 5946 return left_operand; |
| 5969 } | 5947 } |
| 5970 | 5948 |
| 5971 | 5949 |
| 5972 bool Parser::IsAssignableExpr(AstNode* expr) { | 5950 bool Parser::IsAssignableExpr(AstNode* expr) { |
| 5973 return expr->IsPrimaryNode() | 5951 return expr->IsPrimaryNode() |
| (...skipping 2613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8587 void Parser::SkipQualIdent() { | 8565 void Parser::SkipQualIdent() { |
| 8588 ASSERT(IsIdentifier()); | 8566 ASSERT(IsIdentifier()); |
| 8589 ConsumeToken(); | 8567 ConsumeToken(); |
| 8590 if (CurrentToken() == Token::kPERIOD) { | 8568 if (CurrentToken() == Token::kPERIOD) { |
| 8591 ConsumeToken(); // Consume the kPERIOD token. | 8569 ConsumeToken(); // Consume the kPERIOD token. |
| 8592 ExpectIdentifier("identifier expected after '.'"); | 8570 ExpectIdentifier("identifier expected after '.'"); |
| 8593 } | 8571 } |
| 8594 } | 8572 } |
| 8595 | 8573 |
| 8596 } // namespace dart | 8574 } // namespace dart |
| OLD | NEW |