Add line directives for C code variables (#21466)
* Add line directives for C code variables * Refactor genCLineDir to only use toFullPath if necessary
This commit is contained in:
parent
7bde421e4d
commit
05e8a60bb4
1 changed files with 6 additions and 2 deletions
|
|
@ -273,6 +273,7 @@ proc genCLineDir(r: var Rope, filename: string, line: int; conf: ConfigRef) =
|
||||||
[rope(makeSingleLineCString(filename)), rope(line)])
|
[rope(makeSingleLineCString(filename)), rope(line)])
|
||||||
|
|
||||||
proc genCLineDir(r: var Rope, info: TLineInfo; conf: ConfigRef) =
|
proc genCLineDir(r: var Rope, info: TLineInfo; conf: ConfigRef) =
|
||||||
|
if optLineDir in conf.options:
|
||||||
genCLineDir(r, toFullPath(conf, info), info.safeLineNm, conf)
|
genCLineDir(r, toFullPath(conf, info), info.safeLineNm, conf)
|
||||||
|
|
||||||
proc freshLineInfo(p: BProc; info: TLineInfo): bool =
|
proc freshLineInfo(p: BProc; info: TLineInfo): bool =
|
||||||
|
|
@ -287,7 +288,7 @@ proc genLineDir(p: BProc, t: PNode) =
|
||||||
|
|
||||||
if optEmbedOrigSrc in p.config.globalOptions:
|
if optEmbedOrigSrc in p.config.globalOptions:
|
||||||
p.s(cpsStmts).add("//" & sourceLine(p.config, t.info) & "\L")
|
p.s(cpsStmts).add("//" & sourceLine(p.config, t.info) & "\L")
|
||||||
genCLineDir(p.s(cpsStmts), toFullPath(p.config, t.info), line, p.config)
|
genCLineDir(p.s(cpsStmts), t.info, p.config)
|
||||||
if ({optLineTrace, optStackTrace} * p.options == {optLineTrace, optStackTrace}) and
|
if ({optLineTrace, optStackTrace} * p.options == {optLineTrace, optStackTrace}) and
|
||||||
(p.prc == nil or sfPure notin p.prc.flags) and t.info.fileIndex != InvalidFileIdx:
|
(p.prc == nil or sfPure notin p.prc.flags) and t.info.fileIndex != InvalidFileIdx:
|
||||||
if freshLineInfo(p, t.info):
|
if freshLineInfo(p, t.info):
|
||||||
|
|
@ -566,6 +567,9 @@ proc localVarDecl(p: BProc; n: PNode): Rope =
|
||||||
if s.kind == skLet: incl(s.loc.flags, lfNoDeepCopy)
|
if s.kind == skLet: incl(s.loc.flags, lfNoDeepCopy)
|
||||||
if s.kind in {skLet, skVar, skField, skForVar} and s.alignment > 0:
|
if s.kind in {skLet, skVar, skField, skForVar} and s.alignment > 0:
|
||||||
result.addf("NIM_ALIGN($1) ", [rope(s.alignment)])
|
result.addf("NIM_ALIGN($1) ", [rope(s.alignment)])
|
||||||
|
|
||||||
|
genCLineDir(result, n.info, p.config)
|
||||||
|
|
||||||
result.add getTypeDesc(p.module, s.typ, skVar)
|
result.add getTypeDesc(p.module, s.typ, skVar)
|
||||||
if s.constraint.isNil:
|
if s.constraint.isNil:
|
||||||
if sfRegister in s.flags: result.add(" register")
|
if sfRegister in s.flags: result.add(" register")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue