summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2014-07-29 19:34:11 +0200
committerAndreas Rumpf <rumpf_a@web.de>2014-07-29 19:34:11 +0200
commit4eccfb979eeabc18ac671ffd7d83348cd3aa2296 (patch)
treed0620b1ea2f027798e2ae28fb4d809448e981ab5
parent9b63a338f38d6f3872c3224c46571739b9071c03 (diff)
parent1274953507deb1c1210a1e0f152950d5ffe5ad45 (diff)
downloadNim-4eccfb979eeabc18ac671ffd7d83348cd3aa2296.tar.gz
Merge pull request #1422 from def-/nimrod-run2
Allow arguments for "nimrod run"
-rw-r--r--compiler/nimrod.nim2
-rw-r--r--compiler/service.nim2
-rw-r--r--compiler/tccgen.nim8
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..22f5c6e33 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.normalize != "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, "")