fix this keyword in IDE watch <wanggang203@huawei.com>

Signed-off-by: Gavin1012 <wanggang203@huawei.com>
Change-Id: I77344ff85852ffa5781b1c1c96a8c83476b6b6b5
This commit is contained in:
Gavin1012
2022-04-28 21:11:33 +08:00
parent b862eebe99
commit 380301e116
2 changed files with 14 additions and 8 deletions
+2 -1
View File
@@ -1020,7 +1020,8 @@ export class Compiler {
scope.setLexVar(v, this.scope);
}
}
pandaGen.loadAccFromLexEnv(node, scope!, level, v);
CmdOptions.isWatchMode() ? pandaGen.loadByNameViaDebugger(node, "this", CacheList.True)
: pandaGen.loadAccFromLexEnv(node, scope!, level, v);
} else {
throw new Error("\"this\" must be a local variable");
}
@@ -278,17 +278,22 @@ describe("WatchExpressions", function () {
});
it("watch ThisKeyword", function () {
let snippetCompiler = new SnippetCompiler();
snippetCompiler.compile("this");
let globalScope = snippetCompiler.getGlobalScope();
let insns = snippetCompiler.getGlobalInsns();
CmdOptions.parseUserCmd([""]);
CmdOptions.setWatchArgs(['','']);
let insns = compileMainSnippet(`
this
`);
let expected = [
new LdaDyn(new VReg()),
new EcmaLdobjbyname('debuggerGetValue', new VReg()),
new StaDyn(new VReg()),
new LdaStr('this'),
new StaDyn(new VReg()),
new MovDyn(new VReg(), new VReg()),
new EcmaCallargs2dyn(new VReg(), new VReg(), new VReg()),
new ReturnDyn()
];
expect(checkInstructions(insns, expected)).to.be.true;
let thisVar = globalScope!.findLocal("this");
expect(thisVar instanceof LocalVariable).to.be.true;
});
it("watch MetaProperty", function () {