preparations of making compiler/msgs.nim free of global variables

This commit is contained in:
Andreas Rumpf 2018-05-17 15:21:22 +02:00
commit bf6c2c5ccf
38 changed files with 179 additions and 183 deletions

View file

@ -10,7 +10,7 @@
## This module implements the generation of ``.ndi`` files for better debugging
## support of Nim code. "ndi" stands for "Nim debug info".
import ast, msgs, ropes
import ast, msgs, ropes, options
type
NdiFile* = object
@ -18,19 +18,19 @@ type
f: File
buf: string
proc doWrite(f: var NdiFile; s: PSym) =
proc doWrite(f: var NdiFile; s: PSym; conf: ConfigRef) =
f.buf.setLen 0
f.buf.add s.info.line.int
f.buf.add "\t"
f.buf.add s.info.col.int
f.f.write(s.name.s, "\t")
f.f.writeRope(s.loc.r)
f.f.writeLine("\t", s.info.toFullPath, "\t", f.buf)
f.f.writeLine("\t", toFullPath(conf, s.info), "\t", f.buf)
template writeMangledName*(f: NdiFile; s: PSym) =
if f.enabled: doWrite(f, s)
template writeMangledName*(f: NdiFile; s: PSym; conf: ConfigRef) =
if f.enabled: doWrite(f, s, conf)
proc open*(f: var NdiFile; filename: string) =
proc open*(f: var NdiFile; filename: string; conf: ConfigRef) =
f.enabled = filename.len > 0
if f.enabled:
f.f = open(filename, fmWrite, 8000)