Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Implement Int64 as a wrapper around int
Browse files Browse the repository at this point in the history
On AOT, JIT, and Wasm we don't need to emulate 64-bit integers as the
`int` type is already 64 bits.

This PR adds another implementation of `Int64` that is just a wrapper
around `int`:

    class Int64 implements IntX {
      final int _i;
      ...
    }

`int64` library imports this implementation in VM and dart2wasm, and the
old (emulated) `Int64` implementation on dart2js.

The conditional import is implemented based on availability of the
library `dart:html`, which is only available on dart2js.

(In principle dart2wasm could support `dart:html` as well, but it won't
be supported, instead dart2wasm will support `package:web`)

Documentations of `Int64` and its members are copied directly from the
old emulated `Int64` class to make sure the documentation will look the
same as before.

The old `toRadixStringUnsigned` implementation is moved to the utilities
library and reused in the new class.
  • Loading branch information
osa1 committed Oct 17, 2023
1 parent ef45eb5 commit 71b813b
Show file tree
Hide file tree
Showing 6 changed files with 1,490 additions and 1,125 deletions.
3 changes: 2 additions & 1 deletion lib/fixnum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
/// Signed 32- and 64-bit integer support.
///
/// The integer implementations in this library are designed to work
/// identically whether executed on the Dart VM or compiled to JavaScript.
/// identically whether executed on the Dart VM or compiled to JavaScript or
/// Wasm.
library fixnum;

export 'src/int32.dart';
Expand Down
Loading

0 comments on commit 71b813b

Please sign in to comment.