From e3b7552f9a3d4e4cfb77e4cb64566fc40cfb5f37 Mon Sep 17 00:00:00 2001 From: gavin1012_hw Date: Mon, 25 Jul 2022 14:33:27 +0800 Subject: [PATCH] Improve ts2abc performance in watch and report error when transform bad expression 1. Improve ts2abc process performance in watch 2. Report the error when user enter bad expression for watching Issue: I5FXUI Signed-off-by: gavin1012_hw Change-Id: Iab7c9813ac29d108612b6cd247fe951b8cd5dcff --- ts2panda/src/cmdOptions.ts | 46 +++-- ts2panda/src/compiler.ts | 19 +- ts2panda/src/index.ts | 164 ++++++++++++------ ts2panda/src/pandagen.ts | 4 +- ts2panda/tests/utils/base.ts | 2 +- .../tests/watch_expression/addWatch.test.ts | 56 +++--- 6 files changed, 186 insertions(+), 105 deletions(-) diff --git a/ts2panda/src/cmdOptions.ts b/ts2panda/src/cmdOptions.ts index 980ec2c5d7..69f1cd6fde 100644 --- a/ts2panda/src/cmdOptions.ts +++ b/ts2panda/src/cmdOptions.ts @@ -27,7 +27,7 @@ const ts2pandaOptions = [ { 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: 'debug-add-watch', alias: 'w', type: String, lazyMultiple: true, defaultValue: [], description: "watch expression and abc file path in debug mode." }, + { name: 'debug-add-watch', alias: 'w', type: String, lazyMultiple: true, defaultValue: [], description: "watch expression, abc file path and maybe watchTimeOut(in seconds) in debug mode." }, { name: 'keep-persistent-watch', alias: 'k', type: String, lazyMultiple: true, defaultValue: [], description: "keep persistent watch on js file with watched expression." }, { name: 'show-statistics', alias: 's', type: String, lazyMultiple: true, defaultValue: "", description: "show compile statistics(ast, histogram, hoisting, all)." }, { name: 'output', alias: 'o', type: String, defaultValue: "", description: "set output file." }, @@ -82,37 +82,49 @@ export class CmdOptions { return this.options["debug"]; } - static getAddWatchArgs(): string[] { + static setWatchEvaluateExpressionArgs(watchArgs: string[]) { + this.options["debug-add-watch"] = watchArgs; + } + + static getDeamonModeArgs(): string[] { if (!this.options) { return []; } - return this.options["debug-add-watch"]; + return this.options["keep-persistent-watch"]; } - static isWatchMode(): boolean { - if (!this.options) { - return false; - } - return this.options["debug-add-watch"].length != 0; + static isWatchEvaluateDeamonMode(): boolean { + return CmdOptions.getDeamonModeArgs()[0] == "start"; } - static setWatchArgs(watchArgs: string[]) { - this.options["debug-add-watch"] = watchArgs; + static isStopEvaluateDeamonMode(): boolean { + return CmdOptions.getDeamonModeArgs()[0] == "stop"; } - static getKeepWatchFile(): string[] { + static getEvaluateDeamonPath(): string { + return CmdOptions.getDeamonModeArgs()[1]; + } + + static isWatchEvaluateExpressionMode(): boolean { if (!this.options) { - return []; + return false; } - return this.options["keep-persistent-watch"]; + return this.options["debug-add-watch"].length != 0; } - static isKeepWatchMode(args: string[]): boolean { - return args.length == 2 && args[0] == "start"; + static getEvaluateExpression(): string { + return this.options["debug-add-watch"][0]; } - static isStopWatchMode(args: string[]): boolean { - return args.length == 2 && args[0] == "stop"; + static getWatchJsPath(): string { + return this.options["debug-add-watch"][1]; + } + + static getWatchTimeOutValue(): number { + if (this.options["debug-add-watch"].length == 2) { + return 0; + } + return this.options["debug-add-watch"][2]; } static isCommonJs(): boolean { diff --git a/ts2panda/src/compiler.ts b/ts2panda/src/compiler.ts index fcc8536e36..d47b3e06ff 100644 --- a/ts2panda/src/compiler.ts +++ b/ts2panda/src/compiler.ts @@ -328,7 +328,8 @@ export class Compiler { this.funcBuilder.resolve(NodeKind.Invalid, getVregisterCache(pandaGen, CacheList.undefined)); pandaGen.return(NodeKind.Invalid); } else { - CmdOptions.isWatchMode() ? pandaGen.return(NodeKind.Invalid) : pandaGen.returnUndefined(NodeKind.Invalid); + CmdOptions.isWatchEvaluateExpressionMode() ? + pandaGen.return(NodeKind.Invalid) : pandaGen.returnUndefined(NodeKind.Invalid); } } @@ -978,8 +979,9 @@ export class Compiler { // typeof an undeclared variable will return undefined instead of throwing reference error let parent = findOuterNodeOfParenthesis(id); if ((parent.kind == ts.SyntaxKind.TypeOfExpression)) { - CmdOptions.isWatchMode() ? pandaGen.loadByNameViaDebugger(id, name, CacheList.False) - : pandaGen.loadObjProperty(id, getVregisterCache(pandaGen, CacheList.Global), name); + CmdOptions.isWatchEvaluateExpressionMode() ? + pandaGen.loadByNameViaDebugger(id, name, CacheList.False) : + pandaGen.loadObjProperty(id, getVregisterCache(pandaGen, CacheList.Global), name); } else { pandaGen.tryLoadGlobalByName(id, name); } @@ -1047,8 +1049,8 @@ export class Compiler { scope.setLexVar(v, this.scope); } } - CmdOptions.isWatchMode() ? pandaGen.loadByNameViaDebugger(node, "this", CacheList.True) - : pandaGen.loadAccFromLexEnv(node, scope!, level, v); + CmdOptions.isWatchEvaluateExpressionMode() ? pandaGen.loadByNameViaDebugger(node, "this", CacheList.True) + : pandaGen.loadAccFromLexEnv(node, scope!, level, v); } else { throw new Error("\"this\" must be a local variable"); } @@ -1614,9 +1616,10 @@ export class Compiler { if (variable.v.isNone()) { let parent = findOuterNodeOfParenthesis(node); if ((parent.kind == ts.SyntaxKind.TypeOfExpression)) { - CmdOptions.isWatchMode() ? this.pandaGen.loadByNameViaDebugger(node, variable.v.getName(), - CacheList.False) : this.pandaGen.loadObjProperty(node, getVregisterCache(this.pandaGen, - CacheList.Global), variable.v.getName()); + CmdOptions.isWatchEvaluateExpressionMode() ? + this.pandaGen.loadByNameViaDebugger(node, variable.v.getName(), CacheList.False) : + this.pandaGen.loadObjProperty(node, getVregisterCache(this.pandaGen, CacheList.Global), + variable.v.getName()); } else { this.pandaGen.tryLoadGlobalByName(node, variable.v.getName()); } diff --git a/ts2panda/src/index.ts b/ts2panda/src/index.ts index e1b34e285c..aef91b98df 100644 --- a/ts2panda/src/index.ts +++ b/ts2panda/src/index.ts @@ -168,72 +168,140 @@ function getDtsFiles(libDir: string): string[] { } const stopWatchingStr = "####"; -const watchAbcFileTimeOut = 5000; +const watchAbcFileDefaultTimeOut = 10; const watchFileName = "watch_expressions"; -function updateWatchedFile() { - let watchArgs = CmdOptions.getAddWatchArgs(); - let ideIputStr = watchArgs[0]; - if (watchArgs.length != 2 || !isBase64Str(ideIputStr)) { - throw new Error("Incorrect args' format or not enter base64 string in watch mode"); +function updateWatchJsFile() { + let ideIputStr = CmdOptions.getEvaluateExpression(); + if (!isBase64Str(ideIputStr)) { + throw new Error("Passed expression string for evaluating is not base64 style."); } - let fragmentSep = "\\n"; + let watchAbcFileTimeOut = watchAbcFileDefaultTimeOut; + if (CmdOptions.getWatchTimeOutValue() != 0) { watchAbcFileTimeOut = CmdOptions.getWatchTimeOutValue(); } + let watchFilePrefix = CmdOptions.getWatchJsPath() + path.sep + watchFileName; let originExpre = Buffer.from(ideIputStr, 'base64').toString(); - let expressiones = originExpre.split(fragmentSep); - let jsFileName = watchArgs[1] + path.sep + watchFileName + ".js"; - let abcFileName = watchArgs[1] + path.sep + watchFileName + ".abc"; - let writeFlag: Boolean = false; - for (let index = 0; index < expressiones.length; index++) { - let expreLine = expressiones[index].trim(); - if (expreLine != "") { - if (!writeFlag) { - fs.writeFileSync(jsFileName, expreLine + "\n"); - writeFlag = true; - } else { - fs.appendFileSync(jsFileName, expreLine + "\n"); - } - } - } - if (CmdOptions.isAssemblyMode()) { - return; - } + let jsFileName = watchFilePrefix + ".js"; + let abcFileName = watchFilePrefix + ".abc"; + let errorMsgFileName = watchFilePrefix + ".err"; + fs.watchFile(errorMsgFileName, { persistent: true, interval: 50 }, (curr, prev) => { + if (+curr.mtime <= +prev.mtime) { + fs.unwatchFile(jsFileName); + fs.unwatchFile(abcFileName); + throw new Error("watched errMsg file has not been initialized"); + } + console.log("error in genarate abc file for this expression."); + fs.unwatchFile(abcFileName); + fs.unwatchFile(errorMsgFileName); + process.exit(); + }); fs.watchFile(abcFileName, { persistent: true, interval: 50 }, (curr, prev) => { if (+curr.mtime <= +prev.mtime) { fs.unwatchFile(jsFileName); + fs.unwatchFile(errorMsgFileName); throw new Error("watched abc file has not been initialized"); } let base64data = fs.readFileSync(abcFileName); let watchResStr = Buffer.from(base64data).toString('base64'); console.log(watchResStr); fs.unwatchFile(abcFileName); + fs.unwatchFile(errorMsgFileName); process.exit(); }); + fs.writeFileSync(jsFileName, originExpre); setTimeout(() => { fs.unwatchFile(jsFileName); fs.unwatchFile(abcFileName); + fs.unwatchFile(errorMsgFileName); fs.unlinkSync(jsFileName); fs.unlinkSync(abcFileName); + fs.unlinkSync(errorMsgFileName); throw new Error("watchFileServer has not been initialized"); - }, watchAbcFileTimeOut); + }, watchAbcFileTimeOut*1000); } -function convertWatchExpression(jsfileName: string, parsed: ts.ParsedCommandLine | undefined) { - let files: string[] = parsed.fileNames; - files.unshift(jsfileName); - CmdOptions.setWatchArgs(['','']); - main(files.concat(CmdOptions.getIncludedFiles()), parsed.options); +function compileWatchExpression(jsFileName: string, errorMsgFileName: string, options: ts.CompilerOptions, + watchedProgram: ts.Program) { + CmdOptions.setWatchEvaluateExpressionArgs(['','']); + let fileName = watchFileName + ".js"; + let errorMsgRecordFlag = false; + let sourceFile = ts.createSourceFile(fileName, fs.readFileSync(jsFileName).toString(), ts.ScriptTarget.ES2017); + let jsFileDiagnostics = watchedProgram.getSyntacticDiagnostics(sourceFile); + jsFileDiagnostics.forEach(diagnostic => { + if (!errorMsgRecordFlag) { + fs.writeFileSync(errorMsgFileName, "There are syntax errors in input expression.\n"); + errorMsgRecordFlag = true; + } + diag.printDiagnostic(diagnostic); + return; + }); + if (errorMsgRecordFlag) { + return; + } + watchedProgram.emit( + undefined, + undefined, + undefined, + undefined, + { + before: [ + // @ts-ignore + (ctx: ts.TransformationContext) => { + return (node: ts.SourceFile) => { + if (path.basename(node.fileName) == fileName) { node = sourceFile; } + let outputBinName = getOutputBinName(node); + let compilerDriver = new CompilerDriver(outputBinName); + compilerDriver.compileForSyntaxCheck(node); + return node; + } + } + ], + after: [ + // @ts-ignore + (ctx: ts.TransformationContext) => { + return (node: ts.SourceFile) => { + if (ts.getEmitHelpers(node)) { + let newStatements = []; + ts.getEmitHelpers(node)?.forEach( + item => { + let emitHelperSourceFile = ts.createSourceFile(node.fileName, item.text, options.target!, true, ts.ScriptKind.JS); + emitHelperSourceFile.statements.forEach(emitStatement => { + let emitNode = setPos(emitStatement); + newStatements.push(emitNode); + }); + } + ) + newStatements.push(...node.statements); + node = ts.factory.updateSourceFile(node, newStatements); + } + let outputBinName = getOutputBinName(node); + let compilerDriver = new CompilerDriver(outputBinName); + setGlobalStrict(jshelpers.isEffectiveStrictModeSourceFile(node, options)); + compilerDriver.compile(node); + return node; + } + } + ] + } + ); } -function keepWatchingFiles(filePath: string, parsed: ts.ParsedCommandLine | undefined) { - let jsFileName = filePath + path.sep + watchFileName + ".js"; - let abcFileName = filePath + path.sep + watchFileName + ".abc"; +function launchWatchEvaluateDeamon(parsed: ts.ParsedCommandLine | undefined) { + let deamonFilePrefix = CmdOptions.getEvaluateDeamonPath() + path.sep + watchFileName; + let jsFileName = deamonFilePrefix + ".js"; + let abcFileName = deamonFilePrefix + ".abc"; + let errorMsgFileName = deamonFilePrefix + ".err"; + if (fs.existsSync(jsFileName)) { - console.log("watchFileServer has been initialized"); + console.log("watchFileServer has been initialized supportTimeout"); return; } + let files: string[] = parsed.fileNames; fs.writeFileSync(jsFileName, "initJsFile\n"); - convertWatchExpression(jsFileName, parsed); + fs.writeFileSync(errorMsgFileName, "initErrMsgFile\n"); + files.unshift(jsFileName); + let watchedProgram = ts.createProgram(files, parsed.options); + compileWatchExpression(jsFileName, errorMsgFileName, parsed.options, watchedProgram); fs.watchFile(jsFileName, { persistent: true, interval: 50 }, (curr, prev) => { if (+curr.mtime <= +prev.mtime) { @@ -244,13 +312,14 @@ function keepWatchingFiles(filePath: string, parsed: ts.ParsedCommandLine | unde console.log("stopWatchingSuccess"); return; } - convertWatchExpression(jsFileName, parsed); + compileWatchExpression(jsFileName, errorMsgFileName, parsed.options, watchedProgram); }); - console.log("startWatchingSuccess"); + console.log("startWatchingSuccess supportTimeout"); process.on("exit", () => { fs.unlinkSync(jsFileName); fs.unlinkSync(abcFileName); + fs.unlinkSync(errorMsgFileName); }); } @@ -300,19 +369,16 @@ function run(args: string[], options?: ts.CompilerOptions): void { } } try { - let keepWatchArgs = CmdOptions.getKeepWatchFile(); - if (keepWatchArgs.length != 0) { - if (CmdOptions.isKeepWatchMode(keepWatchArgs)) { - keepWatchingFiles(CmdOptions.getKeepWatchFile()[1], parsed); - } else if (CmdOptions.isStopWatchMode(keepWatchArgs)) { - fs.writeFileSync(CmdOptions.getKeepWatchFile()[1] + path.sep + watchFileName + ".js", stopWatchingStr); - } else { - throw new Error("Incorrect args' format for keep watching expression mode"); - } + if (CmdOptions.isWatchEvaluateDeamonMode()) { + launchWatchEvaluateDeamon(parsed); + return; + } + if (CmdOptions.isStopEvaluateDeamonMode()) { + fs.writeFileSync(CmdOptions.getEvaluateDeamonPath() + path.sep + watchFileName + ".js", stopWatchingStr); return; } - if (CmdOptions.isWatchMode()) { - updateWatchedFile(); + if (CmdOptions.isWatchEvaluateExpressionMode()) { + updateWatchJsFile(); return; } diff --git a/ts2panda/src/pandagen.ts b/ts2panda/src/pandagen.ts index 65834994a5..45016fe883 100644 --- a/ts2panda/src/pandagen.ts +++ b/ts2panda/src/pandagen.ts @@ -630,7 +630,7 @@ export class PandaGen { // eg. print tryLoadGlobalByName(node: ts.Node, string_id: string) { - CmdOptions.isWatchMode() ? this.loadByNameViaDebugger(node, string_id, CacheList.True) + CmdOptions.isWatchEvaluateExpressionMode() ? this.loadByNameViaDebugger(node, string_id, CacheList.True) : this.add(node, tryLoadGlobalByName(string_id)); } @@ -649,7 +649,7 @@ export class PandaGen { // eg. a = 1 tryStoreGlobalByName(node: ts.Node, string_id: string) { - CmdOptions.isWatchMode() ? this.storeByNameViaDebugger(node, string_id) + CmdOptions.isWatchEvaluateExpressionMode() ? this.storeByNameViaDebugger(node, string_id) : this.add(node, tryStoreGlobalByName(string_id)); } diff --git a/ts2panda/tests/utils/base.ts b/ts2panda/tests/utils/base.ts index 73966bbf1c..2d9f7ed318 100644 --- a/ts2panda/tests/utils/base.ts +++ b/ts2panda/tests/utils/base.ts @@ -144,7 +144,7 @@ export function checkInstructions(actual: IRNode[], expected: IRNode[], checkFn? export function compileAllSnippet(snippet: string, passes?: Pass[], literalBufferArray?: Array): PandaGen[] { let sourceFile = creatAstFromSnippet(snippet); jshelpers.bindSourceFile(sourceFile, {}); - CmdOptions.isWatchMode() ? setGlobalStrict(true) + CmdOptions.isWatchEvaluateExpressionMode() ? setGlobalStrict(true) : setGlobalStrict(jshelpers.isEffectiveStrictModeSourceFile(sourceFile, compileOptions)); let compilerDriver = new CompilerDriver('UnitTest'); diff --git a/ts2panda/tests/watch_expression/addWatch.test.ts b/ts2panda/tests/watch_expression/addWatch.test.ts index 53ccee3695..bb280802e8 100644 --- a/ts2panda/tests/watch_expression/addWatch.test.ts +++ b/ts2panda/tests/watch_expression/addWatch.test.ts @@ -69,7 +69,7 @@ import { checkInstructions, compileMainSnippet, compileAllSnippet, SnippetCompil describe("WatchExpressions", function () { it("watch NumericLiteral", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` a=-123.212 `); @@ -92,7 +92,7 @@ describe("WatchExpressions", function () { it("watch StringLiteral", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` y = 'He is called \'Johnny\'' `); @@ -120,7 +120,7 @@ describe("WatchExpressions", function () { it("watch RegularExpressionLiteral", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` a = /abc/ `); @@ -141,7 +141,7 @@ describe("WatchExpressions", function () { it("watch Identifier", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` _awef `); @@ -161,7 +161,7 @@ describe("WatchExpressions", function () { it("watch TrueKeyword", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` b === true `); @@ -192,7 +192,7 @@ describe("WatchExpressions", function () { it("watch FalseKeyword", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` b === false `); @@ -224,7 +224,7 @@ describe("WatchExpressions", function () { it("watch CallExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` BigInt(10.2) `); @@ -248,7 +248,7 @@ describe("WatchExpressions", function () { it("watch NullKeyword", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` b === null `); @@ -279,7 +279,7 @@ describe("WatchExpressions", function () { it("watch ThisKeyword", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` this `); @@ -298,7 +298,7 @@ describe("WatchExpressions", function () { it("watch MetaProperty", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let pandaGens = compileAllSnippet(` function (){ b = new.target; @@ -325,7 +325,7 @@ describe("WatchExpressions", function () { it("watch ArrayLiteralExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` [1,2] `); @@ -342,7 +342,7 @@ describe("WatchExpressions", function () { it("watch ObjectLiteralExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` a = {key:1,value:1} `); @@ -365,7 +365,7 @@ describe("WatchExpressions", function () { it("watch PropertyAccessExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` a.b `); @@ -387,7 +387,7 @@ describe("WatchExpressions", function () { it("watch ElementAccessExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` a[0] `); @@ -409,7 +409,7 @@ describe("WatchExpressions", function () { it("watch NewExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` new Function() `); @@ -432,7 +432,7 @@ describe("WatchExpressions", function () { it("watch ParenthesizedExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` (a,b,c) `); @@ -466,7 +466,7 @@ describe("WatchExpressions", function () { it("watch FunctionExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let pandaGens = compileAllSnippet(` a = function () {} `); @@ -491,7 +491,7 @@ describe("WatchExpressions", function () { it("watch DeleteExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` delete[abc] `); @@ -516,7 +516,7 @@ describe("WatchExpressions", function () { it("watch TypeOfExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` typeof(a) `); @@ -537,7 +537,7 @@ describe("WatchExpressions", function () { it("watch VoidExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` void doSomething() `); @@ -560,7 +560,7 @@ describe("WatchExpressions", function () { it("watch AwaitExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let pandaGens = compileAllSnippet( `async function a(){ await abc; @@ -613,7 +613,7 @@ describe("WatchExpressions", function () { it("watch PrefixUnaryExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` --a `); @@ -641,7 +641,7 @@ describe("WatchExpressions", function () { it("watch PostfixUnaryExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` a-- `); @@ -670,7 +670,7 @@ describe("WatchExpressions", function () { it("watch BinaryExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` a+b `); @@ -698,7 +698,7 @@ describe("WatchExpressions", function () { it("watch ConditionalExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let insns = compileMainSnippet(` a?4:2 `); @@ -728,7 +728,7 @@ describe("WatchExpressions", function () { it("watch YieldExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let pandaGens = compileAllSnippet(` function* func(){ yield a; @@ -800,7 +800,7 @@ describe("WatchExpressions", function () { it("watch ArrowFunction", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let pandaGens = compileAllSnippet(` a => b.length `); @@ -829,7 +829,7 @@ describe("WatchExpressions", function () { it("watch ClassExpression", function () { CmdOptions.parseUserCmd([""]); - CmdOptions.setWatchArgs(['','']); + CmdOptions.setWatchEvaluateExpressionArgs(['','']); let pandaGens = compileAllSnippet(` a = new class{}; `); -- Gitee