* fixes #10703 * emit frame defines once
This commit is contained in:
parent
3e04afda9f
commit
ea3e18bc6c
3 changed files with 21 additions and 17 deletions
|
|
@ -539,7 +539,22 @@ proc initLocExprSingleUse(p: BProc, e: PNode, result: var TLoc) =
|
|||
|
||||
include ccgcalls, "ccgstmts.nim"
|
||||
|
||||
proc initFrame(p: BProc, procname, filename: Rope): Rope =
|
||||
proc initFrame(p: BProc, procname, filename: Rope): Rope =
|
||||
const frameDefines = """
|
||||
$1 define nimfr_(proc, file) \
|
||||
TFrame FR_; \
|
||||
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; #nimFrame(&FR_);
|
||||
|
||||
$1 define nimfrs_(proc, file, slots, length) \
|
||||
struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
|
||||
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; #nimFrame((TFrame*)&FR_);
|
||||
|
||||
$1 define nimln_(n, file) \
|
||||
FR_.line = n; FR_.filename = file;
|
||||
"""
|
||||
if p.module.s[cfsFrameDefines].len == 0:
|
||||
appcg(p.module, p.module.s[cfsFrameDefines], frameDefines, [rope("#")])
|
||||
|
||||
discard cgsym(p.module, "nimFrame")
|
||||
if p.maxFrameLen > 0:
|
||||
discard cgsym(p.module, "VarSlot")
|
||||
|
|
@ -1123,20 +1138,6 @@ proc genVarPrototype(m: BModule, n: PNode) =
|
|||
"\t$1 = ($2*)hcrGetGlobal($3, \"$1\");$n", [sym.loc.r,
|
||||
getTypeDesc(m, sym.loc.t), getModuleDllPath(m, sym)])
|
||||
|
||||
const
|
||||
frameDefines = """
|
||||
$1 define nimfr_(proc, file) \
|
||||
TFrame FR_; \
|
||||
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; #nimFrame(&FR_);
|
||||
|
||||
$1 define nimfrs_(proc, file, slots, length) \
|
||||
struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
|
||||
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; #nimFrame((TFrame*)&FR_);
|
||||
|
||||
$1 define nimln_(n, file) \
|
||||
FR_.line = n; FR_.filename = file;
|
||||
"""
|
||||
|
||||
proc addIntTypes(result: var Rope; conf: ConfigRef) {.inline.} =
|
||||
addf(result, "#define NIM_INTBITS $1\L", [
|
||||
platform.CPU[conf.target.targetCPU].intSize.rope])
|
||||
|
|
@ -1477,8 +1478,6 @@ proc genInitCode(m: BModule) =
|
|||
## this function is called in cgenWriteModules after all modules are closed,
|
||||
## it means raising dependency on the symbols is too late as it will not propogate
|
||||
## into other modules, only simple rope manipulations are allowed
|
||||
appcg(m, m.s[cfsForwardTypes], frameDefines, [rope("#")])
|
||||
|
||||
var moduleInitRequired = m.hcrOn
|
||||
let initname = getInitName(m)
|
||||
var prc = "$1 N_NIMCALL(void, $2)(void) {$N" %
|
||||
|
|
@ -1608,6 +1607,9 @@ proc genModule(m: BModule, cfile: Cfile): Rope =
|
|||
add(result, genSectionStart(cfsHeaders, m.config))
|
||||
add(result, m.s[cfsHeaders])
|
||||
add(result, genSectionEnd(cfsHeaders, m.config))
|
||||
add(result, genSectionStart(cfsFrameDefines, m.config))
|
||||
add(result, m.s[cfsFrameDefines])
|
||||
add(result, genSectionEnd(cfsFrameDefines, m.config))
|
||||
|
||||
for i in countup(cfsForwardTypes, cfsProcs):
|
||||
if m.s[i].len > 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue