diff --git a/ts2panda/src/cmdOptions.ts b/ts2panda/src/cmdOptions.ts index 72bd24cc4f070ddeb5c49ca7e63a01e8ae088255..e4117916096bbd6172620adc75d6ac1b009c1d0e 100644 --- a/ts2panda/src/cmdOptions.ts +++ b/ts2panda/src/cmdOptions.ts @@ -24,7 +24,7 @@ import { execute } from "./base/util"; const ts2pandaOptions = [ { name: 'variant-bytecode', alias: 'r', type: Boolean, defaultValue: true, description: "emit 2nd bytecode to pandafile." }, { name: 'modules', alias: 'm', type: Boolean, defaultValue: false, description: "compile as module." }, - { name: 'debug-log', alias: 'l', type: Boolean, defaultValue: false, description: "show info debug log." }, + { name: 'debug-log', alias: 'l', type: Boolean, defaultValue: false, description: "show info debug log and generate the json file."}, { name: 'dump-assembly', alias: 'a', type: Boolean, defaultValue: false, description: "dump assembly to file." }, { name: 'debug', alias: 'd', type: Boolean, defaultValue: false, description: "compile with debug info." }, { name: 'show-statistics', alias: 's', type: String, lazyMultiple: true, defaultValue: "", description: "show compile statistics(ast, histogram, hoisting, all)." }, diff --git a/ts2panda/src/ts2panda.ts b/ts2panda/src/ts2panda.ts index af9cf1e7820f8660e83951d1fb56393661884376..6e0d6e7cd998823d434bf796f1d7ba567171bcc9 100644 --- a/ts2panda/src/ts2panda.ts +++ b/ts2panda/src/ts2panda.ts @@ -129,9 +129,6 @@ export class Ts2Panda { static dumpStringsArray(ts2abc: any) { let strings_arr = Array.from(Ts2Panda.strings); - if (CmdOptions.isEnableDebugLog()) { - Ts2Panda.jsonString += escapeUnicode(JSON.stringify(strings_arr, null, 2)); - } strings_arr.forEach(function(str) { let strObject = { @@ -139,8 +136,10 @@ export class Ts2Panda { "string": str } let jsonStrUnicode = escapeUnicode(JSON.stringify(strObject, null, 2)); - Ts2Panda.jsonString += jsonStrUnicode; jsonStrUnicode = "$" + jsonStrUnicode.replace(dollarSign, '#$') + "$"; + if (CmdOptions.isEnableDebugLog()) { + Ts2Panda.jsonString += jsonStrUnicode; + } ts2abc.stdio[3].write(jsonStrUnicode + '\n'); }); } @@ -167,10 +166,6 @@ export class Ts2Panda { } } - if (CmdOptions.isEnableDebugLog()) { - Ts2Panda.jsonString += escapeUnicode(JSON.stringify(literalArrays, null, 2)); - } - literalArrays.forEach(function(literalArray) { let literalArrayObject = { "type": JsonType.literal_arr, @@ -178,6 +173,9 @@ export class Ts2Panda { } let jsonLiteralArrUnicode = escapeUnicode(JSON.stringify(literalArrayObject, null, 2)); jsonLiteralArrUnicode = "$" + jsonLiteralArrUnicode.replace(dollarSign, '#$') + "$"; + if (CmdOptions.isEnableDebugLog()) { + Ts2Panda.jsonString += jsonLiteralArrUnicode; + } ts2abc.stdio[3].write(jsonLiteralArrUnicode + '\n'); }); } @@ -192,10 +190,10 @@ export class Ts2Panda { "opt_log_level": CmdOptions.getOptLogLevel() }; let jsonOpt = JSON.stringify(options, null, 2); + jsonOpt = "$" + jsonOpt.replace(dollarSign, '#$') + "$"; if (CmdOptions.isEnableDebugLog()) { Ts2Panda.jsonString += jsonOpt; } - jsonOpt = "$" + jsonOpt.replace(dollarSign, '#$') + "$"; ts2abc.stdio[3].write(jsonOpt + '\n'); } @@ -279,10 +277,10 @@ export class Ts2Panda { "func_body": func } let jsonFuncUnicode = escapeUnicode(JSON.stringify(funcObject, null, 2)); + jsonFuncUnicode = "$" + jsonFuncUnicode.replace(dollarSign, '#$') + "$"; if (CmdOptions.isEnableDebugLog()) { Ts2Panda.jsonString += jsonFuncUnicode; } - jsonFuncUnicode = "$" + jsonFuncUnicode.replace(dollarSign, '#$') + "$"; ts2abc.stdio[3].write(jsonFuncUnicode + '\n'); }