summary refs log tree commit diff stats
path: root/compiler/jsgen.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/jsgen.nim')
-rw-r--r--compiler/jsgen.nim11
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 6310a45a6..4b3862cff 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -33,7 +33,7 @@ import
   nversion, msgs, idents, types, tables,
   ropes, math, passes, ccgutils, wordrecg, renderer,
   intsets, cgmeth, lowerings, sighashes, modulegraphs, lineinfos, rodutils,
-  transf
+  transf, injectdestructors
 
 
 from modulegraphs import ModuleGraph, PPassContext
@@ -2259,7 +2259,10 @@ proc genProc(oldProc: PProc, prc: PSym): Rope =
     else:
       returnStmt = "return $#;$n" % [a.res]
 
-  let transformedBody = transformBody(oldProc.module.graph, prc, cache = false)
+  var transformedBody = transformBody(oldProc.module.graph, prc, cache = false)
+  if sfInjectDestructors in prc.flags:
+    transformedBody = injectDestructorCalls(oldProc.module.graph, prc, transformedBody)
+
   p.nested: genStmt(p, transformedBody)
 
   var def: Rope
@@ -2540,7 +2543,9 @@ proc genModule(p: PProc, n: PNode) =
     add(p.body, frameCreate(p,
         makeJSString("module " & p.module.module.name.s),
         makeJSString(toFilename(p.config, p.module.module.info))))
-  let transformedN = transformStmt(p.module.graph, p.module.module, n)
+  var transformedN = transformStmt(p.module.graph, p.module.module, n)
+  if sfInjectDestructors in p.module.module.flags:
+    transformedN = injectDestructorCalls(p.module.graph, p.module.module, transformedN)
   if p.config.hcrOn and n.kind == nkStmtList:
     let moduleSym = p.module.module
     var moduleLoadedVar = rope(moduleSym.name.s) & "_loaded" &