Nimscript supports hint() and warning() procs; refs #3688

This commit is contained in:
Andreas Rumpf 2016-07-08 22:24:28 +02:00
commit e2267ef5c9
4 changed files with 24 additions and 3 deletions

View file

@ -158,7 +158,7 @@ var
enableNotes: TNoteKinds enableNotes: TNoteKinds
disableNotes: TNoteKinds disableNotes: TNoteKinds
proc processSpecificNote(arg: string, state: TSpecialWord, pass: TCmdLinePass, proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
info: TLineInfo; orig: string) = info: TLineInfo; orig: string) =
var id = "" # arg = "X]:on|off" var id = "" # arg = "X]:on|off"
var i = 0 var i = 0

View file

@ -13,7 +13,7 @@
import import
ast, modules, passes, passaux, condsyms, ast, modules, passes, passaux, condsyms,
options, nimconf, lists, sem, semdata, llstream, vm, vmdef, commands, msgs, options, nimconf, lists, sem, semdata, llstream, vm, vmdef, commands, msgs,
os, times, osproc os, times, osproc, wordrecg
# we support 'cmpIgnoreStyle' natively for efficiency: # we support 'cmpIgnoreStyle' natively for efficiency:
from strutils import cmpIgnoreStyle from strutils import cmpIgnoreStyle
@ -116,7 +116,12 @@ proc setupVM*(module: PSym; scriptName: string): PEvalContext =
setResult(a, options.command) setResult(a, options.command)
cbconf switch: cbconf switch:
processSwitch(a.getString 0, a.getString 1, passPP, unknownLineInfo()) processSwitch(a.getString 0, a.getString 1, passPP, unknownLineInfo())
cbconf hintImpl:
processSpecificNote(a.getString 0, wHint, passPP, unknownLineInfo(),
a.getString 1)
cbconf warningImpl:
processSpecificNote(a.getString 0, wWarning, passPP, unknownLineInfo(),
a.getString 1)
proc runNimScript*(scriptName: string; freshDefines=true) = proc runNimScript*(scriptName: string; freshDefines=true) =
passes.gIncludeFile = includeModule passes.gIncludeFile = includeModule

View file

@ -39,6 +39,9 @@ proc getCurrentDir(): string = builtin
proc rawExec(cmd: string): int {.tags: [ExecIOEffect], raises: [OSError].} = proc rawExec(cmd: string): int {.tags: [ExecIOEffect], raises: [OSError].} =
builtin builtin
proc warningImpl(arg, orig: string) = discard
proc hintImpl(arg, orig: string) = discard
proc paramStr*(i: int): string = proc paramStr*(i: int): string =
## Retrieves the ``i``'th command line parameter. ## Retrieves the ``i``'th command line parameter.
builtin builtin
@ -52,6 +55,16 @@ proc switch*(key: string, val="") =
## example ``switch("checks", "on")``. ## example ``switch("checks", "on")``.
builtin builtin
proc warning*(name: string; val: bool) =
## Disables or enables a specific warning.
let v = if val: "on" else: "off"
warningImpl(name & "]:" & v, "warning[" & name & "]:" & v)
proc hint*(name: string; val: bool) =
## Disables or enables a specific hint.
let v = if val: "on" else: "off"
hintImpl(name & "]:" & v, "hint[" & name & "]:" & v)
proc getCommand*(): string = proc getCommand*(): string =
## Gets the Nim command that the compiler has been invoked with, for example ## Gets the Nim command that the compiler has been invoked with, for example
## "c", "js", "build", "help". ## "c", "js", "build", "help".

View file

@ -8,6 +8,9 @@ import ospaths
--forceBuild --forceBuild
warning("uninit", off)
hint("processing", off)
task listDirs, "lists every subdirectory": task listDirs, "lists every subdirectory":
for x in listDirs("."): for x in listDirs("."):
echo "DIR ", x echo "DIR ", x