Implement `int.>>>` for DDC.
BUG= https://github.com/dart-lang/sdk/issues/44915
Change-Id: Ia63d1653729ff458f9ebb2a2e33883a00a66378f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191220
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
diff --git a/sdk/lib/_internal/js_dev_runtime/private/js_number.dart b/sdk/lib/_internal/js_dev_runtime/private/js_number.dart
index c70de91..b90d786 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/js_number.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/js_number.dart
@@ -335,13 +335,16 @@
return _shrOtherPositive(other);
}
- int operator >>>(@nullCheck num other) =>
- throw UnimplementedError('int.>>> is not implemented yet');
+ @notNull
+ int operator >>>(@nullCheck num other) {
+ if (JS<num>('!', '#', other) < 0) throwArgumentErrorValue(other);
+ return _shrUnsigned(other);
+ }
@notNull
int _shrOtherPositive(@notNull num other) {
return JS<num>('!', '#', this) > 0
- ? _shrBothPositive(other)
+ ? _shrUnsigned(other)
// For negative numbers we just clamp the shift-by amount.
// `this` could be negative but not have its 31st bit set.
// The ">>" would then shift in 0s instead of 1s. Therefore
@@ -350,7 +353,7 @@
}
@notNull
- int _shrBothPositive(@notNull num other) {
+ int _shrUnsigned(@notNull num other) {
return JS<bool>('!', r'# > 31', other)
// JavaScript only looks at the last 5 bits of the shift-amount. In JS
// shifting by 33 is hence equivalent to a shift by 1. Shortcut the