mirror of
https://github.com/openharmony/ark_ts2abc.git
synced 2026-07-21 08:25:24 -04:00
fix this keyword in IDE watch <wanggang203@huawei.com>
Signed-off-by: Gavin1012 <wanggang203@huawei.com> Change-Id: I77344ff85852ffa5781b1c1c96a8c83476b6b6b5
This commit is contained in:
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user