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

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

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 5
6 6
7 function native_NumberImplementation_BIT_OR(other) { 7 function native_NumberImplementation_BIT_OR(other) {
8 return this | other; 8 return this | other;
9 } 9 }
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 function native_NumberImplementation_LTE(other) { 78 function native_NumberImplementation_LTE(other) {
79 return this <= other; 79 return this <= other;
80 } 80 }
81 81
82 function native_NumberImplementation_GTE(other) { 82 function native_NumberImplementation_GTE(other) {
83 return this >= other; 83 return this >= other;
84 } 84 }
85 85
86 function native_NumberImplementation_EQ(other) { 86 function native_NumberImplementation_EQ(other) {
87 if (typeof other == 'number') { 87 return typeof other == 'number' && this == other;
floitsch 2011/10/14 20:20:44 Same as for booleans: operator$EQ should intercept
John Lenz 2011/10/14 21:26:40 It is already special cased in EQ$operator, but I'
88 return this == other;
89 } else if (other instanceof Number) {
90 // Must convert other to a primitive for value equality to work
91 return this == Number(other);
92 } else {
93 return false;
94 }
95 } 88 }
96 89
97 function native_NumberImplementation_BIT_NOT() { 90 function native_NumberImplementation_BIT_NOT() {
98 return ~this; 91 return ~this;
99 } 92 }
100 93
101 function native_NumberImplementation_negate() { return -this; } 94 function native_NumberImplementation_negate() { return -this; }
102 95
103 function native_NumberImplementation_remainder(other) { 96 function native_NumberImplementation_remainder(other) {
104 return this % other; 97 return this % other;
(...skipping 12 matching lines...) Expand all
117 if (this == 0) return (1 / this) < 0; 110 if (this == 0) return (1 / this) < 0;
118 return this < 0; 111 return this < 0;
119 } 112 }
120 function native_NumberImplementation_isEven() { return ((this & 1) == 0); } 113 function native_NumberImplementation_isEven() { return ((this & 1) == 0); }
121 function native_NumberImplementation_isOdd() { return ((this & 1) == 1); } 114 function native_NumberImplementation_isOdd() { return ((this & 1) == 1); }
122 function native_NumberImplementation_isNaN() { return isNaN(this); } 115 function native_NumberImplementation_isNaN() { return isNaN(this); }
123 function native_NumberImplementation_isInfinite() { 116 function native_NumberImplementation_isInfinite() {
124 return (this == Infinity) || (this == -Infinity); 117 return (this == Infinity) || (this == -Infinity);
125 } 118 }
126 119
120 function native_NumberImplementation_toDouble() {
121 return this.valueOf();
122 }
123
127 function native_NumberImplementation_toString() { 124 function native_NumberImplementation_toString() {
128 return this.toString(); 125 return this.toString();
129 } 126 }
130 function native_NumberImplementation_toStringAsFixed(fractionDigits) { 127 function native_NumberImplementation_toStringAsFixed(fractionDigits) {
131 return this.toFixed(fractionDigits); 128 return this.toFixed(fractionDigits);
132 } 129 }
133 function native_NumberImplementation_toStringAsPrecision(precision) { 130 function native_NumberImplementation_toStringAsPrecision(precision) {
134 return this.toPrecision(precision); 131 return this.toPrecision(precision);
135 } 132 }
136 function native_NumberImplementation_toStringAsExponential(fractionDigits) { 133 function native_NumberImplementation_toStringAsExponential(fractionDigits) {
137 return this.toExponential(fractionDigits); 134 return this.toExponential(fractionDigits);
138 } 135 }
139 function native_NumberImplementation_toRadixString(radix) { 136 function native_NumberImplementation_toRadixString(radix) {
140 return this.toString(radix); 137 return this.toString(radix);
141 } 138 }
142 139
143 function native_NumberImplementation_hashCode() { 140 function native_NumberImplementation_hashCode() {
144 return this & 0xFFFFFFF; 141 return this & 0xFFFFFFF;
145 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698