mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Fix read private property on inner object method
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
2624608567
commit
e52f0ce0cf
3 changed files with 22 additions and 5 deletions
|
|
@ -127,7 +127,7 @@ Optional<LexicalEnvironment*> ExecutionState::mostNearestHeapAllocatedLexicalEnv
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Optional<Object*> ExecutionState::mostNearestHomeObject()
|
||||
Optional<Object*> ExecutionState::mostNearestHomeObject(size_t skipCount)
|
||||
{
|
||||
LexicalEnvironment* env = m_lexicalEnvironment;
|
||||
|
||||
|
|
@ -136,7 +136,11 @@ Optional<Object*> ExecutionState::mostNearestHomeObject()
|
|||
if (rec->isDeclarativeEnvironmentRecord() && rec->asDeclarativeEnvironmentRecord()->isFunctionEnvironmentRecord()) {
|
||||
auto homeObject = rec->asDeclarativeEnvironmentRecord()->asFunctionEnvironmentRecord()->homeObject();
|
||||
if (homeObject) {
|
||||
return homeObject;
|
||||
if (skipCount) {
|
||||
skipCount--;
|
||||
} else {
|
||||
return homeObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
env = env->outerEnvironment();
|
||||
|
|
@ -154,11 +158,24 @@ Object* ExecutionState::convertHomeObjectIntoPrivateMemberContextObject(Object*
|
|||
|
||||
Object* ExecutionState::findPrivateMemberContextObject()
|
||||
{
|
||||
auto o = mostNearestHomeObject();
|
||||
size_t skipCount = 0;
|
||||
Optional<Object*> o;
|
||||
while (true) {
|
||||
auto test = mostNearestHomeObject(skipCount);
|
||||
if (!test) {
|
||||
break;
|
||||
}
|
||||
if (test->isScriptClassConstructorPrototypeObject() || test->isScriptClassConstructorFunctionObject()) {
|
||||
o = test;
|
||||
break;
|
||||
}
|
||||
skipCount++;
|
||||
}
|
||||
if (!o) {
|
||||
ErrorObject::throwBuiltinError(*this, ErrorCode::TypeError, "Cannot read/write private member here");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return convertHomeObjectIntoPrivateMemberContextObject(o.value());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ public:
|
|||
LexicalEnvironment* mostNearestFunctionLexicalEnvironment();
|
||||
Optional<LexicalEnvironment*> mostNearestHeapAllocatedLexicalEnvironment();
|
||||
|
||||
Optional<Object*> mostNearestHomeObject();
|
||||
Optional<Object*> mostNearestHomeObject(size_t skipCount = 0);
|
||||
static Object* convertHomeObjectIntoPrivateMemberContextObject(Object* o);
|
||||
Object* findPrivateMemberContextObject();
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 9f6270fde5d89d049be2e375fd85250688110b93
|
||||
Subproject commit 0db8e32d96a15fcd392021c29fe9103cd52b86a6
|
||||
Loading…
Add table
Add a link
Reference in a new issue