Fix minor issues

* When there is arrow function on class ctor, we should use heap-allocated lex env for class ctor.
  because we need to compute this variable on run-time
* when there is super expression with computed case, we should load this binding first for testing binding

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
Seonghyun Kim 2020-05-11 16:33:12 +09:00 committed by Boram Bae
commit 355d7244f1
5 changed files with 36 additions and 4 deletions

View file

@ -67,6 +67,25 @@ InterpretedCodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context*
}
}
if (scopeCtx->m_hasThisExpression && scopeCtx->m_isArrowFunctionExpression) {
// every arrow function should save this value of upper env.
// except arrow function is localed on class constructor(class constructor needs test of this binding is valid)
InterpretedCodeBlock* c = codeBlock;
while (c) {
if (c->isKindOfFunction()) {
if (c->isArrowFunctionExpression()) {
// pass
} else if (c->isClassConstructor()) {
c->m_canAllocateEnvironmentOnStack = false;
break;
} else {
break;
}
}
c = c->parentCodeBlock();
}
}
if (scopeCtx->m_hasSuperOrNewTarget) {
InterpretedCodeBlock* c = codeBlock;
while (c) {