Implement missing part of GlobalDeclarationInstantiation and EvalDeclarationInstantiation

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
Seonghyun Kim 2020-05-08 19:17:31 +09:00 committed by Hyukwoo Park
commit a9a41ff5f0
4 changed files with 64 additions and 37 deletions

View file

@ -198,10 +198,15 @@ Value ByteCodeInterpreter::interpret(ExecutionState* state, ByteCodeBlock* byteC
isCacheWork = true;
} else if (slot->m_cachedStructure == nullptr) {
isCacheWork = true;
if (UNLIKELY(ctx->globalDeclarativeStorage()->at(idx).isEmpty())) {
ErrorObject::throwBuiltinError(*state, ErrorObject::ReferenceError, ctx->globalDeclarativeRecord()->at(idx).m_name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
const auto& record = ctx->globalDeclarativeRecord()->at(idx);
auto& storage = ctx->globalDeclarativeStorage()->at(idx);
if (UNLIKELY(storage.isEmpty())) {
ErrorObject::throwBuiltinError(*state, ErrorObject::ReferenceError, record.m_name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
}
ctx->globalDeclarativeStorage()->at(idx) = registerFile[code->m_registerIndex];
if (UNLIKELY(!record.m_isMutable)) {
ErrorObject::throwBuiltinError(*state, ErrorObject::TypeError, record.m_name.string(), false, String::emptyString, ErrorObject::Messages::AssignmentToConstantVariable);
}
storage = registerFile[code->m_registerIndex];
}
}
@ -2097,6 +2102,9 @@ NEVER_INLINE void ByteCodeInterpreter::setGlobalVariableSlowCase(ExecutionState&
if (UNLIKELY(place.isEmpty())) {
ErrorObject::throwBuiltinError(state, ErrorObject::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
}
if (UNLIKELY(!records[i].m_isMutable)) {
ErrorObject::throwBuiltinError(state, ErrorObject::TypeError, ErrorObject::Messages::AssignmentToConstantVariable, name);
}
place = value;
return;
}