diff options
author | Andreas Rumpf <andreas@andreas-laptop> | 2010-04-02 19:34:57 +0200 |
---|---|---|
committer | Andreas Rumpf <andreas@andreas-laptop> | 2010-04-02 19:34:57 +0200 |
commit | f530bbd6315f21469d7479991186e88302608726 (patch) | |
tree | 8b05aba5a3d407d50160c448fa2ba5b2fa952a6f /tools/nimrepl.nim | |
parent | 227b76c34259cf406131d27fb8e0cc88530e38f7 (diff) | |
download | Nim-f530bbd6315f21469d7479991186e88302608726.tar.gz |
tiny C backend for a much faster REPL
Diffstat (limited to 'tools/nimrepl.nim')
-rwxr-xr-x | tools/nimrepl.nim | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tools/nimrepl.nim b/tools/nimrepl.nim index bf0578285..210ac2467 100755 --- a/tools/nimrepl.nim +++ b/tools/nimrepl.nim @@ -1,20 +1,22 @@ -import glib2, gtk2, gdk2, osproc, dialogs, strutils - -type - output = tuple[compiler, app: string] +# +# +# Nimrod REPL +# (c) Copyright 2010 Dominik Picheta +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# -proc execCode(code: string): output = +import glib2, gtk2, gdk2, osproc, dialogs, strutils +proc execCode(code: string): string = var f: TFile if open(f, "temp.nim", fmWrite): f.write(code) f.close() else: - raise newException(EIO, "Unable to open file") - - var compilerOutput = osproc.execProcess("nimrod c temp.nim") - var appOutput = osproc.execProcess("temp.exe") - return (compilerOutput, appOutput) + raise newException(EIO, "Unable to open file") + result = osproc.execProcess("nimrod run --verbosity:0 temp.nim") var shiftPressed = False var w: gtk2.PWindow @@ -83,8 +85,8 @@ proc inputKeyReleased(widget: PWidget, event: PEventKey, try: var r = execCode($InputText) - set_text(OutputTextBuffer, r[0] & r[1], len(r[0] & r[1])) - except: + set_text(OutputTextBuffer, r, len(r)) + except EIO: setError("Error: Could not open file temp.nim") |