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

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

Issue 9212016: - More cleanup after the kSAR -> kSHR rename. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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/integers.cc ('k') | runtime/vm/bootstrap_natives.h » ('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 const UnsupportedOperationException( 9 throw const UnsupportedOperationException(
10 "IntegerImplementation can only be allocated by the VM"); 10 "IntegerImplementation can only be allocated by the VM");
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 int bitXorFromInteger(int other) native "Integer_bitXorFromInteger"; 53 int bitXorFromInteger(int other) native "Integer_bitXorFromInteger";
54 int addFromInteger(int other) native "Integer_addFromInteger"; 54 int addFromInteger(int other) native "Integer_addFromInteger";
55 int subFromInteger(int other) native "Integer_subFromInteger"; 55 int subFromInteger(int other) native "Integer_subFromInteger";
56 int mulFromInteger(int other) native "Integer_mulFromInteger"; 56 int mulFromInteger(int other) native "Integer_mulFromInteger";
57 int truncDivFromInteger(int other) native "Integer_truncDivFromInteger"; 57 int truncDivFromInteger(int other) native "Integer_truncDivFromInteger";
58 int moduloFromInteger(int other) native "Integer_moduloFromInteger"; 58 int moduloFromInteger(int other) native "Integer_moduloFromInteger";
59 int remainderFromInteger(int other) { 59 int remainderFromInteger(int other) {
60 return other - (other ~/ this) * this; 60 return other - (other ~/ this) * this;
61 } 61 }
62 int operator >>(int other) { 62 int operator >>(int other) {
63 return other.sarFromInt(this); 63 return other.shrFromInt(this);
64 } 64 }
65 int operator <<(int other) { 65 int operator <<(int other) {
66 return other.shlFromInt(this); 66 return other.shlFromInt(this);
67 } 67 }
68 bool operator <(num other) { 68 bool operator <(num other) {
69 return other > this; 69 return other > this;
70 } 70 }
71 bool operator >(num other) { 71 bool operator >(num other) {
72 return other.greaterThanFromInteger(this); 72 return other.greaterThanFromInteger(this);
73 } 73 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 class Smi extends IntegerImplementation implements int { 162 class Smi extends IntegerImplementation implements int {
163 factory Smi._uninstantiable() { 163 factory Smi._uninstantiable() {
164 throw const UnsupportedOperationException( 164 throw const UnsupportedOperationException(
165 "Smi can only be allocated by the VM"); 165 "Smi can only be allocated by the VM");
166 } 166 }
167 int hashCode() { 167 int hashCode() {
168 return this; 168 return this;
169 } 169 }
170 int operator ~() native "Smi_bitNegate"; 170 int operator ~() native "Smi_bitNegate";
171 int sarFromInt(int other) native "Smi_sarFromInt"; 171 int shrFromInt(int other) native "Smi_shrFromInt";
172 int shlFromInt(int other) native "Smi_shlFromInt"; 172 int shlFromInt(int other) native "Smi_shlFromInt";
173 } 173 }
174 174
175 // Represents integers that cannot be represented by Smi but fit into 64bits. 175 // Represents integers that cannot be represented by Smi but fit into 64bits.
176 class Mint extends IntegerImplementation implements int { 176 class Mint extends IntegerImplementation implements int {
177 factory Mint._uninstantiable() { 177 factory Mint._uninstantiable() {
178 throw const UnsupportedOperationException( 178 throw const UnsupportedOperationException(
179 "Mint can only be allocated by the VM"); 179 "Mint can only be allocated by the VM");
180 } 180 }
181 int hashCode() { 181 int hashCode() {
182 return this; 182 return this;
183 } 183 }
184 int operator ~() native "Mint_bitNegate"; 184 int operator ~() native "Mint_bitNegate";
185 185
186 // Shift by mint exceeds range that can be handled by the VM. 186 // Shift by mint exceeds range that can be handled by the VM.
187 int sarFromInt(int other) { 187 int shrFromInt(int other) {
188 if (other < 0) { 188 if (other < 0) {
189 return -1; 189 return -1;
190 } else { 190 } else {
191 return 0; 191 return 0;
192 } 192 }
193 } 193 }
194 int shlFromInt(int other) { 194 int shlFromInt(int other) {
195 throw const OutOfMemoryException(); 195 throw const OutOfMemoryException();
196 } 196 }
197 } 197 }
198 198
199 // A number that can be represented as Smi or Mint will never be represented as 199 // A number that can be represented as Smi or Mint will never be represented as
200 // Bigint. 200 // Bigint.
201 class Bigint extends IntegerImplementation implements int { 201 class Bigint extends IntegerImplementation implements int {
202 factory Bigint._uninstantiable() { 202 factory Bigint._uninstantiable() {
203 throw const UnsupportedOperationException( 203 throw const UnsupportedOperationException(
204 "Bigint can only be allocated by the VM"); 204 "Bigint can only be allocated by the VM");
205 } 205 }
206 int hashCode() { 206 int hashCode() {
207 return this; 207 return this;
208 } 208 }
209 int operator ~() native "Bigint_bitNegate"; 209 int operator ~() native "Bigint_bitNegate";
210 210
211 // Shift by bigint exceeds range that can be handled by the VM. 211 // Shift by bigint exceeds range that can be handled by the VM.
212 int sarFromInt(int other) { 212 int shrFromInt(int other) {
213 if (other < 0) { 213 if (other < 0) {
214 return -1; 214 return -1;
215 } else { 215 } else {
216 return 0; 216 return 0;
217 } 217 }
218 } 218 }
219 int shlFromInt(int other) { 219 int shlFromInt(int other) {
220 throw const OutOfMemoryException(); 220 throw const OutOfMemoryException();
221 } 221 }
222 } 222 }
OLDNEW
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698