Plumb {.intdefine.} and {.strdefine.} pragmas.

Shorthand so that users won't need to use the .magic pragma
This commit is contained in:
Jeff Ciesielski 2016-07-04 22:52:24 -04:00
commit 4f4aafda6c
2 changed files with 7 additions and 2 deletions

View file

@ -63,7 +63,8 @@ const
wImportCpp, wImportObjC, wError, wNoInit, wCompileTime, wGlobal, wImportCpp, wImportObjC, wError, wNoInit, wCompileTime, wGlobal,
wGensym, wInject, wCodegenDecl, wGuard, wGoto, wExportNims} wGensym, wInject, wCodegenDecl, wGuard, wGoto, wExportNims}
constPragmas* = {wImportc, wExportc, wHeader, wDeprecated, wMagic, wNodecl, constPragmas* = {wImportc, wExportc, wHeader, wDeprecated, wMagic, wNodecl,
wExtern, wImportCpp, wImportObjC, wError, wGensym, wInject, wExportNims} wExtern, wImportCpp, wImportObjC, wError, wGensym, wInject, wExportNims,
wIntDefine, wStrDefine}
letPragmas* = varPragmas letPragmas* = varPragmas
procTypePragmas* = {FirstCallConv..LastCallConv, wVarargs, wNosideeffect, procTypePragmas* = {FirstCallConv..LastCallConv, wVarargs, wNosideeffect,
wThread, wRaises, wLocks, wTags, wGcSafe} wThread, wRaises, wLocks, wTags, wGcSafe}
@ -898,6 +899,10 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
of wBase: of wBase:
noVal(it) noVal(it)
sym.flags.incl sfBase sym.flags.incl sfBase
of wIntDefine:
sym.magic = mIntDefine
of wStrDefine:
sym.magic = mIntDefine
else: invalidPragma(it) else: invalidPragma(it)
else: invalidPragma(it) else: invalidPragma(it)

View file

@ -150,7 +150,7 @@ elif defined(windows):
#VirtualFree(p, size, MEM_DECOMMIT) #VirtualFree(p, size, MEM_DECOMMIT)
elif hostOS == "standalone": elif hostOS == "standalone":
const StandaloneHeapSize {.magic: "IntDefine"}: int = 1024 * PageSize const StandaloneHeapSize {.intdefine.}: int = 1024 * PageSize
var var
theHeap: array[StandaloneHeapSize, float64] # 'float64' for alignment theHeap: array[StandaloneHeapSize, float64] # 'float64' for alignment
bumpPointer = cast[int](addr theHeap) bumpPointer = cast[int](addr theHeap)