Skip to content

Commit b250a58

Browse files
lrhncommit-bot@chromium.org
authored andcommitted
Implement int.>>> for DDC.
BUG= #44915 Change-Id: Ia63d1653729ff458f9ebb2a2e33883a00a66378f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191220 Reviewed-by: Nicholas Shahan <[email protected]> Commit-Queue: Lasse R.H. Nielsen <[email protected]>
1 parent 7e2cc73 commit b250a58

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sdk/lib/_internal/js_dev_runtime/private/js_number.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,16 @@ class JSNumber extends Interceptor implements int, double {
335335
return _shrOtherPositive(other);
336336
}
337337

338-
int operator >>>(@nullCheck num other) =>
339-
throw UnimplementedError('int.>>> is not implemented yet');
338+
@notNull
339+
int operator >>>(@nullCheck num other) {
340+
if (JS<num>('!', '#', other) < 0) throwArgumentErrorValue(other);
341+
return _shrUnsigned(other);
342+
}
340343

341344
@notNull
342345
int _shrOtherPositive(@notNull num other) {
343346
return JS<num>('!', '#', this) > 0
344-
? _shrBothPositive(other)
347+
? _shrUnsigned(other)
345348
// For negative numbers we just clamp the shift-by amount.
346349
// `this` could be negative but not have its 31st bit set.
347350
// The ">>" would then shift in 0s instead of 1s. Therefore
@@ -350,7 +353,7 @@ class JSNumber extends Interceptor implements int, double {
350353
}
351354

352355
@notNull
353-
int _shrBothPositive(@notNull num other) {
356+
int _shrUnsigned(@notNull num other) {
354357
return JS<bool>('!', r'# > 31', other)
355358
// JavaScript only looks at the last 5 bits of the shift-amount. In JS
356359
// shifting by 33 is hence equivalent to a shift by 1. Shortcut the

0 commit comments

Comments
 (0)