clean up stdlib with --jsbigint64 (#24255)

refs #6978, refs #6752, refs #21613, refs #24234

The `jsNoInt64`, `whenHasBigInt64`, `whenJsNoBigInt64` templates are
replaced with bool constants to use with `when`. Weird that I didn't do
this in the first place.

The `whenJsNoBigInt64` template was also slightly misleading. The first
branch was compiled for both no bigint64 on JS as well as on C/C++. It
seems only `trandom` depended on this by mistake.

The workaround for #6752 added in #6978 to `times` is also removed with
`--jsbigint64:on`, but #24233 was also encountered with this, so this PR
depends on #24234.

(cherry picked from commit 041098e882)
This commit is contained in:
metagn
2024-10-19 17:40:28 +03:00
committed by narimiran
parent 0cce80071b
commit cd760b00c2
14 changed files with 73 additions and 94 deletions

View File

@@ -83,14 +83,21 @@ when defined(js):
assert 9007199254740991.toJs.isSafeInteger
assert not 9007199254740992.toJs.isSafeInteger
template whenJsNoBigInt64*(no64, yes64): untyped =
const jsNoBigInt64* =
when defined(js):
when compiles(compileOption("jsbigint64")):
when compileOption("jsbigint64"):
yes64
else:
no64
not compileOption("jsbigint64")
else:
no64
true
else:
no64
false
const hasWorkingInt64* =
# equal to `not jsNoBigInt64`, but define it by itself anyway
when defined(js):
when compiles(compileOption("jsbigint64")):
compileOption("jsbigint64")
else:
false
else:
true