-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for BigInts and BigInt-based TypedArrays #184
Conversation
Time Change: +279.25ms (3%) Total Time: 8,247.5ms
ℹ️ View Unchanged
|
This needs conflicts to be resolved after |
Can we have a separate module for BigInt support instead of having a new feature flag BTW symbol support should be also enabled by an explicit option? We need to define the minimum supported ECMAScript edition, and guard for new features introduced after the edition. |
Time Change: -39ms (0%) Total Time: 19,157ms
View Unchanged
|
I would especially appreciate feedback on the new package name ( |
Module name candidates:
Note: The proposal name was JS-BigInt-integration |
How's about |
Ah, sorry, just saw your link to the proposal. 😅 Then I personally vote for |
For |
Is this ready for review by any chance? |
Yep! |
I prefer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a few nits. Great work! 👏
Co-Authored-By: Max Desiatov <[email protected]>
Co-Authored-By: Max Desiatov <[email protected]>
I wonder if we have to disable Safari WasmTransformer pass when |
I can also confirm that the issue is not reproducible with 95d0c4c, which is prior to the merge commit for this PR. |
That sounds good! Would we need to do anything on the JS side to correctly handle the previous APIs that now return BigInts? |
I haven't verified yet if disabling the pass fixes the issue with the latest JSKit |
Fixes #56.
Depends on #183In the
JavaScriptKit
package, this PR:JSBigInt
class that makes it easy to convert betweenBigInt
andInt64
/UInt64
values.i64
values are signed, so I have to hack around that behavior forUInt64
values+-*/
etc) onJSBigInt
instances; however, we currently don’t have a way to invoke arbitrary operators in JS from Swift, and there are no function-based equivalents of the operators that we could access instead..fromJSValue()
(this may cause a crash if the BigInt is outside of the bounds of the requested type, I think)Int64
andUInt64
toJSValue
In addition, a new package (tentatively named
JavaScriptKit_I64
) includes:JSTypedArray<Int64>
andJSTypedArray<UInt64>
Int64
andUInt64
to aBigInt
JSValueDouble
value?BigInt
JSValueint64Value
anduInt64Value
of aJSBigInt
Int64(bigInt)
/UInt64(bigInt)
?JSBigInt
from anInt64
orUInt64
also, it:
ConstructibleFromJSValue
to reduce boilerplate code (using a Swift 5.5 feature)JSSymbol
’sJSValue
conversion APIs (oops!)setTimeout
function to be aDouble
(since at least Node.js doesn’t support BigInt timeouts)JSValueKind.invalid
since it is unusedassertNever
helper function in TypeScript to ensure switches are exhaustive