remove dead code elimination option (#7669)

This commit is contained in:
Jacek Sieka
2018-04-23 17:02:38 +08:00
committed by Andreas Rumpf
parent a8b70c5500
commit 72dfe176f5
57 changed files with 67 additions and 122 deletions

View File

@@ -262,7 +262,8 @@ type
# variable is a thread variable
sfCompileTime, # proc can be evaluated at compile time
sfConstructor, # proc is a C++ constructor
sfDeadCodeElim, # dead code elimination for the module is turned on
sfDispatcher, # copied method symbol is the dispatcher
# deprecated and unused, except for the con
sfBorrow, # proc is borrowed
sfInfixCall, # symbol needs infix call syntax in target language;
# for interfacing with C++, JS
@@ -275,10 +276,9 @@ type
TSymFlags* = set[TSymFlag]
const
sfDispatcher* = sfDeadCodeElim # copied method symbol is the dispatcher
sfNoInit* = sfMainModule # don't generate code to init the variable
sfImmediate* = sfDeadCodeElim
sfImmediate* = sfDispatcher
# macro or template is immediately expanded
# without considering any possible overloads
sfAllUntyped* = sfVolatile # macro or template is immediately expanded \

View File

@@ -2264,7 +2264,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
of nkEmpty: discard
of nkWhileStmt: genWhileStmt(p, n)
of nkVarSection, nkLetSection: genVarStmt(p, n)
of nkConstSection: genConstStmt(p, n)
of nkConstSection: discard # consts generated lazily on use
of nkForStmt: internalError(n.info, "for statement not eliminated")
of nkCaseStmt: genCase(p, n, d)
of nkReturnStmt: genReturnStmt(p, n)
@@ -2315,8 +2315,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
# are not transformed correctly. We work around this issue (#411) here
# by ensuring it's no inner proc (owner is a module):
if prc.skipGenericOwner.kind == skModule and sfCompileTime notin prc.flags:
if (not emitLazily(prc)) or
({sfExportc, sfCompilerProc} * prc.flags == {sfExportc}) or
if ({sfExportc, sfCompilerProc} * prc.flags == {sfExportc}) or
(sfExportc in prc.flags and lfExportLib in prc.loc.flags) or
(prc.kind == skMethod):
# we have not only the header:

View File

@@ -280,20 +280,6 @@ proc genVarStmt(p: BProc, n: PNode) =
else:
genVarTuple(p, it)
proc genConstStmt(p: BProc, n: PNode) =
for it in n.sons:
if it.kind == nkCommentStmt: continue
if it.kind != nkConstDef: internalError(n.info, "genConstStmt")
let sym = it.sons[0].sym
if sym.typ.containsCompileTimeOnly or
sym.typ.kind notin ConstantDataTypes or
sym.ast.len == 0 or
emitLazily(sym):
continue
requestConstImpl(p, sym)
proc genIf(p: BProc, n: PNode, d: var TLoc) =
#
# { if (!expr1) goto L1;
@@ -587,7 +573,7 @@ proc genRaiseStmt(p: BProc, t: PNode) =
genLineDir(p, t)
if isImportedException(typ):
lineF(p, cpsStmts, "throw $1;$n", [e])
else:
else:
lineCg(p, cpsStmts, "#raiseException((#Exception*)$1, $2);$n",
[e, makeCString(typ.sym.name.s)])
else:
@@ -836,7 +822,7 @@ proc genTryCpp(p: BProc, t: PNode, d: var TLoc) =
else:
for j in 0..t[i].len-2:
if t[i][j].isInfixAs():
let exvar = t[i][j][2] # ex1 in `except ExceptType as ex1:`
let exvar = t[i][j][2] # ex1 in `except ExceptType as ex1:`
fillLoc(exvar.sym.loc, locTemp, exvar, mangleLocalName(p, exvar.sym), OnUnknown)
startBlock(p, "catch ($1& $2) {$n", getTypeDesc(p.module, t[i][j][1].typ), rdLoc(exvar.sym.loc))
else:

View File

@@ -211,8 +211,4 @@ proc mangle*(name: string): string =
if requiresUnderscore:
result.add "_"
proc emitLazily*(s: PSym): bool {.inline.} =
result = optDeadCodeElim in gGlobalOptions or
sfDeadCodeElim in getModule(s).flags
initTypeTables()

View File

@@ -1309,10 +1309,6 @@ proc newModule(g: BModuleList; module: PSym): BModule =
growCache g.modules, module.position
g.modules[module.position] = result
if (optDeadCodeElim in gGlobalOptions):
if (sfDeadCodeElim in module.flags):
internalError("added pending module twice: " & toFilename(FileIndex module.position))
template injectG(config) {.dirty.} =
if graph.backend == nil:
graph.backend = newModuleList(config)

View File

@@ -268,7 +268,6 @@ proc testCompileOption*(switch: string, info: TLineInfo): bool =
of "movechecks": result = contains(gOptions, optMoveCheck)
of "linedir": result = contains(gOptions, optLineDir)
of "assertions", "a": result = contains(gOptions, optAssert)
of "deadcodeelim": result = contains(gGlobalOptions, optDeadCodeElim)
of "run", "r": result = contains(gGlobalOptions, optRun)
of "symbolfiles": result = gSymbolFiles != disabledSf
of "genscript": result = contains(gGlobalOptions, optGenScript)
@@ -509,7 +508,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
of "movechecks": processOnOffSwitch({optMoveCheck}, arg, pass, info)
of "linedir": processOnOffSwitch({optLineDir}, arg, pass, info)
of "assertions", "a": processOnOffSwitch({optAssert}, arg, pass, info)
of "deadcodeelim": processOnOffSwitchG({optDeadCodeElim}, arg, pass, info)
of "deadcodeelim": discard # deprecated, dead code elim always on
of "threads":
processOnOffSwitchG({optThreads}, arg, pass, info)
#if optThreads in gGlobalOptions: incl(gNotes, warnGcUnsafe)

View File

@@ -41,7 +41,8 @@ type # please make sure we have under 32 options
TOptions* = set[TOption]
TGlobalOption* = enum # **keep binary compatible**
gloptNone, optForceFullMake, optDeadCodeElim,
gloptNone, optForceFullMake,
optDeadCodeElimUnused, # deprecated, always on
optListCmd, optCompileOnly, optNoLinking,
optCDebug, # turn on debugging information
optGenDynLib, # generate a dynamic library

View File

@@ -44,7 +44,9 @@ const
wWarnings, wHints,
wLinedir, wStacktrace, wLinetrace, wOptimization, wHint, wWarning, wError,
wFatal, wDefine, wUndef, wCompile, wLink, wLinksys, wPure, wPush, wPop,
wBreakpoint, wWatchPoint, wPassl, wPassc, wDeadCodeElim, wDeprecated,
wBreakpoint, wWatchPoint, wPassl, wPassc,
wDeadCodeElimUnused, # deprecated, always on
wDeprecated,
wFloatchecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll,
wLinearScanEnd, wPatterns, wEffects, wNoForward, wReorder, wComputedGoto,
wInjectStmt, wDeprecated, wExperimental, wThis}
@@ -215,10 +217,6 @@ proc onOff(c: PContext, n: PNode, op: TOptions) =
if isTurnedOn(c, n): gOptions = gOptions + op
else: gOptions = gOptions - op
proc pragmaDeadCodeElim(c: PContext, n: PNode) =
if isTurnedOn(c, n): incl(c.module.flags, sfDeadCodeElim)
else: excl(c.module.flags, sfDeadCodeElim)
proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) =
if isTurnedOn(c, n): incl(c.module.flags, flag)
else: excl(c.module.flags, flag)
@@ -764,7 +762,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
of wThreadVar:
noVal(it)
incl(sym.flags, sfThread)
of wDeadCodeElim: pragmaDeadCodeElim(c, it)
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)
@@ -960,10 +958,6 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
if sym.kind != skType or sym.typ == nil: invalidPragma(it)
else:
incl(sym.typ.flags, tfPartial)
# .partial types can only work with dead code elimination
# to prevent the codegen from doing anything before we compiled
# the whole program:
incl gGlobalOptions, optDeadCodeElim
of wInject, wGensym:
# We check for errors, but do nothing with these pragmas otherwise
# as they are handled directly in 'evalTemplate'.

View File

@@ -55,7 +55,8 @@ type
wFloatchecks, wNanChecks, wInfChecks, wMoveChecks,
wAssertions, wPatterns, wWarnings,
wHints, wOptimization, wRaises, wWrites, wReads, wSize, wEffects, wTags,
wDeadCodeElim, wSafecode, wPackage, wNoForward, wReorder, wNoRewrite,
wDeadCodeElimUnused, # deprecated, dead code elim always happens
wSafecode, wPackage, wNoForward, wReorder, wNoRewrite,
wPragma,
wCompileTime, wNoInit,
wPassc, wPassl, wBorrow, wDiscardable,
@@ -143,7 +144,8 @@ const
"assertions", "patterns", "warnings", "hints",
"optimization", "raises", "writes", "reads", "size", "effects", "tags",
"deadcodeelim", "safecode", "package", "noforward", "reorder", "norewrite",
"deadcodeelim", # deprecated, dead code elim always happens
"safecode", "package", "noforward", "reorder", "norewrite",
"pragma",
"compiletime", "noinit",
"passc", "passl", "borrow", "discardable", "fieldchecks",

View File

@@ -29,7 +29,6 @@ Options:
--nanChecks:on|off turn NaN checks on|off
--infChecks:on|off turn Inf checks on|off
--nilChecks:on|off turn nil checks on|off
--deadCodeElim:on|off whole program dead code elimination on|off
--opt:none|speed|size optimize not at all or for speed|size
Note: use -d:release for a release build!
--debugger:native|endb use native debugger (gdb) | ENDB (experimental)

View File

@@ -6768,22 +6768,6 @@ the created global variables within a module is not defined, but all of them
will be initialized after any top-level variables in their originating module
and before any variable in a module that imports it.
deadCodeElim pragma
-------------------
The ``deadCodeElim`` pragma only applies to whole modules: It tells the
compiler to activate (or deactivate) dead code elimination for the module the
pragma appears in.
The ``--deadCodeElim:on`` command line switch has the same effect as marking
every module with ``{.deadCodeElim:on}``. However, for some modules such as
the GTK wrapper it makes sense to *always* turn on dead code elimination -
no matter if it is globally active or not.
Example:
.. code-block:: nim
{.deadCodeElim: on.}
..
NoForward pragma

View File

@@ -181,7 +181,7 @@ generated; use the ``--symbolFiles:on`` command line switch to activate them.
Unfortunately due to technical reasons the ``--symbolFiles:on`` needs
to *aggregate* some generated C code. This means that the resulting executable
might contain some cruft even when dead code elimination is turned on. So
might contain some cruft even with dead code elimination. So
the final release build should be done with ``--symbolFiles:off``.
Due to the aggregation of C code it is also recommended that each project
@@ -439,7 +439,7 @@ target.
For example, to generate code for an `AVR`:idx: processor use this command::
nim c --cpu:avr --os:standalone --deadCodeElim:on --genScript x.nim
nim c --cpu:avr --os:standalone --genScript x.nim
For the ``standalone`` target one needs to provide
a file ``panicoverride.nim``.

View File

@@ -32,7 +32,7 @@
include "system/inclrtl"
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
when hostOS == "solaris":
{.passl: "-lsocket -lnsl".}

View File

@@ -81,7 +81,7 @@
##
## theDb.close()
{.deadCodeElim:on.}
{.deadCodeElim: on.} # dce option deprecated
import strutils, sqlite3

View File

@@ -13,7 +13,7 @@
## is used. This suffices because Windows' console already provides the
## wanted functionality.
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
when defined(Windows):
proc readLineFromStdin*(prompt: string): TaintedString {.

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
{.deadCodeElim:on.}
{.deadCodeElim: on.} # dce option deprecated
from posix import SocketHandle

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
{.deadCodeElim:on.}
{.deadCodeElim: on.} # dce option deprecated
# Get the platform-dependent flags.
# Structure describing an inotify event.

View File

@@ -7,8 +7,6 @@
# distribution, for details about the copyright.
#
{.deadCodeElim:on.}
from posix import Timespec
when defined(macosx) or defined(freebsd) or defined(openbsd) or
@@ -61,7 +59,7 @@ const
EV_CLEAR* = 0x0020 ## Clear event state after reporting.
EV_RECEIPT* = 0x0040 ## Force EV_ERROR on success, data == 0
EV_DISPATCH* = 0x0080 ## Disable event after reporting.
EV_SYSFLAGS* = 0xF000 ## Reserved by system
EV_DROP* = 0x1000 ## Not should be dropped
EV_FLAG1* = 0x2000 ## Filter-specific flag
@@ -87,10 +85,10 @@ when defined(macosx) or defined(freebsd) or defined(dragonfly):
NOTE_FFAND* = 0x40000000'u32 ## AND fflags
NOTE_FFOR* = 0x80000000'u32 ## OR fflags
NOTE_FFCOPY* = 0xc0000000'u32 ## copy fflags
NOTE_FFCTRLMASK* = 0xc0000000'u32 ## masks for operations
NOTE_FFCTRLMASK* = 0xc0000000'u32 ## masks for operations
NOTE_FFLAGSMASK* = 0x00ffffff'u32
NOTE_TRIGGER* = 0x01000000'u32 ## Cause the event to be triggered
NOTE_TRIGGER* = 0x01000000'u32 ## Cause the event to be triggered
## for output.
# data/hint flags for EVFILT_{READ|WRITE}, shared with userspace

View File

@@ -1,4 +1,4 @@
{.deadCodeElim:on.}
{.deadCodeElim: on.} # dce option deprecated
import posix

View File

@@ -27,10 +27,10 @@
## resulting C code will just ``#include <XYZ.h>`` and *not* define the
## symbols declared here.
# This ensures that we don't accidentally generate #includes for files that
# might not exist on a specific platform! The user will get an error only
# if they actualy try to use the missing declaration
{.deadCodeElim: on.}
# Dead code elimination ensures that we don't accidentally generate #includes
# for files that might not exist on a specific platform! The user will get an
# error only if they actualy try to use the missing declaration
{.deadCodeElim: on.} # dce option deprecated
# TODO these constants don't seem to be fetched from a header file for unknown
# platforms - where do they come from and why are they here?

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
{.deadCodeElim:on.}
{.deadCodeElim: on.} # dce option deprecated
const
hasSpawnH = not defined(haiku) # should exist for every Posix system nowadays

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
import posix
type

View File

@@ -10,7 +10,7 @@
## Floating-point environment. Handling of floating-point rounding and
## exceptions (overflow, division by zero, etc.).
{.deadCodeElim:on.}
{.deadCodeElim: on.} # dce option deprecated
when defined(Posix) and not defined(haiku):
{.passl: "-lm".}

View File

@@ -12,7 +12,7 @@
## **Warning:** This module is deprecated since version 0.14.0.
{.deprecated.}
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
{.push debugger:off .} # the user does not want to trace a part
# of the standard library!

View File

@@ -68,7 +68,7 @@
## ``newSocket()``. The difference is that the latter creates a new file
## descriptor.
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
import nativesockets, os, strutils, parseutils, times, sets, options
export Port, `$`, `==`
export Domain, SockType, Protocol

View File

@@ -10,7 +10,7 @@
## This module contains basic operating system facilities like
## retrieving environment variables, reading command line arguments,
## working with directories, running shell commands, etc.
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
{.push debugger: off.}

View File

@@ -11,7 +11,7 @@
##
## To unpack raw bytes look at the `streams <streams.html>`_ module.
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
{.push debugger:off .} # the user does not want to trace a part
# of the standard library!

View File

@@ -19,7 +19,7 @@
include "system/inclrtl"
import streams
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
{.push debugger:off .} # the user does not want to trace a part
# of the standard library!

View File

@@ -12,7 +12,7 @@
import strutils
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
proc expandTabs*(s: string, tabSize: int = 8): string {.noSideEffect,
procvar.} =

View File

@@ -17,7 +17,7 @@ import parseutils
from math import pow, round, floor, log10
from algorithm import reverse
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
{.push debugger:off .} # the user does not want to trace a part
# of the standard library!

View File

@@ -9,7 +9,7 @@
## This module provides support to handle the Unicode UTF-8 encoding.
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
include "system/inclrtl"

View File

@@ -146,7 +146,7 @@ proc declared*(x: untyped): bool {.magic: "Defined", noSideEffect, compileTime.}
## # missing it.
when defined(useNimRtl):
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
proc definedInScope*(x: untyped): bool {.
magic: "DefinedInScope", noSideEffect, deprecated, compileTime.}

View File

@@ -10,7 +10,7 @@
## This module implements a small wrapper for some needed Win API procedures,
## so that the Nim compiler does not depend on the huge Windows module.
{.deadCodeElim:on.}
{.deadCodeElim: on.} # dce option deprecated
import dynlib

View File

@@ -34,7 +34,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ****************************************************************************
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
when defined(windows):
const dllname = "iup(|30|27|26|25|24).dll"

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
{.push, callconv: cdecl.}
when defined(Unix):

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
when not defined(ODBCVER):
const

View File

@@ -22,7 +22,7 @@
## ./bin/nim c -d:ssl -p:. -r tests/untestable/tssl.nim
## ./bin/nim c -d:ssl -p:. --dynlibOverride:ssl --passL:-lcrypto --passL:-lssl -r tests/untestable/tssl.nim
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
const useWinVersion = defined(Windows) or defined(nimdoc)

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
# The current PCRE version information.

View File

@@ -15,7 +15,7 @@
# connection-protocol.
#
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
when defined(windows):
const

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
{.deadCodeElim: on.}
{.deadCodeElim: on.} # dce option deprecated
when defined(windows):
when defined(nimOldDlls):
const Lib = "sqlite3.dll"

View File

@@ -4,7 +4,7 @@ type
TOption = enum
optNone, optForceFullMake, optBoehmGC, optRefcGC, optRangeCheck,
optBoundsCheck, optOverflowCheck, optNilCheck, optAssert, optLineDir,
optWarns, optHints, optDeadCodeElim, optListCmd, optCompileOnly,
optWarns, optHints, optListCmd, optCompileOnly,
optSafeCode, # only allow safe code
optStyleCheck, optOptimizeSpeed, optOptimizeSize, optGenDynLib,
optGenGuiApp, optStackTrace

View File

@@ -4,8 +4,6 @@ discard """
# bug #2023
{.deadCodeElim:on.}
type
Obj = object
iter: iterator (): int8 {.closure.}

View File

@@ -23,7 +23,6 @@ const Lib = "libchipmunk.so.6.1.1"
when defined(MoreNim):
{.hint: "MoreNim defined; some Chipmunk functions replaced in Nim".}
{.deadCodeElim: on.}
from math import sqrt, sin, cos, arctan2
when defined(CpUseFloat):
{.hint: "CpUseFloat defined; using float32 as float".}

View File

@@ -20,7 +20,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
const Lib = "libenet.so.1(|.0.3)"
{.deadCodeElim: on.}
const
ENET_VERSION_MAJOR* = 1
ENET_VERSION_MINOR* = 3

View File

@@ -1,5 +1,5 @@
import macros
{.deadCodeElim: on.}
#Inline macro.add() to allow for easier nesting
proc und*(a: NimNode; b: NimNode): NimNode {.compileTime.} =
a.add(b)

View File

@@ -12,7 +12,7 @@ else:
LibS = "libcsfml-system.so.2.0"
LibW = "libcsfml-window.so.2.0"
#{.error: "Platform unsupported".}
{.deadCodeElim: on.}
{.pragma: pf, pure, final.}
type
PClock* = ptr TClock

View File

@@ -1,5 +1,5 @@
import sfml
{.deadCodeElim: on.}
let
Black*: TColor = color(0, 0, 0)
White*: TColor = color(255, 255, 255)

View File

@@ -1,2 +1 @@
import sfml, math, strutils
{.deadCodeElim: on.}

View File

@@ -5,7 +5,7 @@ import
sg_gui, sg_assets, sound_buffer, enet_client
when defined(profiler):
import nimprof
{.deadCodeElim: on.}
type
PPlayer* = ref TPlayer
TPlayer* = object

View File

@@ -2,7 +2,7 @@ import
sfml, sfml_colors,
input_helpers, sg_packets
from strutils import countlines
{.deadCodeElim: on.}
type
PGuiContainer* = ref TGuiContainer
TGuiContainer* = object of TObject

View File

@@ -1,5 +1,4 @@
debugger = off
deadCodeElim = on
path = ".."
path = "../genpacket"
path = "../helpers"

View File

@@ -10,7 +10,7 @@ const
ExeName = "keineschweine"
ServerDefines = "-d:NoSFML -d:NoChipmunk"
TestBuildDefines = "-d:escapeMenuTest -d:debugWeps -d:showFPS -d:moreNim -d:debugKeys -d:foo -d:recordMode --forceBuild"
ReleaseDefines = "-d:release --deadCodeElim:on"
ReleaseDefines = "-d:release"
ReleaseTestDefines = "-d:debugWeps -d:debugKeys --forceBuild"
task "testprofile", "..":

View File

@@ -1,3 +1,2 @@
--os:standalone
--deadCodeElim:on
--gc:none

View File

@@ -2,13 +2,16 @@ discard """
ccodeCheck: "\\i @'__attribute__((noreturn))' .*"
"""
proc noret1*(i: int) {.noreturn.} =
proc noret1*(i: int) {.noreturn.} =
echo i
proc noret2*(i: int): void {.noreturn.} =
proc noret2*(i: int): void {.noreturn.} =
echo i
noret1(1)
noret2(2)
var p {.used.}: proc(i: int): int
doAssert(not compiles(
p = proc(i: int): int {.noreturn.} = i # noreturn lambda returns int

View File

@@ -1,6 +1,3 @@
{.deadCodeElim: on.}
proc p1*(x, y: int): int =
result = x + y

View File

@@ -15,7 +15,7 @@ _nim()
return 0
fi
case $prev in
--stackTrace|--lineTrace|--threads|-x|--checks|--objChecks|--fieldChecks|--rangeChecks|--boundChecks|--overflowChecks|-a|--assertions|--floatChecks|--nanChecks|--infChecks|--deadCodeElim)
--stackTrace|--lineTrace|--threads|-x|--checks|--objChecks|--fieldChecks|--rangeChecks|--boundChecks|--overflowChecks|-a|--assertions|--floatChecks|--nanChecks|--infChecks)
# Options that require on/off
[[ "$cur" == "=" ]] && cur=""
COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
@@ -32,7 +32,7 @@ _nim()
return 0
;;
*)
kw="-r -p= --path= -d= --define= -u= --undef= -f --forceBuild --opt= --app= --stackTrace= --lineTrace= --threads= -x= --checks= --objChecks= --fieldChecks= --rangeChecks= --boundChecks= --overflowChecks= -a= --assertions= --floatChecks= --nanChecks= --infChecks= --deadCodeElim="
kw="-r -p= --path= -d= --define= -u= --undef= -f --forceBuild --opt= --app= --stackTrace= --lineTrace= --threads= -x= --checks= --objChecks= --fieldChecks= --rangeChecks= --boundChecks= --overflowChecks= -a= --assertions= --floatChecks= --nanChecks= --infChecks="
COMPREPLY=( $( compgen -W "${kw}" -- $cur ) )
_filedir '@(nim)'
#$split

View File

@@ -60,8 +60,6 @@ _nim() {
'*--infChecks=off[turn Inf checks off]' \
'*--nilChecks=on[turn nil checks on]' \
'*--nilChecks=off[turn nil checks off]' \
'*--deadCodeElim=on[whole program dead code elimination on]' \
'*--deadCodeElim=off[whole program dead code elimination off]' \
'*--opt=none[do not optimize]' \
'*--opt=speed[optimize for speed|size - use -d:release for a release build]' \
'*--opt=size[optimize for size]' \