Implemented to-host
h3rald h3rald@h3rald.com
Fri, 15 Jul 2016 22:16:54 +0200
3 files changed,
21 insertions(+),
1 deletions(-)
M
core/utils.nim
→
core/utils.nim
@@ -184,6 +184,12 @@ a = i.pop
if not a.isString: raiseInvalid("A string is required on the stack") +proc reqStringLikeAndQuotation*(i: var MinInterpreter, a, q: var MinValue) = + a = i.pop + q = i.pop + if not a.isStringLike or not q.isQuotation: + raiseInvalid("A string or symbol and a quotation are required on the stack") + proc reqStringOrQuotation*(i: var MinInterpreter, a: var MinValue) = a = i.pop if not a.isQuotation and not a.isString:
M
lib/min_comm.nim
→
lib/min_comm.nim
@@ -1,4 +1,4 @@
-import strutils, critbits +import strutils, critbits, streams import ../core/types, ../core/parser,@@ -44,5 +44,18 @@ i.push q
.symbol("host") do (i: In): i.push i.link.name.newSym + + .symbol("to-host") do (i: In): + var h, q: MinValue + i.reqStringLikeAndQuotation(h, q) + let host = h.getString + if not i.link.hosts.hasKey(host): + raiseInvalid("Unknown host: " & host) + let res = i.remoteExec(host, $q & " unquote") + echo res + i.open(newStringStream(res), "to-host") + discard i.parser.getToken() + i.interpret() + .finalize()
M
lib/prelude.min
→
lib/prelude.min
@@ -22,6 +22,7 @@ (load) (@) sigil
(call) (%) sigil (module) (=) sigil (object) (^) sigil +(to-host) (>) sigil ; Aliases 'define ::