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

Side by Side Diff: vm/ast.cc

Issue 12038051: Use Double::NewCanonical instead of creating a double object and then canonicalizing it. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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) 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/ast.h" 5 #include "vm/ast.h"
6 #include "vm/compiler.h" 6 #include "vm/compiler.h"
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/resolver.h" 10 #include "vm/resolver.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if (literal().IsSmi()) { 86 if (literal().IsSmi()) {
87 const Smi& smi = Smi::Cast(literal()); 87 const Smi& smi = Smi::Cast(literal());
88 const Instance& literal = 88 const Instance& literal =
89 Instance::ZoneHandle(Integer::New(-smi.Value())); 89 Instance::ZoneHandle(Integer::New(-smi.Value()));
90 return new LiteralNode(this->token_pos(), literal); 90 return new LiteralNode(this->token_pos(), literal);
91 } 91 }
92 if (literal().IsDouble()) { 92 if (literal().IsDouble()) {
93 const Double& dbl = Double::Cast(literal()); 93 const Double& dbl = Double::Cast(literal());
94 // Preserve negative zero. 94 // Preserve negative zero.
95 double new_value = (dbl.value() == 0.0) ? -0.0 : (0.0 - dbl.value()); 95 double new_value = (dbl.value() == 0.0) ? -0.0 : (0.0 - dbl.value());
96 Double& double_instance = 96 const Double& double_instance =
97 Double::ZoneHandle(Double::New(new_value, Heap::kOld)); 97 Double::ZoneHandle(Double::NewCanonical(new_value));
98 double_instance ^= double_instance.Canonicalize();
99 return new LiteralNode(this->token_pos(), double_instance); 98 return new LiteralNode(this->token_pos(), double_instance);
100 } 99 }
101 } 100 }
102 return NULL; 101 return NULL;
103 } 102 }
104 103
105 104
106 bool ComparisonNode::IsKindValid() const { 105 bool ComparisonNode::IsKindValid() const {
107 return Token::IsRelationalOperator(kind_) 106 return Token::IsRelationalOperator(kind_)
108 || Token::IsEqualityOperator(kind_) 107 || Token::IsEqualityOperator(kind_)
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 if (result.IsError() || result.IsNull()) { 433 if (result.IsError() || result.IsNull()) {
435 // TODO(turnidge): We could get better error messages by returning 434 // TODO(turnidge): We could get better error messages by returning
436 // the Error object directly to the parser. This will involve 435 // the Error object directly to the parser. This will involve
437 // replumbing all of the EvalConstExpr methods. 436 // replumbing all of the EvalConstExpr methods.
438 return NULL; 437 return NULL;
439 } 438 }
440 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 439 return &Instance::ZoneHandle(Instance::Cast(result).raw());
441 } 440 }
442 441
443 } // namespace dart 442 } // 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