summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2021-01-06 11:28:24 -0800
committerGitHub <noreply@github.com>2021-01-06 20:28:24 +0100
commit025ca660f7fe396ec6794137c29845feaf7ab9a3 (patch)
tree84c614076dbd8e112530882628f53af825bd6a0d /compiler
parent21dfa04cbf638f4059244b4cecf1906b84889a1e (diff)
downloadNim-025ca660f7fe396ec6794137c29845feaf7ab9a3.tar.gz
[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
Diffstat (limited to 'compiler')
-rw-r--r--compiler/condsyms.nim1
-rw-r--r--compiler/jsgen.nim5
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim
index 131f32f32..55f2b4a0f 100644
--- a/compiler/condsyms.nim
+++ b/compiler/condsyms.nim
@@ -123,3 +123,4 @@ proc initDefines*(symbols: StringTableRef) =
   defineSymbol("nimHasEffectTraitsModule")
   defineSymbol("nimHasCastPragmaBlocks")
   defineSymbol("nimHasDeclaredLocs")
+  defineSymbol("nimHasJsBigIntBackend")
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 675a24c92..4b369210d 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -1677,7 +1677,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: