Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |