| 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 "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 7272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7283 if (binary_op == Token::kDIV) { | 7283 if (binary_op == Token::kDIV) { |
| 7284 const Double& dbl_obj = Double::ZoneHandle( | 7284 const Double& dbl_obj = Double::ZoneHandle( |
| 7285 Double::NewCanonical((left_double / right_double))); | 7285 Double::NewCanonical((left_double / right_double))); |
| 7286 return new LiteralNode(op_pos, dbl_obj); | 7286 return new LiteralNode(op_pos, dbl_obj); |
| 7287 } | 7287 } |
| 7288 } | 7288 } |
| 7289 } | 7289 } |
| 7290 if ((binary_op == Token::kAND) || (binary_op == Token::kOR)) { | 7290 if ((binary_op == Token::kAND) || (binary_op == Token::kOR)) { |
| 7291 EnsureExpressionTemp(); | 7291 EnsureExpressionTemp(); |
| 7292 } | 7292 } |
| 7293 if (binary_op == Token::kBIT_AND) { |
| 7294 // Normalize so that rhs is a literal if any is. |
| 7295 if ((rhs_literal == NULL) && (lhs_literal != NULL)) { |
| 7296 // Swap. |
| 7297 LiteralNode* temp = rhs_literal; |
| 7298 rhs_literal = lhs_literal; |
| 7299 lhs_literal = temp; |
| 7300 } |
| 7301 if ((rhs_literal != NULL) && |
| 7302 (rhs_literal->literal().IsSmi() || rhs_literal->literal().IsMint())) { |
| 7303 const int64_t val = Integer::Cast(rhs_literal->literal()).AsInt64Value(); |
| 7304 if ((0 <= val) && (Utils::IsUint(32, val))) { |
| 7305 if (lhs->IsBinaryOpNode() && |
| 7306 (lhs->AsBinaryOpNode()->kind() == Token::kSHL)) { |
| 7307 // Merge SHL and BIT_AND into one "SHL with mask" node. |
| 7308 BinaryOpNode* old = lhs->AsBinaryOpNode(); |
| 7309 BinaryOpWithMask32Node* binop = new BinaryOpWithMask32Node( |
| 7310 old->token_pos(), old->kind(), old->left(), old->right(), val); |
| 7311 return binop; |
| 7312 } |
| 7313 } |
| 7314 } |
| 7315 } |
| 7293 return new BinaryOpNode(op_pos, binary_op, lhs, rhs); | 7316 return new BinaryOpNode(op_pos, binary_op, lhs, rhs); |
| 7294 } | 7317 } |
| 7295 | 7318 |
| 7296 | 7319 |
| 7297 AstNode* Parser::ExpandAssignableOp(intptr_t op_pos, | 7320 AstNode* Parser::ExpandAssignableOp(intptr_t op_pos, |
| 7298 Token::Kind assignment_op, | 7321 Token::Kind assignment_op, |
| 7299 AstNode* lhs, | 7322 AstNode* lhs, |
| 7300 AstNode* rhs) { | 7323 AstNode* rhs) { |
| 7301 TRACE_PARSER("ExpandAssignableOp"); | 7324 TRACE_PARSER("ExpandAssignableOp"); |
| 7302 switch (assignment_op) { | 7325 switch (assignment_op) { |
| (...skipping 3017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10320 void Parser::SkipQualIdent() { | 10343 void Parser::SkipQualIdent() { |
| 10321 ASSERT(IsIdentifier()); | 10344 ASSERT(IsIdentifier()); |
| 10322 ConsumeToken(); | 10345 ConsumeToken(); |
| 10323 if (CurrentToken() == Token::kPERIOD) { | 10346 if (CurrentToken() == Token::kPERIOD) { |
| 10324 ConsumeToken(); // Consume the kPERIOD token. | 10347 ConsumeToken(); // Consume the kPERIOD token. |
| 10325 ExpectIdentifier("identifier expected after '.'"); | 10348 ExpectIdentifier("identifier expected after '.'"); |
| 10326 } | 10349 } |
| 10327 } | 10350 } |
| 10328 | 10351 |
| 10329 } // namespace dart | 10352 } // namespace dart |
| OLD | NEW |