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

Side by Side Diff: lib/fixnum/int64.dart

Issue 10595002: Protocol Buffer runtime library and 'protoc' plugin (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Work around http://code.google.com/p/dart/issues/detail?id=3806 Created 8 years, 5 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 | « lib/fixnum/int32.dart ('k') | lib/protobuf/plugin/CodeGenerator.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 /** 5 /**
6 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 1]. 6 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 1].
7 * Arithmetic operations may overflow in order to maintain this range. 7 * Arithmetic operations may overflow in order to maintain this range.
8 */ 8 */
9 class int64 implements intx { 9 class int64 implements intx {
10 10
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 _l = bottom & _MASK; 236 _l = bottom & _MASK;
237 _m = ((top & 0xfff) << 10) | ((bottom >> _BITS) & 0x3ff); 237 _m = ((top & 0xfff) << 10) | ((bottom >> _BITS) & 0x3ff);
238 _h = (top >> 12) & _MASK_2; 238 _h = (top >> 12) & _MASK_2;
239 } 239 }
240 240
241 int64 _promote(other) { 241 int64 _promote(other) {
242 if (other == null) { 242 if (other == null) {
243 throw new NullPointerException(); 243 throw new NullPointerException();
244 } else if (other is intx) { 244 } else if (other is intx) {
245 other = other.toInt64(); 245 other = other.toInt64();
246 } else if (other is int) { 246 } else if (other is num) {
247 other = new int64.fromInt(other); 247 other = new int64.fromInt(other.toInt());
248 } 248 }
249 if (other is !int64) { 249 if (other is !int64) {
250 throw new Exception("Can't promote $other to int64"); 250 throw new Exception("Can't promote $other to int64");
251 } 251 }
252 return other; 252 return other;
253 } 253 }
254 254
255 int64 operator +(other) { 255 int64 operator +(other) {
256 int64 o = _promote(other); 256 int64 o = _promote(other);
257 int sum0 = _l + o._l; 257 int sum0 = _l + o._l;
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 } 1086 }
1087 } 1087 }
1088 return ZERO; 1088 return ZERO;
1089 } 1089 }
1090 1090
1091 // Generate the quotient using bit-at-a-time long division. 1091 // Generate the quotient using bit-at-a-time long division.
1092 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative, 1092 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative,
1093 aIsNegative, aIsMinValue, computeRemainder); 1093 aIsNegative, aIsMinValue, computeRemainder);
1094 } 1094 }
1095 } 1095 }
OLDNEW
« no previous file with comments | « lib/fixnum/int32.dart ('k') | lib/protobuf/plugin/CodeGenerator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698