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

Side by Side Diff: compiler/lib/implementation/number.dart

Issue 8286001: Changes "is" and equality checks to strictly check for primitive types, fix a couple of (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 2 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
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 class NumberImplementation implements int, double native "Number" { 5 class NumberImplementation implements int, double native "Number" {
6 NumberImplementation operator +(NumberImplementation other) native; 6 NumberImplementation operator +(NumberImplementation other) native;
7 NumberImplementation operator -(NumberImplementation other) native; 7 NumberImplementation operator -(NumberImplementation other) native;
8 NumberImplementation operator *(NumberImplementation other) native; 8 NumberImplementation operator *(NumberImplementation other) native;
9 NumberImplementation operator /(NumberImplementation other) native; 9 NumberImplementation operator /(NumberImplementation other) native;
10 NumberImplementation operator ~/(NumberImplementation other) native; 10 NumberImplementation operator ~/(NumberImplementation other) native;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 int toInt() { 48 int toInt() {
49 if (isNaN()) throw new BadNumberFormatException("NaN"); 49 if (isNaN()) throw new BadNumberFormatException("NaN");
50 if (isInfinite()) throw new BadNumberFormatException("Infinity"); 50 if (isInfinite()) throw new BadNumberFormatException("Infinity");
51 NumberImplementation truncated = truncate(); 51 NumberImplementation truncated = truncate();
52 // If truncated is -0.0 return +0. The test will also trigger for positive 52 // If truncated is -0.0 return +0. The test will also trigger for positive
53 // 0s but that's not a problem. 53 // 0s but that's not a problem.
54 if (truncated == -0.0) return 0; 54 if (truncated == -0.0) return 0;
55 return truncated; 55 return truncated;
56 } 56 }
57 57
58 NumberImplementation toDouble() { return this; } 58 NumberImplementation toDouble() native;
59
60 String toString() native; 59 String toString() native;
61 String toStringAsFixed(int fractionDigits) native; 60 String toStringAsFixed(int fractionDigits) native;
62 String toStringAsExponential(int fractionDigits) native; 61 String toStringAsExponential(int fractionDigits) native;
63 String toStringAsPrecision(int precision) native; 62 String toStringAsPrecision(int precision) native;
64 String toRadixString(int radix) native; 63 String toRadixString(int radix) native;
65 64
66 int hashCode() native; 65 int hashCode() native;
66 get dynamic() { return toDouble(); }
67 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698