parent
0ae2d1ea88
commit
2aa97a228a
8 changed files with 2 additions and 79 deletions
|
|
@ -801,6 +801,5 @@ proc genAsgnCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
genNamedParamCall(p, ri, d)
|
genNamedParamCall(p, ri, d)
|
||||||
else:
|
else:
|
||||||
genPrefixCall(p, le, ri, d)
|
genPrefixCall(p, le, ri, d)
|
||||||
postStmtActions(p)
|
|
||||||
|
|
||||||
proc genCall(p: BProc, e: PNode, d: var TLoc) = genAsgnCall(p, nil, e, d)
|
proc genCall(p: BProc, e: PNode, d: var TLoc) = genAsgnCall(p, nil, e, d)
|
||||||
|
|
|
||||||
|
|
@ -1509,11 +1509,6 @@ proc genPragma(p: BProc, n: PNode) =
|
||||||
for it in n.sons:
|
for it in n.sons:
|
||||||
case whichPragma(it)
|
case whichPragma(it)
|
||||||
of wEmit: genEmit(p, it)
|
of wEmit: genEmit(p, it)
|
||||||
of wInjectStmt:
|
|
||||||
var p = newProc(nil, p.module)
|
|
||||||
p.options.excl {optLineTrace, optStackTrace}
|
|
||||||
genStmts(p, it[1])
|
|
||||||
p.module.injectStmt = p.s(cpsStmts)
|
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -271,9 +271,6 @@ proc genLineDir(p: BProc, t: PNode) =
|
||||||
linefmt(p, cpsStmts, "nimln_($1, $2);$n",
|
linefmt(p, cpsStmts, "nimln_($1, $2);$n",
|
||||||
[line, quotedFilename(p.config, t.info)])
|
[line, quotedFilename(p.config, t.info)])
|
||||||
|
|
||||||
proc postStmtActions(p: BProc) {.inline.} =
|
|
||||||
p.s(cpsStmts).add(p.module.injectStmt)
|
|
||||||
|
|
||||||
proc accessThreadLocalVar(p: BProc, s: PSym)
|
proc accessThreadLocalVar(p: BProc, s: PSym)
|
||||||
proc emulatedThreadVars(conf: ConfigRef): bool {.inline.}
|
proc emulatedThreadVars(conf: ConfigRef): bool {.inline.}
|
||||||
proc genProc(m: BModule, prc: PSym)
|
proc genProc(m: BModule, prc: PSym)
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,6 @@ type
|
||||||
labels*: Natural # for generating unique module-scope names
|
labels*: Natural # for generating unique module-scope names
|
||||||
extensionLoaders*: array['0'..'9', Rope] # special procs for the
|
extensionLoaders*: array['0'..'9', Rope] # special procs for the
|
||||||
# OpenGL wrapper
|
# OpenGL wrapper
|
||||||
injectStmt*: Rope
|
|
||||||
sigConflicts*: CountTable[SigHash]
|
sigConflicts*: CountTable[SigHash]
|
||||||
g*: BModuleList
|
g*: BModuleList
|
||||||
ndi*: NdiFile
|
ndi*: NdiFile
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ const
|
||||||
wDeprecated,
|
wDeprecated,
|
||||||
wFloatChecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll,
|
wFloatChecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll,
|
||||||
wLinearScanEnd, wPatterns, wTrMacros, wEffects, wNoForward, wReorder, wComputedGoto,
|
wLinearScanEnd, wPatterns, wTrMacros, wEffects, wNoForward, wReorder, wComputedGoto,
|
||||||
wInjectStmt, wExperimental, wThis, wUsed, wInvariant, wAssume, wAssert}
|
wExperimental, wThis, wUsed, wInvariant, wAssume, wAssert}
|
||||||
lambdaPragmas* = {FirstCallConv..LastCallConv,
|
lambdaPragmas* = {FirstCallConv..LastCallConv,
|
||||||
wNoSideEffect, wSideEffect, wNoreturn, wNosinks, wDynlib, wHeader,
|
wNoSideEffect, wSideEffect, wNoreturn, wNosinks, wDynlib, wHeader,
|
||||||
wThread, wAsmNoStackFrame,
|
wThread, wAsmNoStackFrame,
|
||||||
|
|
@ -1204,12 +1204,6 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
|
||||||
of wExportNims:
|
of wExportNims:
|
||||||
if sym == nil: invalidPragma(c, it)
|
if sym == nil: invalidPragma(c, it)
|
||||||
else: magicsys.registerNimScriptSymbol(c.graph, sym)
|
else: magicsys.registerNimScriptSymbol(c.graph, sym)
|
||||||
of wInjectStmt:
|
|
||||||
warningDeprecated(c.config, it.info, "'.injectStmt' pragma is deprecated")
|
|
||||||
if it.kind notin nkPragmaCallKinds or it.len != 2:
|
|
||||||
localError(c.config, it.info, "expression expected")
|
|
||||||
else:
|
|
||||||
it[1] = c.semExpr(c, it[1])
|
|
||||||
of wExperimental:
|
of wExperimental:
|
||||||
if not isTopLevel(c):
|
if not isTopLevel(c):
|
||||||
localError(c.config, n.info, "'experimental' pragma only valid as toplevel statement or in a 'push' environment")
|
localError(c.config, n.info, "'experimental' pragma only valid as toplevel statement or in a 'push' environment")
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ type
|
||||||
wLocalPassc = "localPassC", wBorrow = "borrow", wDiscardable = "discardable",
|
wLocalPassc = "localPassC", wBorrow = "borrow", wDiscardable = "discardable",
|
||||||
wFieldChecks = "fieldChecks", wSubsChar = "subschar", wAcyclic = "acyclic",
|
wFieldChecks = "fieldChecks", wSubsChar = "subschar", wAcyclic = "acyclic",
|
||||||
wShallow = "shallow", wUnroll = "unroll", wLinearScanEnd = "linearScanEnd",
|
wShallow = "shallow", wUnroll = "unroll", wLinearScanEnd = "linearScanEnd",
|
||||||
wComputedGoto = "computedGoto", wInjectStmt = "injectStmt", wExperimental = "experimental",
|
wComputedGoto = "computedGoto", wExperimental = "experimental",
|
||||||
wWrite = "write", wGensym = "gensym", wInject = "inject", wDirty = "dirty",
|
wWrite = "write", wGensym = "gensym", wInject = "inject", wDirty = "dirty",
|
||||||
wInheritable = "inheritable", wThreadVar = "threadvar", wEmit = "emit",
|
wInheritable = "inheritable", wThreadVar = "threadvar", wEmit = "emit",
|
||||||
wAsmNoStackFrame = "asmNoStackFrame", wImplicitStatic = "implicitStatic",
|
wAsmNoStackFrame = "asmNoStackFrame", wImplicitStatic = "implicitStatic",
|
||||||
|
|
|
||||||
|
|
@ -428,16 +428,6 @@ proc sweep(gch: var GcHeap) =
|
||||||
if c.refcount == rcBlack: c.refcount = rcWhite
|
if c.refcount == rcBlack: c.refcount = rcWhite
|
||||||
else: freeCyclicCell(gch, c)
|
else: freeCyclicCell(gch, c)
|
||||||
|
|
||||||
when false:
|
|
||||||
# meant to be used with the now-deprected `.injectStmt`: {.injectStmt: newGcInvariant().}
|
|
||||||
proc newGcInvariant*() =
|
|
||||||
for x in allObjects(gch.region):
|
|
||||||
if isCell(x):
|
|
||||||
var c = cast[PCell](x)
|
|
||||||
if c.typ == nil:
|
|
||||||
writeStackTrace()
|
|
||||||
quit 1
|
|
||||||
|
|
||||||
proc markGlobals(gch: var GcHeap) =
|
proc markGlobals(gch: var GcHeap) =
|
||||||
if gch.gcThreadId == 0:
|
if gch.gcThreadId == 0:
|
||||||
when defined(nimTracing):
|
when defined(nimTracing):
|
||||||
|
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
discard """
|
|
||||||
joinable: false
|
|
||||||
output:'''
|
|
||||||
onInject: 1
|
|
||||||
onInject: 2
|
|
||||||
ok0
|
|
||||||
ok1
|
|
||||||
onInject: 3
|
|
||||||
onInject: 4
|
|
||||||
onInject: 5
|
|
||||||
0
|
|
||||||
onInject: 6
|
|
||||||
onInject: 7
|
|
||||||
onInject: 8
|
|
||||||
1
|
|
||||||
onInject: 9
|
|
||||||
onInject: 10
|
|
||||||
onInject: 11
|
|
||||||
2
|
|
||||||
ok2
|
|
||||||
onInject: 12
|
|
||||||
'''
|
|
||||||
"""
|
|
||||||
|
|
||||||
# test {.injectStmt.}
|
|
||||||
|
|
||||||
#[
|
|
||||||
{.injectStmt.} pragma can be used to inject a statement before every
|
|
||||||
other statement in the current module. It's now undocumented and may be removed
|
|
||||||
in the future and replaced with something more general and without its limitations.
|
|
||||||
(e.g. doesn't work in VM or js backends).
|
|
||||||
]#
|
|
||||||
|
|
||||||
from system/ansi_c import c_printf
|
|
||||||
|
|
||||||
var count = 0
|
|
||||||
proc onInject*() =
|
|
||||||
count.inc
|
|
||||||
# echo count # xxx would fail, probably infinite recursion
|
|
||||||
c_printf("onInject: %d\n", cast[int](count))
|
|
||||||
|
|
||||||
{.injectStmt: onInject().}
|
|
||||||
echo "ok0"
|
|
||||||
proc main()=
|
|
||||||
echo "ok1"
|
|
||||||
for a in 0..<3:
|
|
||||||
echo a
|
|
||||||
echo "ok2"
|
|
||||||
|
|
||||||
static: main() # xxx injectStmt not honored in VM
|
|
||||||
main()
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue