importCompilerProc pragma introduced because the hacks for typeinfo.nim did not suffice
This commit is contained in:
parent
3e91b456e5
commit
3091bc4958
9 changed files with 96 additions and 38 deletions
|
|
@ -406,7 +406,8 @@ type
|
|||
lfNoDecl, # do not declare it in C
|
||||
lfDynamicLib, # link symbol to dynamic library
|
||||
lfExportLib, # export symbol for dynamic library generation
|
||||
lfHeader # include header file for symbol
|
||||
lfHeader, # include header file for symbol
|
||||
lfImportCompilerProc # ``importc`` of a compilerproc
|
||||
TStorageLoc* = enum
|
||||
OnUnknown, # location is unknown (stack, heap or static)
|
||||
OnStack, # location is on hardware stack
|
||||
|
|
|
|||
|
|
@ -1452,7 +1452,8 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
|||
of mIncl, mExcl, mCard, mLtSet, mLeSet, mEqSet, mMulSet, mPlusSet, mMinusSet,
|
||||
mInSet:
|
||||
genSetOp(p, e, d, op)
|
||||
of mNewString, mNewStringOfCap, mCopyStr, mCopyStrLast, mExit, mCreateThread:
|
||||
of mCreateThread: genCall(p, e, d)
|
||||
of mNewString, mNewStringOfCap, mCopyStr, mCopyStrLast, mExit:
|
||||
var opr = e.sons[0].sym
|
||||
if lfNoDecl notin opr.loc.flags:
|
||||
discard cgsym(p.module, opr.loc.r.ropeToStr)
|
||||
|
|
|
|||
|
|
@ -666,17 +666,21 @@ proc genProcPrototype(m: BModule, sym: PSym) =
|
|||
proc genProcNoForward(m: BModule, prc: PSym) =
|
||||
fillProcLoc(prc)
|
||||
useHeader(m, prc)
|
||||
if lfImportCompilerProc in prc.loc.flags:
|
||||
# dependency to a compilerproc:
|
||||
discard cgsym(m, prc.name.s)
|
||||
return
|
||||
genProcPrototype(m, prc)
|
||||
if lfNoDecl in prc.loc.Flags: return
|
||||
if prc.typ.callConv == ccInline:
|
||||
if lfNoDecl in prc.loc.Flags: nil
|
||||
elif prc.typ.callConv == ccInline:
|
||||
# We add inline procs to the calling module to enable C based inlining.
|
||||
# This also means that a check with ``gGeneratedSyms`` is wrong, we need
|
||||
# a check for ``m.declaredThings``.
|
||||
if not ContainsOrIncl(m.declaredThings, prc.id): genProcAux(m, prc)
|
||||
elif lfDynamicLib in prc.loc.flags:
|
||||
elif lfDynamicLib in prc.loc.flags:
|
||||
if not ContainsOrIncl(gGeneratedSyms, prc.id):
|
||||
SymInDynamicLib(findPendingModule(m, prc), prc)
|
||||
elif not (sfImportc in prc.flags):
|
||||
elif sfImportc notin prc.flags:
|
||||
if not ContainsOrIncl(gGeneratedSyms, prc.id):
|
||||
genProcAux(findPendingModule(m, prc), prc)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ const
|
|||
procPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
||||
wMagic, wNosideEffect, wSideEffect, wNoreturn, wDynLib, wHeader,
|
||||
wCompilerProc, wPure, wProcVar, wDeprecated, wVarargs, wCompileTime, wMerge,
|
||||
wBorrow, wExtern}
|
||||
wBorrow, wExtern, wImportCompilerProc}
|
||||
converterPragmas* = procPragmas
|
||||
methodPragmas* = procPragmas
|
||||
macroPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
||||
|
|
@ -80,6 +80,12 @@ proc MakeExternExport(s: PSym, extname: string) =
|
|||
setExternName(s, extname)
|
||||
incl(s.flags, sfExportc)
|
||||
|
||||
proc processImportCompilerProc(s: PSym, extname: string) =
|
||||
setExternName(s, extname)
|
||||
incl(s.flags, sfImportc)
|
||||
excl(s.flags, sfForward)
|
||||
incl(s.loc.flags, lfImportCompilerProc)
|
||||
|
||||
proc getStrLitNode(c: PContext, n: PNode): PNode =
|
||||
if n.kind != nkExprColonExpr:
|
||||
GlobalError(n.info, errStringLiteralExpected)
|
||||
|
|
@ -401,6 +407,8 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
|||
makeExternExport(sym, getOptionalStr(c, it, sym.name.s))
|
||||
incl(sym.flags, sfUsed) # avoid wrong hints
|
||||
of wImportc: makeExternImport(sym, getOptionalStr(c, it, sym.name.s))
|
||||
of wImportCompilerProc:
|
||||
processImportCompilerProc(sym, getOptionalStr(c, it, sym.name.s))
|
||||
of wExtern: setExternName(sym, expectStrLit(c, it))
|
||||
of wAlign:
|
||||
if sym.typ == nil: invalidPragma(it)
|
||||
|
|
|
|||
|
|
@ -33,8 +33,9 @@ type
|
|||
wWithout, wXor, wYield,
|
||||
|
||||
wColon, wColonColon, wEquals, wDot, wDotDot, wHat, wStar, wMinus,
|
||||
wMagic, wTypeCheck, wFinal, wProfiler, wObjChecks, wImportc, wExportc,
|
||||
wExtern,
|
||||
wMagic, wTypeCheck, wFinal, wProfiler, wObjChecks,
|
||||
wImportCompilerProc,
|
||||
wImportc, wExportc, wExtern,
|
||||
wAlign, wNodecl, wPure, wVolatile, wRegister, wSideeffect, wHeader,
|
||||
wNosideeffect, wNoreturn, wMerge, wLib, wDynlib, wCompilerproc, wProcVar,
|
||||
wFatal, wError, wWarning, wHint, wLine, wPush, wPop, wDefine, wUndef,
|
||||
|
|
@ -79,8 +80,8 @@ const
|
|||
"yield",
|
||||
|
||||
":", "::", "=", ".", "..", "^", "*", "-",
|
||||
"magic", "typecheck", "final", "profiler", "objchecks", "importc",
|
||||
"exportc", "extern",
|
||||
"magic", "typecheck", "final", "profiler", "objchecks",
|
||||
"importcompilerproc", "importc", "exportc", "extern",
|
||||
"align", "nodecl", "pure", "volatile", "register", "sideeffect",
|
||||
"header", "nosideeffect", "noreturn", "merge", "lib", "dynlib",
|
||||
"compilerproc", "procvar", "fatal", "error", "warning", "hint", "line",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue