From a1eb3f2b97e7dc8747cf2d8ba12d2e1b886d6e6d Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 12 Aug 2021 18:49:00 -0600 Subject: [PATCH] extern code use args, not readLine() --- src/kiss/CompilerTools.hx | 2 +- src/kiss/Macros.hx | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/kiss/CompilerTools.hx b/src/kiss/CompilerTools.hx index 913bfa9..2a0759b 100644 --- a/src/kiss/CompilerTools.hx +++ b/src/kiss/CompilerTools.hx @@ -190,7 +190,7 @@ class CompilerTools { } // return an expression for a lambda that calls new Process() that runs the target-specific file - var callingCode = 'function (?inputLines:Array) { return kiss.Prelude.assertProcess("$command", [haxe.io.Path.join(["${args.outputFolder}", "$mainClassName.$scriptExt"])], inputLines); }'; + var callingCode = 'function (?inputLines:Array) { return kiss.Prelude.assertProcess("$command", [haxe.io.Path.join(["${args.outputFolder}", "$mainClassName.$scriptExt"])].concat(inputLines)); }'; #if test trace(callingCode); #end diff --git a/src/kiss/Macros.hx b/src/kiss/Macros.hx index ccd462d..e92a539 100644 --- a/src/kiss/Macros.hx +++ b/src/kiss/Macros.hx @@ -856,21 +856,23 @@ class Macros { bindingList[idx + 1] = untypedName; default: } + stringifyExpList.push(b.the(b.symbol("String"), b.callSymbol("tink.Json.stringify", [b.the(b.symbol(type), bindingList[idx + 1])]))); parseBindingList.push(bindingList[idx]); - parseBindingList.push(b.callSymbol("tink.Json.parse", [b.callField("readLine", b.callSymbol("Sys.stdin", []), [])])); + parseBindingList.push(b.callSymbol("tink.Json.parse", [b.callField("shift", b.symbol("__args__"), [])])); idx += 2; } var externExps = [ - b.print( - b.callSymbol("tink.Json.stringify", [ - b.the(bodyType, if (bindingList.length > 0) { - b.let(parseBindingList, exps); - } else { - b.begin(exps); - }) - ])) + b.let([b.symbol("__args__"), b.callSymbol("Sys.args", [])], + [b.print( + b.callSymbol("tink.Json.stringify", [ + b.the(bodyType, if (bindingList.length > 0) { + b.let(parseBindingList, exps); + } else { + b.begin(exps); + }) + ]))]) ]; b.the( bodyType,