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

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

Issue 851763002: Revert modPow introduction since dart2js does not like it. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 | « runtime/lib/bigint.dart ('k') | sdk/lib/core/int.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 extends _Num { 7 class _IntegerImplementation extends _Num {
8 // The Dart class _Bigint extending _IntegerImplementation requires a 8 // The Dart class _Bigint extending _IntegerImplementation requires a
9 // default constructor. 9 // default constructor.
10 10
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 var mask = radix - 1; 258 var mask = radix - 1;
259 do { 259 do {
260 string._setAt(--length, _digits.codeUnitAt(value & mask)); 260 string._setAt(--length, _digits.codeUnitAt(value & mask));
261 value >>= bitsPerDigit; 261 value >>= bitsPerDigit;
262 } while (value > 0); 262 } while (value > 0);
263 return string; 263 return string;
264 } 264 }
265 265
266 _leftShiftWithMask32(count, mask) native "Integer_leftShiftWithMask32"; 266 _leftShiftWithMask32(count, mask) native "Integer_leftShiftWithMask32";
267 267
268 // TODO(regis): Make this method private once the plumbing to invoke it from
269 // dart:math is in place. Move the argument checking to dart:math.
268 // Return pow(this, e) % m. 270 // Return pow(this, e) % m.
269 int modPow(int e, int m) { 271 int modPow(int e, int m) {
270 if (e is! int) throw new ArgumentError(e); 272 if (e is! int) throw new ArgumentError(e);
271 if (m is! int) throw new ArgumentError(m); 273 if (m is! int) throw new ArgumentError(m);
272 if (e is _Bigint || m is _Bigint) { 274 if (e is _Bigint || m is _Bigint) {
273 return _toBigint().modPow(e, m); 275 return _toBigint().modPow(e, m);
274 } 276 }
275 if (e < 1) return 1; 277 if (e < 1) return 1;
276 int b = this; 278 int b = this;
277 if (b < 0 || b > m) { 279 if (b < 0 || b > m) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // Shift by mint exceeds range that can be handled by the VM. 503 // Shift by mint exceeds range that can be handled by the VM.
502 int _shrFromInt(int other) { 504 int _shrFromInt(int other) {
503 if (other < 0) { 505 if (other < 0) {
504 return -1; 506 return -1;
505 } else { 507 } else {
506 return 0; 508 return 0;
507 } 509 }
508 } 510 }
509 int _shlFromInt(int other) native "Mint_shlFromInt"; 511 int _shlFromInt(int other) native "Mint_shlFromInt";
510 } 512 }
OLDNEW
« no previous file with comments | « runtime/lib/bigint.dart ('k') | sdk/lib/core/int.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698