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
parent 94d1aa5109
commit 4f4aafda6c
2 changed files with 7 additions and 2 deletions

View File

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

View File

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