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

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

Issue 10912066: Don't throw on 1 ~/ 0.0. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « no previous file | no next file » | 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 const UnsupportedOperationException( 9 throw const UnsupportedOperationException(
10 "IntegerImplementation can only be allocated by the VM"); 10 "IntegerImplementation can only be allocated by the VM");
11 } 11 }
12 num operator +(num other) { 12 num operator +(num other) {
13 return other.addFromInteger(this); 13 return other.addFromInteger(this);
14 } 14 }
15 num operator -(num other) { 15 num operator -(num other) {
16 return other.subFromInteger(this); 16 return other.subFromInteger(this);
17 } 17 }
18 num operator *(num other) { 18 num operator *(num other) {
19 return other.mulFromInteger(this); 19 return other.mulFromInteger(this);
20 } 20 }
21 num operator ~/(num other) { 21 num operator ~/(num other) {
22 if (other == 0) { 22 if ((other is int) && (other == 0)) {
23 throw const IntegerDivisionByZeroException(); 23 throw const IntegerDivisionByZeroException();
24 } 24 }
25 return other.truncDivFromInteger(this); 25 return other.truncDivFromInteger(this);
26 } 26 }
27 num operator /(num other) { 27 num operator /(num other) {
28 return this.toDouble() / other.toDouble(); 28 return this.toDouble() / other.toDouble();
29 } 29 }
30 num operator %(num other) { 30 num operator %(num other) {
31 if ((other is int) && (other == 0)) { 31 if ((other is int) && (other == 0)) {
32 throw const IntegerDivisionByZeroException(); 32 throw const IntegerDivisionByZeroException();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 } 237 }
238 int shlFromInt(int other) { 238 int shlFromInt(int other) {
239 throw const OutOfMemoryException(); 239 throw const OutOfMemoryException();
240 } 240 }
241 241
242 int pow(int exponent) { 242 int pow(int exponent) {
243 throw "Bigint.pow not implemented"; 243 throw "Bigint.pow not implemented";
244 } 244 }
245 } 245 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698