From e6a4213faeb28530e33663d27ff446a5b74b4a5e Mon Sep 17 00:00:00 2001 From: awr <41453959+awr1@users.noreply.github.com> Date: Tue, 4 Sep 2018 15:31:38 -0500 Subject: transformed {.reorder: on.} into {.experimental: codeReordering.}, added tests --- compiler/pragmas.nim | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'compiler/pragmas.nim') diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 263068344..0ef87720d 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -48,7 +48,7 @@ const wDeadCodeElimUnused, # deprecated, always on wDeprecated, wFloatchecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, - wLinearScanEnd, wPatterns, wEffects, wNoForward, wReorder, wComputedGoto, + wLinearScanEnd, wPatterns, wEffects, wComputedGoto, wInjectStmt, wDeprecated, wExperimental, wThis} lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl, wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader, @@ -227,10 +227,6 @@ proc onOff(c: PContext, n: PNode, op: TOptions, resOptions: var TOptions) = if isTurnedOn(c, n): resOptions = resOptions + op else: resOptions = resOptions - op -proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) = - if isTurnedOn(c, n): incl(c.module.flags, flag) - else: excl(c.module.flags, flag) - proc processCallConv(c: PContext, n: PNode) = if n.kind in nkPragmaCallKinds and n.len == 2 and n.sons[1].kind == nkIdent: let sw = whichKeyword(n.sons[1].ident) @@ -724,7 +720,10 @@ proc processExperimental(c: PContext; n: PNode; s: PSym) = case n[1].kind of nkStrLit, nkRStrLit, nkTripleStrLit: try: - c.features.incl parseEnum[Feature](n[1].strVal) + let feature = parseEnum[Feature](n[1].strVal) + c.features.incl feature + if feature == codeReordering: + c.module.flags.incl sfReorder except ValueError: localError(c.config, n[1].info, "unknown experimental feature") else: @@ -815,8 +814,6 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, noVal(c, it) incl(sym.flags, {sfThread, sfGlobal}) of wDeadCodeElimUnused: discard # deprecated, dead code elim always on - of wNoForward: pragmaNoForward(c, it) - of wReorder: pragmaNoForward(c, it, sfReorder) of wMagic: processMagic(c, it, sym) of wCompileTime: noVal(c, it) -- cgit 1.4.1-2-gfad0 From cd3d4faa79d0ae90afa706393ec67f0721ed87be Mon Sep 17 00:00:00 2001 From: awr <41453959+awr1@users.noreply.github.com> Date: Tue, 4 Sep 2018 16:42:37 -0500 Subject: Deny THIS experimental pragma specifically for non-toplevel --- compiler/pragmas.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'compiler/pragmas.nim') diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 910ee799c..fae215556 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -743,7 +743,11 @@ proc processExperimental(c: PContext; n: PNode) = let feature = parseEnum[Feature](n[1].strVal) c.features.incl feature if feature == codeReordering: - c.module.flags.incl sfReorder + if not isTopLevel(c): + localError(c.config, n.info, + "Code reordering experimental pragma only valid at toplevel") + else: + c.module.flags.incl sfReorder except ValueError: localError(c.config, n[1].info, "unknown experimental feature") else: -- cgit 1.4.1-2-gfad0 From c2b09a499c7b4fe255bb57ade50e2736f89aba2c Mon Sep 17 00:00:00 2001 From: awr <41453959+awr1@users.noreply.github.com> Date: Tue, 4 Sep 2018 16:46:43 -0500 Subject: Fix merge --- compiler/pragmas.nim | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'compiler/pragmas.nim') diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index fae215556..8f6b6e362 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -347,7 +347,13 @@ proc processExperimental(c: PContext; n: PNode) = case n[1].kind of nkStrLit, nkRStrLit, nkTripleStrLit: 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: localError(c.config, n[1].info, "unknown experimental feature") else: @@ -732,27 +738,6 @@ proc semCustomPragma(c: PContext, n: PNode): PNode = elif n.kind == nkExprColonExpr: result.kind = n.kind # pragma(arg) -> pragma: arg -proc processExperimental(c: PContext; n: PNode) = - if n.kind notin nkPragmaCallKinds or n.len != 2: - c.features.incl oldExperimentalFeatures - else: - n[1] = c.semConstExpr(c, n[1]) - case n[1].kind - of nkStrLit, nkRStrLit, nkTripleStrLit: - try: - 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") - else: - c.module.flags.incl sfReorder - except ValueError: - localError(c.config, n[1].info, "unknown experimental feature") - else: - localError(c.config, n.info, errStringLiteralExpected) - proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, validPragmas: TSpecialWords): bool = var it = n.sons[i] -- cgit 1.4.1-2-gfad0 From 2b8c4096a48449d424db6869c7281c837e3e0904 Mon Sep 17 00:00:00 2001 From: awr <41453959+awr1@users.noreply.github.com> Date: Wed, 5 Sep 2018 09:03:44 -0500 Subject: brought back pragmaNoForward, deprecated --- compiler/pragmas.nim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'compiler/pragmas.nim') diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 8f6b6e362..aa0783bd5 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -230,6 +230,19 @@ proc onOff(c: PContext, n: PNode, op: TOptions, resOptions: var TOptions) = if isTurnedOn(c, n): resOptions = resOptions + op else: resOptions = resOptions - op +proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) = + if isTurnedOn(c, n): + 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) = if n.kind in nkPragmaCallKinds and n.len == 2 and n.sons[1].kind == nkIdent: let sw = whichKeyword(n.sons[1].ident) @@ -823,6 +836,8 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, noVal(c, it) incl(sym.flags, {sfThread, sfGlobal}) of wDeadCodeElimUnused: discard # deprecated, dead code elim always on + of wNoForward: pragmaNoForward(c, it) + of wReorder: pragmaNoForward(c, it, flag = sfReorder) of wMagic: processMagic(c, it, sym) of wCompileTime: noVal(c, it) -- cgit 1.4.1-2-gfad0 From e3d7056902550f85cee68ee0cddfe4d944b4e815 Mon Sep 17 00:00:00 2001 From: awr <41453959+awr1@users.noreply.github.com> Date: Fri, 7 Sep 2018 11:28:01 -0500 Subject: fixed stmtPragmas stuff --- compiler/pragmas.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler/pragmas.nim') diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index aa0783bd5..9bc3f353e 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -48,7 +48,7 @@ const wDeadCodeElimUnused, # deprecated, always on wDeprecated, wFloatchecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, - wLinearScanEnd, wPatterns, wEffects, wComputedGoto, + wLinearScanEnd, wPatterns, wEffects, wNoForward, wReorder, wComputedGoto, wInjectStmt, wDeprecated, wExperimental, wThis} lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl, wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader, -- cgit 1.4.1-2-gfad0