diff options
author | Araq <rumpf_a@web.de> | 2017-09-05 01:03:45 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-09-05 01:03:45 +0200 |
commit | c02159dde43f6d04e33eb273c336732d557074b5 (patch) | |
tree | e4bf4111b1783c76e819b51cb3485390362a8126 | |
parent | 21e22624a21b7ace0ba8e11aab7e7df583aa0c1e (diff) | |
parent | d539eb53b523dc0e6d1da8f5736592e7739bc20b (diff) | |
download | Nim-c02159dde43f6d04e33eb273c336732d557074b5.tar.gz |
Merge branch 'devel' of github.com:nim-lang/Nim into devel
-rw-r--r-- | compiler/cgen.nim | 10 | ||||
-rw-r--r-- | compiler/ropes.nim | 1 | ||||
-rw-r--r-- | tools/nim.bash-completion | 47 | ||||
-rw-r--r-- | tools/nim.zsh-completion | 76 |
4 files changed, 130 insertions, 4 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 39c14347b..b618837c7 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -215,7 +215,7 @@ proc genLineDir(p: BProc, t: PNode) = {optLineTrace, optStackTrace}) and (p.prc == nil or sfPure notin p.prc.flags) and tt.info.fileIndex >= 0: if freshLineInfo(p, tt.info): - linefmt(p, cpsStmts, "nimln_($1, $2);$N", + linefmt(p, cpsStmts, "nimln_($1, $2);$n", line.rope, tt.info.quotedFilename) proc postStmtActions(p: BProc) {.inline.} = @@ -394,7 +394,8 @@ proc assignLocalVar(p: BProc, s: PSym) = #assert(s.loc.k == locNone) # not yet assigned # this need not be fulfilled for inline procs; they are regenerated # for each module that uses them! - let decl = localVarDecl(p, s) & ";" & tnl + let nl = if optLineDir in gOptions: "" else: tnl + let decl = localVarDecl(p, s) & ";" & nl line(p, cpsLocals, decl) localDebugInfo(p, s) @@ -627,11 +628,11 @@ proc initFrame(p: BProc, procname, filename: Rope): Rope = discard cgsym(p.module, "nimFrame") if p.maxFrameLen > 0: discard cgsym(p.module, "VarSlot") - result = rfmt(nil, "\tnimfrs_($1, $2, $3, $4)$N", + result = rfmt(nil, "\tnimfrs_($1, $2, $3, $4);$n", procname, filename, p.maxFrameLen.rope, p.blocks[0].frameLen.rope) else: - result = rfmt(nil, "\tnimfr_($1, $2)$N", procname, filename) + result = rfmt(nil, "\tnimfr_($1, $2);$n", procname, filename) proc deinitFrame(p: BProc): Rope = result = rfmt(p.module, "\t#popFrame();$n") @@ -1311,6 +1312,7 @@ proc myProcess(b: PPassContext, n: PNode): PNode = if b == nil or passes.skipCodegen(n): return var m = BModule(b) m.initProc.options = initProcOptions(m) + softRnl = if optLineDir in gOptions: noRnl else: rnl genStmts(m.initProc, n) proc finishModule(m: BModule) = diff --git a/compiler/ropes.nim b/compiler/ropes.nim index d84b59f78..358ce8a53 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -228,6 +228,7 @@ proc prepend*(a: var Rope, b: string) = a = b & a var rnl* = tnl.newRope softRnl* = tnl.newRope + noRnl* = "".newRope proc `%`*(frmt: FormatStr, args: openArray[Rope]): Rope = var i = 0 diff --git a/tools/nim.bash-completion b/tools/nim.bash-completion new file mode 100644 index 000000000..4f62da986 --- /dev/null +++ b/tools/nim.bash-completion @@ -0,0 +1,47 @@ +# bash completion for nim -*- shell-script -*- + +_nim() +{ + local cur prev words cword split + _init_completion -s || return + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + if [ $COMP_CWORD -eq 1 ] ; then + # first item - suggest commands + kw="compile c doc doc2 compileToC cc compileToCpp cpp compileToOC objc js e rst2html rst2tex jsondoc jsondoc2 buildIndex genDepend dump check" + COMPREPLY=( $( compgen -W "${kw}" -- $cur ) ) + return 0 + fi + case $prev in + --stackTrace|--lineTrace|--threads|-x|--checks|--objChecks|--fieldChecks|--rangeChecks|--boundChecks|--overflowChecks|-a|--assertions|--floatChecks|--nanChecks|--infChecks|--deadCodeElim) + # Options that require on/off + [[ "$cur" == "=" ]] && cur="" + COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + return 0 + ;; + --opt) + [[ "$cur" == "=" ]] && cur="" + COMPREPLY=( $(compgen -W 'none speed size' -- "$cur") ) + return 0 + ;; + --app) + [[ "$cur" == "=" ]] && cur="" + COMPREPLY=( $(compgen -W 'console gui lib staticlib' -- "$cur") ) + 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=" + COMPREPLY=( $( compgen -W "${kw}" -- $cur ) ) + _filedir '@(nim)' + #$split + return 0 + ;; + esac + return 0 + +} && +complete -onospace -F _nim nim + +# ex: ts=2 sw=2 et filetypesh diff --git a/tools/nim.zsh-completion b/tools/nim.zsh-completion new file mode 100644 index 000000000..3d6e0d5f6 --- /dev/null +++ b/tools/nim.zsh-completion @@ -0,0 +1,76 @@ +#compdef nim + +_nim() { + _arguments -C \ + ':command:(( + {compile,c}\:compile\ project\ with\ default\ code\ generator\ C + doc\:generate\ the\ documentation\ for\ inputfile + doc2\:generate\ the\ documentation\ for\ inputfile + {compileToC,cc}\:compile\ project\ with\ C\ code\ generator + {compileToCpp,cpp}\:compile\ project\ to\ C++\ code + {compileToOC,objc}\:compile\ project\ to\ Objective\ C\ code + js\:compile\ project\ to\ Javascript + e\:run\ a\ Nimscript\ file + rst2html\:convert\ a\ reStructuredText\ file\ to\ HTML + rst2tex\:convert\ a\ reStructuredText\ file\ to\ TeX + jsondoc\:extract\ the\ documentation\ to\ a\ json\ file + jsondoc2\:extract\ documentation\ to\ a\ json\ file\ using\ doc2 + buildIndex\:build\ an\ index\ for\ the\ whole\ documentation + genDepend\:generate\ a\ DOT\ file\ containing\ the\ module\ dependency\ graph + dump\:dump\ all\ defined\ conditionals\ and\ search\ paths + check\:checks\ the\ project\ for\ syntax\ and\ semantic + ))' \ + '*-r[run the application]' \ + '*--run[run the application]' \ + '*-p=[add path to search paths]' \ + '*--path=[add path to search paths]' \ + '*-d=[define a conditional symbol]' \ + '*--define=[define a conditional symbol]' \ + '*-u=[undefine a conditional symbol]' \ + '*--undef=[undefine a conditional symbol]' \ + '*-f[force rebuilding of all modules]' \ + '*--forceBuild[force rebuilding of all modules]' \ + '*--stackTrace=on[turn stack tracing on]' \ + '*--stackTrace=off[turn stack tracing off]' \ + '*--lineTrace=on[turn line tracing on]' \ + '*--lineTrace=off[turn line tracing off]' \ + '*--threads=on[turn support for multi-threading on]' \ + '*--threads=off[turn support for multi-threading off]' \ + '*-x=on[turn all runtime checks on]' \ + '*-x=off[turn all runtime checks off]' \ + '*--checks=on[turn all runtime checks on]' \ + '*--checks=off[turn all runtime checks off]' \ + '*--objChecks=on[turn obj conversion checks on]' \ + '*--objChecks=off[turn obj conversion checks off]' \ + '*--fieldChecks=on[turn case variant field checks on]' \ + '*--fieldChecks=off[turn case variant field checks off]' \ + '*--rangeChecks=on[turn range checks on]' \ + '*--rangeChecks=off[turn range checks off]' \ + '*--boundChecks=on[turn bound checks on]' \ + '*--boundChecks=off[turn bound checks off]' \ + '*--overflowChecks=on[turn int over-/underflow checks on]' \ + '*--overflowChecks=off[turn int over-/underflow checks off]' \ + '*-a[turn assertions on]' \ + '*-a[turn assertions off]' \ + '*--assertions=on[turn assertions on]' \ + '*--assertions=off[turn assertions off]' \ + '*--floatChecks=on[turn all floating point (NaN/Inf) checks on]' \ + '*--floatChecks=off[turn all floating point (NaN/Inf) checks off]' \ + '*--nanChecks=on[turn NaN checks on]' \ + '*--nanChecks=off[turn NaN checks off]' \ + '*--infChecks=on[turn Inf checks on]' \ + '*--infChecks=off[turn Inf 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]' \ + '*--debugger:native|endb[use native debugger (gdb) | ENDB (experimental)]' \ + '*--app=console[generate a console app]' \ + '*--app=gui[generate a GUI app]' \ + '*--app=lib[generate a dynamic library]' \ + '*--app=staticlib[generate a static library]' \ + ':filename:_files -g"*.nim"' +} + +_nim "$@" |