Implement chain of ClassPrivateMemberData

* Each chain piece represents one of class
* User can uses private member with same name parent with child class
* We should check nearest [[homeObject]] of function to find where function is located

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
Seonghyun Kim 2021-06-25 15:56:36 +09:00 committed by Boram Bae
commit 8c3cd2f3b1
19 changed files with 320 additions and 294 deletions

View file

@ -91,6 +91,23 @@ InterpretedCodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context*
} else if (c->isClassConstructor()) {
c->m_canAllocateEnvironmentOnStack = false;
break;
} else if ((c->isClassMethod() || c->isClassStaticMethod()) && scopeCtx->m_hasClassPrivateNameExpression) {
/*
// this covers case below
var C = class {
#f = 'Test262';
method() {
let arrowFunction = () => {
return this.#f; // private member access needs upper env's homeObject
}
return arrowFunction();
}
}
*/
c->m_canAllocateEnvironmentOnStack = false;
break;
} else {
break;
}