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

Side by Side Diff: pkg/fixnum/int32.dart

Issue 10911206: Remove support for operator negate and replace occurrences with unary (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 | « lib/core/num.dart ('k') | pkg/fixnum/int64.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 32-bit signed integer, in the range [-2^31, 2^31 - 1]. 6 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 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 int32 implements intx { 9 class int32 implements intx {
10 10
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return new int32.fromInt(_i + _convert(other)); 171 return new int32.fromInt(_i + _convert(other));
172 } 172 }
173 173
174 intx operator -(other) { 174 intx operator -(other) {
175 if (other is int64) { 175 if (other is int64) {
176 return this.toInt64() - other; 176 return this.toInt64() - other;
177 } 177 }
178 return new int32.fromInt(_i - _convert(other)); 178 return new int32.fromInt(_i - _convert(other));
179 } 179 }
180 180
181 int32 operator negate() => new int32.fromInt(-_i); 181 int32 operator -() => new int32.fromInt(-_i);
182 182
183 intx operator *(other) { 183 intx operator *(other) {
184 if (other is int64) { 184 if (other is int64) {
185 return this.toInt64() * other; 185 return this.toInt64() * other;
186 } 186 }
187 // TODO(rice) - optimize 187 // TODO(rice) - optimize
188 return (this.toInt64() * other).toInt32(); 188 return (this.toInt64() * other).toInt32();
189 } 189 }
190 190
191 int32 operator %(other) { 191 int32 operator %(other) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 346
347 int toInt() => _i; 347 int toInt() => _i;
348 int32 toInt32() => this; 348 int32 toInt32() => this;
349 int64 toInt64() => new int64.fromInt(_i); 349 int64 toInt64() => new int64.fromInt(_i);
350 350
351 String toString() => _i.toString(); 351 String toString() => _i.toString();
352 String toHexString() => _i.toRadixString(16); 352 String toHexString() => _i.toRadixString(16);
353 String toRadixString(int radix) => _i.toRadixString(radix); 353 String toRadixString(int radix) => _i.toRadixString(radix);
354 } 354 }
OLDNEW
« no previous file with comments | « lib/core/num.dart ('k') | pkg/fixnum/int64.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698