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

Side by Side Diff: vm/parser.cc

Issue 8963001: Add Double::NewCanonical and Mint::NewCanonical so that it is possible to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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 | « vm/object_test.cc ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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"
(...skipping 5489 matching lines...) Expand 10 before | Expand all | Expand 10 after
5500 LiteralNode* rhs_literal = rhs->AsLiteralNode(); 5500 LiteralNode* rhs_literal = rhs->AsLiteralNode();
5501 if ((lhs_literal != NULL) && (rhs_literal != NULL)) { 5501 if ((lhs_literal != NULL) && (rhs_literal != NULL)) {
5502 if (lhs_literal->literal().IsDouble() && 5502 if (lhs_literal->literal().IsDouble() &&
5503 rhs_literal->literal().IsDouble()) { 5503 rhs_literal->literal().IsDouble()) {
5504 Double& dbl_obj = Double::ZoneHandle(); 5504 Double& dbl_obj = Double::ZoneHandle();
5505 dbl_obj ^= lhs_literal->literal().raw(); 5505 dbl_obj ^= lhs_literal->literal().raw();
5506 double left_double = dbl_obj.value(); 5506 double left_double = dbl_obj.value();
5507 dbl_obj ^= rhs_literal->literal().raw(); 5507 dbl_obj ^= rhs_literal->literal().raw();
5508 double right_double = dbl_obj.value(); 5508 double right_double = dbl_obj.value();
5509 if (binary_op == Token::kDIV) { 5509 if (binary_op == Token::kDIV) {
5510 dbl_obj = Double::New(left_double / right_double, Heap::kOld); 5510 dbl_obj = Double::NewCanonical((left_double / right_double));
5511 dbl_obj ^= dbl_obj.Canonicalize();
5512 return new LiteralNode(op_pos, dbl_obj); 5511 return new LiteralNode(op_pos, dbl_obj);
5513 } 5512 }
5514 } 5513 }
5515 } 5514 }
5516 return new BinaryOpNode(op_pos, binary_op, lhs, rhs); 5515 return new BinaryOpNode(op_pos, binary_op, lhs, rhs);
5517 } 5516 }
5518 5517
5519 5518
5520 AstNode* Parser::ExpandAssignableOp(intptr_t op_pos, 5519 AstNode* Parser::ExpandAssignableOp(intptr_t op_pos,
5521 Token::Kind assignment_op, 5520 Token::Kind assignment_op,
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
7375 ConsumeToken(); 7374 ConsumeToken();
7376 const bool saved_mode = SetAllowFunctionLiterals(true); 7375 const bool saved_mode = SetAllowFunctionLiterals(true);
7377 primary = ParseExpr(kAllowConst); 7376 primary = ParseExpr(kAllowConst);
7378 SetAllowFunctionLiterals(saved_mode); 7377 SetAllowFunctionLiterals(saved_mode);
7379 ExpectToken(Token::kRPAREN); 7378 ExpectToken(Token::kRPAREN);
7380 } else if (CurrentToken() == Token::kDOUBLE) { 7379 } else if (CurrentToken() == Token::kDOUBLE) {
7381 String* double_literal = CurrentLiteral(); 7380 String* double_literal = CurrentLiteral();
7382 ASSERT(double_literal != NULL); 7381 ASSERT(double_literal != NULL);
7383 ASSERT(double_literal->Length() > 0); 7382 ASSERT(double_literal->Length() > 0);
7384 Double& double_value = 7383 Double& double_value =
7385 Double::ZoneHandle(Double::New(*double_literal, Heap::kOld)); 7384 Double::ZoneHandle(Double::NewCanonical(*double_literal));
7386 if (double_value.IsNull()) { 7385 if (double_value.IsNull()) {
7387 ErrorMsg("invalid double literal"); 7386 ErrorMsg("invalid double literal");
7388 } 7387 }
7389 double_value ^= double_value.Canonicalize();
7390 primary = new LiteralNode(token_index_, double_value); 7388 primary = new LiteralNode(token_index_, double_value);
7391 ConsumeToken(); 7389 ConsumeToken();
7392 } else if (CurrentToken() == Token::kSTRING) { 7390 } else if (CurrentToken() == Token::kSTRING) {
7393 primary = ParseStringLiteral(); 7391 primary = ParseStringLiteral();
7394 } else if (CurrentToken() == Token::kNEW) { 7392 } else if (CurrentToken() == Token::kNEW) {
7395 primary = ParseNewOperator(); 7393 primary = ParseNewOperator();
7396 } else if (CurrentToken() == Token::kCONST) { 7394 } else if (CurrentToken() == Token::kCONST) {
7397 if ((LookaheadToken(1) == Token::kLT) || 7395 if ((LookaheadToken(1) == Token::kLT) ||
7398 (LookaheadToken(1) == Token::kLBRACK) || 7396 (LookaheadToken(1) == Token::kLBRACK) ||
7399 (LookaheadToken(1) == Token::kINDEX) || 7397 (LookaheadToken(1) == Token::kINDEX) ||
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
7687 } 7685 }
7688 7686
7689 7687
7690 void Parser::SkipNestedExpr() { 7688 void Parser::SkipNestedExpr() {
7691 const bool saved_mode = SetAllowFunctionLiterals(true); 7689 const bool saved_mode = SetAllowFunctionLiterals(true);
7692 SkipExpr(); 7690 SkipExpr();
7693 SetAllowFunctionLiterals(saved_mode); 7691 SetAllowFunctionLiterals(saved_mode);
7694 } 7692 }
7695 7693
7696 } // namespace dart 7694 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698