Merge pull request #8875 from awr1/experimentalize-reorder
Experimentalize reorder (Changes {.reorder: on.} to {.experimental: "codeReordering".})
This commit is contained in:
commit
5fa4fa185b
5 changed files with 27 additions and 10 deletions
|
|
@ -121,7 +121,8 @@ type
|
||||||
notnil,
|
notnil,
|
||||||
dynamicBindSym,
|
dynamicBindSym,
|
||||||
forLoopMacros,
|
forLoopMacros,
|
||||||
caseStmtMacros
|
caseStmtMacros,
|
||||||
|
codeReordering,
|
||||||
|
|
||||||
SymbolFilesOption* = enum
|
SymbolFilesOption* = enum
|
||||||
disabledSf, writeOnlySf, readOnlySf, v2Sf
|
disabledSf, writeOnlySf, readOnlySf, v2Sf
|
||||||
|
|
|
||||||
|
|
@ -231,8 +231,17 @@ proc onOff(c: PContext, n: PNode, op: TOptions, resOptions: var TOptions) =
|
||||||
else: resOptions = resOptions - op
|
else: resOptions = resOptions - op
|
||||||
|
|
||||||
proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) =
|
proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) =
|
||||||
if isTurnedOn(c, n): incl(c.module.flags, flag)
|
if isTurnedOn(c, n):
|
||||||
else: excl(c.module.flags, flag)
|
incl(c.module.flags, flag)
|
||||||
|
c.features.incl codeReordering
|
||||||
|
else:
|
||||||
|
excl(c.module.flags, flag)
|
||||||
|
# c.features.excl codeReordering
|
||||||
|
|
||||||
|
# deprecated as of 0.18.1
|
||||||
|
message(c.config, n.info, warnDeprecated,
|
||||||
|
"use {.experimental: \"codeReordering.\".} instead; " &
|
||||||
|
(if flag == sfNoForward: "{.noForward.}" else: "{.reorder.}"))
|
||||||
|
|
||||||
proc processCallConv(c: PContext, n: PNode) =
|
proc processCallConv(c: PContext, n: PNode) =
|
||||||
if n.kind in nkPragmaCallKinds and n.len == 2 and n.sons[1].kind == nkIdent:
|
if n.kind in nkPragmaCallKinds and n.len == 2 and n.sons[1].kind == nkIdent:
|
||||||
|
|
@ -351,7 +360,13 @@ proc processExperimental(c: PContext; n: PNode) =
|
||||||
case n[1].kind
|
case n[1].kind
|
||||||
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
||||||
try:
|
try:
|
||||||
c.features.incl parseEnum[Feature](n[1].strVal)
|
let feature = parseEnum[Feature](n[1].strVal)
|
||||||
|
c.features.incl feature
|
||||||
|
if feature == codeReordering:
|
||||||
|
if not isTopLevel(c):
|
||||||
|
localError(c.config, n.info,
|
||||||
|
"Code reordering experimental pragma only valid at toplevel")
|
||||||
|
c.module.flags.incl sfReorder
|
||||||
except ValueError:
|
except ValueError:
|
||||||
localError(c.config, n[1].info, "unknown experimental feature")
|
localError(c.config, n[1].info, "unknown experimental feature")
|
||||||
else:
|
else:
|
||||||
|
|
@ -817,7 +832,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
|
||||||
incl(sym.flags, {sfThread, sfGlobal})
|
incl(sym.flags, {sfThread, sfGlobal})
|
||||||
of wDeadCodeElimUnused: discard # deprecated, dead code elim always on
|
of wDeadCodeElimUnused: discard # deprecated, dead code elim always on
|
||||||
of wNoForward: pragmaNoForward(c, it)
|
of wNoForward: pragmaNoForward(c, it)
|
||||||
of wReorder: pragmaNoForward(c, it, sfReorder)
|
of wReorder: pragmaNoForward(c, it, flag = sfReorder)
|
||||||
of wMagic: processMagic(c, it, sym)
|
of wMagic: processMagic(c, it, sym)
|
||||||
of wCompileTime:
|
of wCompileTime:
|
||||||
noVal(c, it)
|
noVal(c, it)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ discard """
|
||||||
disabled: true
|
disabled: true
|
||||||
"""
|
"""
|
||||||
|
|
||||||
{. noforward: on .}
|
# {. noforward: on .}
|
||||||
|
{.experimental: "codeReordering".}
|
||||||
|
|
||||||
proc foo(x: int) =
|
proc foo(x: int) =
|
||||||
bar x
|
bar x
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ defined
|
||||||
3'''
|
3'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
{.reorder: on.}
|
{.experimental: "codeReordering".}
|
||||||
{.experimental.}
|
|
||||||
|
|
||||||
proc bar(x: T)
|
proc bar(x: T)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ output:'''0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import macros
|
import macros
|
||||||
{.reorder: on .}
|
# {.reorder: on .}
|
||||||
|
{.experimental: "codeReordering".}
|
||||||
|
|
||||||
echo foo(-1)
|
echo foo(-1)
|
||||||
echo callWithFoo(0)
|
echo callWithFoo(0)
|
||||||
|
|
@ -71,4 +72,4 @@ macro make(arg: untyped): untyped =
|
||||||
proc first(i: int): void =
|
proc first(i: int): void =
|
||||||
make(second)
|
make(second)
|
||||||
|
|
||||||
var ss {.compileTime.}: string = ""
|
var ss {.compileTime.}: string = ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue