summary refs log tree commit diff stats
path: root/compiler/lineinfos.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-08-11 21:55:47 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-08-11 21:55:47 +0200
commitda64c8762fd4af44866879061c10f707b0dcd310 (patch)
tree89711b4f775605b510785580ea9b8ddc94fc5a58 /compiler/lineinfos.nim
parent212ae2f1257628bd5d1760593ce0a1bad768831a (diff)
downloadNim-da64c8762fd4af44866879061c10f707b0dcd310.tar.gz
destructors: spec reflects reality, =sink is here to stay
Diffstat (limited to 'compiler/lineinfos.nim')
0 files changed, 0 insertions, 0 deletions
name mangling bugfixes; ndi file generation for debugger support' href='/ahoang/Nim/commit/compiler/ndi.nim?h=devel&id=848676cec6ba75e9bd0f8f590c6e47f6be7e696e'>848676cec ^
bf6c2c5cc ^

848676cec ^
bf6c2c5cc ^
848676cec ^






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40











                                                                               
                                






                   
                                                        





                           
                                                            
 

                                                                  
 
                                                               






                                       
#
#
#           The Nim Compiler
#        (c) Copyright 2017 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

## 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, options

type
  NdiFile* = object
    enabled: bool
    f: File
    buf: string

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", toFullPath(conf, s.info), "\t", f.buf)

template writeMangledName*(f: NdiFile; s: PSym; conf: ConfigRef) =
  if f.enabled: doWrite(f, s, conf)

proc open*(f: var NdiFile; filename: string; conf: ConfigRef) =
  f.enabled = filename.len > 0
  if f.enabled:
    f.f = open(filename, fmWrite, 8000)
    f.buf = newStringOfCap(20)

proc close*(f: var NdiFile) =
  if f.enabled: close(f.f)