[backport 1.0] add backend support for js bigint (#16606)

* add backend support for js bigint

* cleanup

* add tests

* add -d:nimHasJsBigIntBackend

* cleanup

* more tests

(cherry picked from commit 025ca660f7)
This commit is contained in:
Timothee Cour
2021-01-06 11:28:24 -08:00
committed by narimiran
parent bdb3cc3a8a
commit 040adf415b
3 changed files with 63 additions and 1 deletions

View File

@@ -117,3 +117,4 @@ proc initDefines*(symbols: StringTableRef) =
defineSymbol("nimHasInvariant")
defineSymbol("nimHasStacktraceMsgs")
defineSymbol("nimHasStacktracesModule")
defineSymbol("nimHasJsBigIntBackend")

View File

@@ -1591,7 +1591,10 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope =
var t = skipTypes(typ, abstractInst)
case t.kind
of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyChar:
result = putToSeq("0", indirect)
if $t.sym.loc.r == "bigint":
result = putToSeq("0n", indirect)
else:
result = putToSeq("0", indirect)
of tyFloat..tyFloat128:
result = putToSeq("0.0", indirect)
of tyRange, tyGenericInst, tyAlias, tySink, tyOwned: