fixes #8405: -d:useNimRtl now works even when {.rtl.} procs are used at compile time; CTFFI now works with {dynlib} (#11635)

This commit is contained in:
Timothee Cour 2019-07-03 14:57:52 -07:00 • committed by Andreas Rumpf
commit 64168d4aea
5 changed files with 68 additions and 61 deletions

View file

@ -1544,8 +1544,11 @@ proc genTypeLit(c: PCtx; t: PType; dest: var TDest) =
n.typ = t
genLit(c, n, dest)
proc importcCond(s: PSym): bool {.inline.} =
sfImportc in s.flags and (lfDynamicLib notin s.loc.flags or s.ast == nil)
proc importcCond*(s: PSym): bool {.inline.} =
## return true to importc `s`, false to execute its body instead (refs #8405)
if sfImportc in s.flags:
if s.kind in routineKinds:
return s.ast.sons[bodyPos].kind == nkEmpty
proc importcSym(c: PCtx; info: TLineInfo; s: PSym) =
when hasFFI:
@ -1553,7 +1556,8 @@ proc importcSym(c: PCtx; info: TLineInfo; s: PSym) =
c.globals.add(importcSymbol(c.config, s))
s.position = c.globals.len
else:
localError(c.config, info, "VM is not allowed to 'importc'")
localError(c.config, info,
"VM is not allowed to 'importc' without --experimental:compiletimeFFI")
else:
localError(c.config, info,
"cannot 'importc' variable at compile time; " & s.name.s)