!306 Fix incorrect column number of CallExpression

Merge pull request !306 from ctw-ian/ctw_fixcol
This commit is contained in:
openharmony_ci
2022-06-20 09:37:10 +00:00
committed by Gitee
2 changed files with 23 additions and 11 deletions
+18 -3
View File
@@ -109,17 +109,32 @@ function emitCallArguments(compiler: Compiler, expr: ts.CallExpression, args: VR
export function emitCall(expr: ts.CallExpression, args: VReg[], passThis: boolean, compiler: Compiler) {
let pandaGen = compiler.getPandaGen();
let hasSpread = emitCallArguments(compiler, expr, args);
let callee = expr.expression;
let debugNode = undefined;
switch (callee.kind) {
case ts.SyntaxKind.ElementAccessExpression: {
debugNode = (<ts.ElementAccessExpression>callee).argumentExpression;
break;
}
case ts.SyntaxKind.PropertyAccessExpression: {
debugNode = (<ts.PropertyAccessExpression>callee).name;
break;
}
default: {
debugNode = expr;
}
}
if (!hasSpread) {
pandaGen.call(expr, [...args], passThis);
pandaGen.call(debugNode, [...args], passThis);
return;
}
// spread argument exist
let callee = args[0];
let calleeReg = args[0];
let thisReg = passThis ? args[1] : getVregisterCache(pandaGen, CacheList.undefined);
let argArray = pandaGen.getTemp();
createArrayFromElements(expr, compiler, <ts.NodeArray<ts.Expression>>expr.arguments, argArray);
pandaGen.callSpread(expr, callee, thisReg, argArray);
pandaGen.callSpread(debugNode, calleeReg, thisReg, argArray);
pandaGen.freeTemps(argArray);
}
+5 -8
View File
@@ -126,18 +126,15 @@ describe("ScopeTest", function () {
});
it("test add 'none' variable to LocalScope", function () {
let parent = new FunctionScope();
let parent = new GlobalScope();
let scope = new LocalScope(parent);
let variable = scope.add("x", VarDeclarationKind.NONE);
expect(variable).to.be.equal(undefined);
expect(variable instanceof GlobalVariable).to.be.true;
let { scope: sp, level: lv, v: outVariable } = scope.find("x");
expect(outVariable).to.be.equal(undefined);
expect(lv).to.be.equal(0);
expect(sp).to.be.equal(undefined);
expect(outVariable === variable).to.be.true;
let { scope: spParent, level: lvParent, v: outVariableParent } = parent.find("x");
expect(outVariableParent).to.be.equal(undefined);
expect(lvParent).to.be.equal(0);
expect(spParent).to.be.equal(undefined);
expect(outVariableParent === variable).to.be.true;
expect(spParent instanceof GlobalScope).to.be.true;
});
it("test add 'var' variable to LocalScope", function () {