Skip to content

Flutter/Dart web support #3190

@JulianBissekkou

Description

@JulianBissekkou

First of all, great job with the current dart runtime and the quick nullable release that you did in the last weeks. 👍🏽

We are using antlr4 in our flutter app which will run on the web soon. The current antlr4 dart runtime is not able to compile to js.
Here is the output when compiling the flutter web project:

../../../../../.pub-cache/git/antlr4-f0d4d129b7f146c314101bd3c99e630dc433af50/runtime/Dart/lib/src/util/bit_set.dart:31:16: Error: The integer literal 0x5555555555555555 can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in Javascript. In Javascript 0x5555555555555400 is the nearest value that can be represented exactly.
    const m1 = 0x5555555555555555;
               ^^^^^^^^^^^^^^^^^^
../../../../../.pub-cache/git/antlr4-f0d4d129b7f146c314101bd3c99e630dc433af50/runtime/Dart/lib/src/util/bit_set.dart:32:16: Error: The integer literal 0x3333333333333333 can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in Javascript. In Javascript 0x3333333333333400 is the nearest value that can be represented exactly.
    const m2 = 0x3333333333333333;
               ^^^^^^^^^^^^^^^^^^
../../../../../.pub-cache/git/antlr4-f0d4d129b7f146c314101bd3c99e630dc433af50/runtime/Dart/lib/src/util/bit_set.dart:33:16: Error: The integer literal 0x0F0F0F0F0F0F0F0F can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in Javascript. In Javascript 0xf0f0f0f0f0f0f00 is the nearest value that can be represented exactly.
    const m4 = 0x0F0F0F0F0F0F0F0F;
               ^^^^^^^^^^^^^^^^^^
../../../../../.pub-cache/git/antlr4-f0d4d129b7f146c314101bd3c99e630dc433af50/runtime/Dart/lib/src/util/bit_set.dart:34:16: Error: The integer literal 0x00FF00FF00FF00FF can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in Javascript. In Javascript 0xff00ff00ff0100 is the nearest value that can be represented exactly.
    const m8 = 0x00FF00FF00FF00FF;
               ^^^^^^^^^^^^^^^^^^
../../../../../.pub-cache/git/antlr4-f0d4d129b7f146c314101bd3c99e630dc433af50/runtime/Dart/lib/src/util/bit_set.dart:36:17: Error: The integer literal 0x0101010101010101 can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in Javascript. In Javascript 0x101010101010100 is the nearest value that can be represented exactly.
    const h01 = 0x0101010101010101;
                ^^^^^^^^^^^^^^^^^^
../../../../../.pub-cache/git/antlr4-f0d4d129b7f146c314101bd3c99e630dc433af50/runtime/Dart/lib/src/util/bit_set.dart:75:30: Error: The operator '>>' isn't defined for the class 'num'.
Try correcting the operator to an existing operator, or defining a '>>' operator.
      bitCount += ((x * h01) >> 56);
                             ^^
../../../../../.pub-cache/git/antlr4-f0d4d129b7f146c314101bd3c99e630dc433af50/runtime/Dart/lib/src/util/bit_set.dart:75:16: Error: A value of type 'num' can't be assigned to a variable of type 'int'.
      bitCount += ((x * h01) >> 56);
               ^
../../../../../.pub-cache/git/antlr4-f0d4d129b7f146c314101bd3c99e630dc433af50/runtime/Dart/lib/src/util/bit_set.dart:151:24: Error: The integer literal 0x03f79d71b4cb0a89 can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in Javascript. In Javascript 0x3f79d71b4cb0a80 is the nearest value that can be represented exactly.
    const debruijn64 = 0x03f79d71b4cb0a89;
                       ^^^^^^^^^^^^^^^^^^
../../../../../.pub-cache/git/antlr4-f0d4d129b7f146c314101bd3c99e630dc433af50/runtime/Dart/lib/src/util/bit_set.dart:152:58: Error: The operator '>>' isn't defined for the class 'num'.
Try correcting the operator to an existing operator, or defining a '>>' operator.
    return index64[(((value ^ (value - 1)) * debruijn64) >> 58) % 64];
                                                         ^^
Failed to compile application.

Maybe this requires only a small fix by using BigInt in bit_set.dart.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions