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

Side by Side Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 10332291: Negative numbers should not be >>> shifted. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test. Created 8 years, 7 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 | tests/language/positive_bit_operations_test.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 #library('js_helper'); 5 #library('js_helper');
6 6
7 #import('coreimpl.dart'); 7 #import('coreimpl.dart');
8 8
9 #source('constant_map.dart'); 9 #source('constant_map.dart');
10 #source('native_helper.dart'); 10 #source('native_helper.dart');
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return UNINTERCEPTED(a << b); 171 return UNINTERCEPTED(a << b);
172 } 172 }
173 173
174 shr(var a, var b) { 174 shr(var a, var b) {
175 // TODO(floitsch): inputs must be integers. 175 // TODO(floitsch): inputs must be integers.
176 if (checkNumbers(a, b)) { 176 if (checkNumbers(a, b)) {
177 if (b < 0) throw new IllegalArgumentException(b); 177 if (b < 0) throw new IllegalArgumentException(b);
178 // JavaScript only looks at the last 5 bits of the shift-amount. Shifting 178 // JavaScript only looks at the last 5 bits of the shift-amount. Shifting
179 // by 33 is hence equivalent to a shift by 1. 179 // by 33 is hence equivalent to a shift by 1.
180 if (b > 31) return 0; 180 if (b > 31) return 0;
181 return JS('num', @'# >>> #', a, b); 181 if (a >= 0) return JS('num', @'# >>> #', a, b);
182 return JS('num', @'(# >> #) >>> 0', a, b);
ngeoffray 2012/05/22 15:46:31 Please add a comment on what this entails.
floitsch 2012/05/22 21:07:37 Done.
182 } 183 }
183 return UNINTERCEPTED(a >> b); 184 return UNINTERCEPTED(a >> b);
184 } 185 }
185 186
186 and(var a, var b) { 187 and(var a, var b) {
187 // TODO(floitsch): inputs must be integers. 188 // TODO(floitsch): inputs must be integers.
188 if (checkNumbers(a, b)) { 189 if (checkNumbers(a, b)) {
189 return JS('num', @'(# & #) >>> 0', a, b); 190 return JS('num', @'(# & #) >>> 0', a, b);
190 } 191 }
191 return UNINTERCEPTED(a & b); 192 return UNINTERCEPTED(a & b);
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 if (JS('bool', '!!#[#]', value, property)) return value; 904 if (JS('bool', '!!#[#]', value, property)) return value;
904 propertyTypeError(value, property); 905 propertyTypeError(value, property);
905 } 906 }
906 907
907 listSuperNativeTypeCheck(value, property) { 908 listSuperNativeTypeCheck(value, property) {
908 if (value === null) return value; 909 if (value === null) return value;
909 if (value is List) return value; 910 if (value is List) return value;
910 if (JS('bool', '#[#]()', value, property)) return value; 911 if (JS('bool', '#[#]()', value, property)) return value;
911 propertyTypeError(value, property); 912 propertyTypeError(value, property);
912 } 913 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/positive_bit_operations_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698