add static assertions in the generated code about platform-related assumptions
This commit is contained in:
parent
8717742f00
commit
11cd0fde42
1 changed files with 7 additions and 9 deletions
|
|
@ -40,15 +40,7 @@ proc addForwardedProc(m: BModule, prc: PSym) =
|
||||||
|
|
||||||
proc findPendingModule(m: BModule, s: PSym): BModule =
|
proc findPendingModule(m: BModule, s: PSym): BModule =
|
||||||
var ms = getModule(s)
|
var ms = getModule(s)
|
||||||
if ms.id == m.module.id: return m
|
result = gModules[ms.position]
|
||||||
for i in countup(0, high(gModules)):
|
|
||||||
result = gModules[i]
|
|
||||||
if result.module.id == ms.id: return
|
|
||||||
# else we found no pending module: This can happen for procs that are in
|
|
||||||
# a module that is already closed. This is fine, don't generate code for
|
|
||||||
# it then:
|
|
||||||
result = nil
|
|
||||||
#InternalError(s.info, "no pending module found for: " & s.name.s)
|
|
||||||
|
|
||||||
proc emitLazily(s: PSym): bool {.inline.} =
|
proc emitLazily(s: PSym): bool {.inline.} =
|
||||||
result = optDeadCodeElim in gGlobalOptions or
|
result = optDeadCodeElim in gGlobalOptions or
|
||||||
|
|
@ -1139,6 +1131,11 @@ proc writeModule(m: BModule, pending: bool) =
|
||||||
addFileToCompile(cfilenoext)
|
addFileToCompile(cfilenoext)
|
||||||
addFileToLink(cfilenoext)
|
addFileToLink(cfilenoext)
|
||||||
|
|
||||||
|
proc genPlatformAsserts(m: BModule) =
|
||||||
|
appf(m.s[cfsForwardTypes],
|
||||||
|
"typedef assert_numbits[sizeof(NI) == sizeof(void*) &&" &
|
||||||
|
"NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];$N")
|
||||||
|
|
||||||
proc myClose(b: PPassContext, n: PNode): PNode =
|
proc myClose(b: PPassContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
if b == nil or passes.skipCodegen(n): return
|
if b == nil or passes.skipCodegen(n): return
|
||||||
|
|
@ -1152,6 +1149,7 @@ proc myClose(b: PPassContext, n: PNode): PNode =
|
||||||
if sfMainModule in m.module.flags:
|
if sfMainModule in m.module.flags:
|
||||||
var disp = generateMethodDispatchers()
|
var disp = generateMethodDispatchers()
|
||||||
for i in 0..sonsLen(disp)-1: genProcAux(m, disp.sons[i].sym)
|
for i in 0..sonsLen(disp)-1: genProcAux(m, disp.sons[i].sym)
|
||||||
|
genPlatformAsserts(m)
|
||||||
genMainProc(m)
|
genMainProc(m)
|
||||||
# we need to process the transitive closure because recursive module
|
# we need to process the transitive closure because recursive module
|
||||||
# deps are allowed (and the system module is processed in the wrong
|
# deps are allowed (and the system module is processed in the wrong
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue