diff options
author | def <dennis@felsin9.de> | 2014-07-28 17:41:00 +0200 |
---|---|---|
committer | def <dennis@felsin9.de> | 2014-07-28 17:41:00 +0200 |
commit | d9b5ae13be7c7f9e92a5af4fa4274eae8c57397f (patch) | |
tree | a18a89e36465ad97ec5f05bdafe0e3d6fbbe3e1a /compiler | |
parent | f59d76a59e73f4b9697796535929d9337936cdd4 (diff) | |
download | Nim-d9b5ae13be7c7f9e92a5af4fa4274eae8c57397f.tar.gz |
Allow arguments for "nimrod run"
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/nimrod.nim | 2 | ||||
-rw-r--r-- | compiler/service.nim | 2 | ||||
-rw-r--r-- | compiler/tccgen.nim | 8 |
3 files changed, 5 insertions, 7 deletions
diff --git a/compiler/nimrod.nim b/compiler/nimrod.nim index efe3d83bf..ea7621b09 100644 --- a/compiler/nimrod.nim +++ b/compiler/nimrod.nim @@ -58,7 +58,7 @@ proc handleCmdLine() = if msgs.gErrorCounter == 0: when hasTinyCBackend: if gCmd == cmdRun: - tccgen.run() + tccgen.run(service.arguments) if optRun in gGlobalOptions: if gCmd == cmdCompileToJS: var ex: string diff --git a/compiler/service.nim b/compiler/service.nim index 2b861e1c7..eab995276 100644 --- a/compiler/service.nim +++ b/compiler/service.nim @@ -59,7 +59,7 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) = inc argsCount if pass == passCmd2: - if optRun notin gGlobalOptions and arguments != "": + if optRun notin gGlobalOptions and arguments != "" and options.command != "run": rawMessage(errArgsNeedRunOption, []) proc serve*(action: proc (){.nimcall.}) = diff --git a/compiler/tccgen.nim b/compiler/tccgen.nim index 9ed6db8a1..a571d416e 100644 --- a/compiler/tccgen.nim +++ b/compiler/tccgen.nim @@ -68,11 +68,9 @@ proc compileCCode*(ccode: string) = setupEnvironment() discard compileString(gTinyC, ccode) -proc run*() = - var a: array[0..1, cstring] - a[0] = "" - a[1] = "" - var err = tinyc.run(gTinyC, 0'i32, cast[cstringArray](addr(a))) != 0'i32 +proc run*(args: string) = + var s = @[cstring(gProjectName)] & map(split(args), proc(x: string): cstring = cstring(x)) + var err = tinyc.run(gTinyC, cint(len(s)), cast[cstringArray](addr(s[0]))) != 0'i32 closeCCState(gTinyC) if err: rawMessage(errExecutionOfProgramFailed, "") |