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>
This commit is contained in:
Lasse R.H. Nielsen 2021-03-16 09:37:15 +00:00 committed by commit-bot@chromium.org
parent 7e2cc73da8
commit b250a58d8e

View file

@ -335,13 +335,16 @@ class JSNumber extends Interceptor implements int, double {
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 @@ class JSNumber extends Interceptor implements int, double {
}
@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