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

Side by Side Diff: runtime/lib/integers.dart

Issue 24280003: Add Object.hashCodeOf to get the default hashCode of an object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Now top-level and called identityHashCode Created 7 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
« no previous file with comments | « runtime/lib/identical_patch.dart ('k') | runtime/lib/null_patch.dart » ('j') | 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) 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 // TODO(srdjan): fix limitations. 5 // TODO(srdjan): fix limitations.
6 // - shift amount must be a Smi. 6 // - shift amount must be a Smi.
7 class _IntegerImplementation { 7 class _IntegerImplementation {
8 factory _IntegerImplementation._uninstantiable() { 8 factory _IntegerImplementation._uninstantiable() {
9 throw new UnsupportedError( 9 throw new UnsupportedError(
10 "_IntegerImplementation can only be allocated by the VM"); 10 "_IntegerImplementation can only be allocated by the VM");
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 216
217 _leftShiftWithMask32(count, mask) native "Integer_leftShiftWithMask32"; 217 _leftShiftWithMask32(count, mask) native "Integer_leftShiftWithMask32";
218 } 218 }
219 219
220 class _Smi extends _IntegerImplementation implements int { 220 class _Smi extends _IntegerImplementation implements int {
221 factory _Smi._uninstantiable() { 221 factory _Smi._uninstantiable() {
222 throw new UnsupportedError( 222 throw new UnsupportedError(
223 "_Smi can only be allocated by the VM"); 223 "_Smi can only be allocated by the VM");
224 } 224 }
225 int get hashCode { 225 int get _identityHashCode {
226 return this; 226 return this;
227 } 227 }
228 int operator ~() native "Smi_bitNegate"; 228 int operator ~() native "Smi_bitNegate";
229 int get bitLength native "Smi_bitLength"; 229 int get bitLength native "Smi_bitLength";
230 230
231 int _shrFromInt(int other) native "Smi_shrFromInt"; 231 int _shrFromInt(int other) native "Smi_shrFromInt";
232 int _shlFromInt(int other) native "Smi_shlFromInt"; 232 int _shlFromInt(int other) native "Smi_shlFromInt";
233 233
234 String toString() { 234 String toString() {
235 if (this == 0) return "0"; 235 if (this == 0) return "0";
(...skipping 28 matching lines...) Expand all
264 264
265 // Reusable buffer used by smi.toString. 265 // Reusable buffer used by smi.toString.
266 List _toStringBuffer = new Uint8List(20); 266 List _toStringBuffer = new Uint8List(20);
267 267
268 // Represents integers that cannot be represented by Smi but fit into 64bits. 268 // Represents integers that cannot be represented by Smi but fit into 64bits.
269 class _Mint extends _IntegerImplementation implements int { 269 class _Mint extends _IntegerImplementation implements int {
270 factory _Mint._uninstantiable() { 270 factory _Mint._uninstantiable() {
271 throw new UnsupportedError( 271 throw new UnsupportedError(
272 "_Mint can only be allocated by the VM"); 272 "_Mint can only be allocated by the VM");
273 } 273 }
274 int get hashCode { 274 int get _identityHashCode {
275 return this; 275 return this;
276 } 276 }
277 int operator ~() native "Mint_bitNegate"; 277 int operator ~() native "Mint_bitNegate";
278 int get bitLength native "Mint_bitLength"; 278 int get bitLength native "Mint_bitLength";
279 279
280 // Shift by mint exceeds range that can be handled by the VM. 280 // Shift by mint exceeds range that can be handled by the VM.
281 int _shrFromInt(int other) { 281 int _shrFromInt(int other) {
282 if (other < 0) { 282 if (other < 0) {
283 return -1; 283 return -1;
284 } else { 284 } else {
285 return 0; 285 return 0;
286 } 286 }
287 } 287 }
288 int _shlFromInt(int other) native "Mint_shlFromInt"; 288 int _shlFromInt(int other) native "Mint_shlFromInt";
289 } 289 }
290 290
291 // A number that can be represented as Smi or Mint will never be represented as 291 // A number that can be represented as Smi or Mint will never be represented as
292 // Bigint. 292 // Bigint.
293 class _Bigint extends _IntegerImplementation implements int { 293 class _Bigint extends _IntegerImplementation implements int {
294 factory _Bigint._uninstantiable() { 294 factory _Bigint._uninstantiable() {
295 throw new UnsupportedError( 295 throw new UnsupportedError(
296 "_Bigint can only be allocated by the VM"); 296 "_Bigint can only be allocated by the VM");
297 } 297 }
298 int get hashCode { 298 int get _identityHashCode {
299 return this; 299 return this;
300 } 300 }
301 int operator ~() native "Bigint_bitNegate"; 301 int operator ~() native "Bigint_bitNegate";
302 int get bitLength native "Bigint_bitLength"; 302 int get bitLength native "Bigint_bitLength";
303 303
304 // Shift by bigint exceeds range that can be handled by the VM. 304 // Shift by bigint exceeds range that can be handled by the VM.
305 int _shrFromInt(int other) { 305 int _shrFromInt(int other) {
306 if (other < 0) { 306 if (other < 0) {
307 return -1; 307 return -1;
308 } else { 308 } else {
309 return 0; 309 return 0;
310 } 310 }
311 } 311 }
312 int _shlFromInt(int other) native "Bigint_shlFromInt"; 312 int _shlFromInt(int other) native "Bigint_shlFromInt";
313 313
314 int pow(int exponent) { 314 int pow(int exponent) {
315 throw "Bigint.pow not implemented"; 315 throw "Bigint.pow not implemented";
316 } 316 }
317 } 317 }
OLDNEW
« no previous file with comments | « runtime/lib/identical_patch.dart ('k') | runtime/lib/null_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698