mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
Support loading HSP at Previewer
issue : https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7X78H Signed-off-by: DaiHN <daihuina1@huawei.com> Change-Id: I0405477038648b122c9f5140b6cf2ed78f46e6fe
This commit is contained in:
parent
4487fb9100
commit
d46adc83dd
@ -66,12 +66,17 @@ std::shared_ptr<JSPandaFile> JSPandaFileManager::LoadJSPandaFile(JSThread *threa
|
|||||||
}
|
}
|
||||||
|
|
||||||
EcmaVM *vm = thread->GetEcmaVM();
|
EcmaVM *vm = thread->GetEcmaVM();
|
||||||
bool mode = thread->GetCurrentEcmaContext()->GetModuleManager()->GetCurrentMode();
|
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
|
||||||
std::unique_ptr<const panda_file::File> pf;
|
std::unique_ptr<const panda_file::File> pf;
|
||||||
if (!vm->IsBundlePack() && mode) {
|
if (!vm->IsBundlePack() && moduleManager->GetExecuteMode()) {
|
||||||
ResolveBufferCallback resolveBufferCallback = vm->GetResolveBufferCallback();
|
ResolveBufferCallback resolveBufferCallback = vm->GetResolveBufferCallback();
|
||||||
if (resolveBufferCallback == nullptr) {
|
if (resolveBufferCallback == nullptr) {
|
||||||
LOG_ECMA(ERROR) << "resolveBufferCallback is nullptr";
|
LOG_ECMA(ERROR) << "resolveBufferCallback is nullptr";
|
||||||
|
#if defined(PANDA_TARGET_WINDOWS) || defined(PANDA_TARGET_MACOS)
|
||||||
|
if (vm->EnableReportModuleResolvingFailure()) {
|
||||||
|
LOG_NO_TAG(ERROR) << "[ArkRuntime Log] Importing shared package is not supported in the Previewer.";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
uint8_t *data = nullptr;
|
uint8_t *data = nullptr;
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
void AddResolveImportedModule(const CString &referencingModule, JSHandle<JSTaggedValue> moduleRecord);
|
void AddResolveImportedModule(const CString &referencingModule, JSHandle<JSTaggedValue> moduleRecord);
|
||||||
void Iterate(const RootVisitor &v);
|
void Iterate(const RootVisitor &v);
|
||||||
|
|
||||||
bool GetCurrentMode() const
|
bool GetExecuteMode() const
|
||||||
{
|
{
|
||||||
return isExecuteBuffer_;
|
return isExecuteBuffer_;
|
||||||
}
|
}
|
||||||
|
@ -174,18 +174,22 @@ CString ModulePathHelper::ParsePrefixBundle(JSThread *thread, const JSPandaFile
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
CVector<CString> currentVec;
|
CVector<CString> currentVec;
|
||||||
StringHelper::SplitString(recordName, currentVec, 0, SEGMENTS_LIMIT_TWO);
|
StringHelper::SplitString(moduleRequestName, currentVec, 0, SEGMENTS_LIMIT_TWO);
|
||||||
if (currentVec.size() < SEGMENTS_LIMIT_TWO) {
|
if (currentVec.size() < SEGMENTS_LIMIT_TWO) {
|
||||||
LOG_ECMA(INFO) << "SplitString filed, please check recordName";
|
LOG_ECMA(INFO) << "SplitString filed, please check recordName";
|
||||||
return CString();
|
return CString();
|
||||||
}
|
}
|
||||||
CString currentModuleName = currentVec[1];
|
CString currentModuleName = currentVec[1];
|
||||||
PathHelper::DeleteNamespace(currentModuleName);
|
PathHelper::DeleteNamespace(currentModuleName);
|
||||||
if (bundleName != vm->GetBundleName() || moduleName != currentModuleName) {
|
if (bundleName != vm->GetBundleName()) {
|
||||||
entryPoint = PREVIEW_OF_ACROSS_HAP_FLAG;
|
entryPoint = PREVIEW_OF_ACROSS_HAP_FLAG;
|
||||||
if (vm->EnableReportModuleResolvingFailure()) {
|
if (vm->EnableReportModuleResolvingFailure()) {
|
||||||
LOG_NO_TAG(ERROR) << "[ArkRuntime Log] Importing shared package is not supported in the Previewer.";
|
CString msg = "[ArkRuntime Log] Cannot preview this HSP module as" \
|
||||||
|
"it is imported from outside the current application.";
|
||||||
|
LOG_NO_TAG(ERROR) << msg;
|
||||||
}
|
}
|
||||||
|
} else if (currentModuleName != vm->GetModuleName()) {
|
||||||
|
baseFileName = BUNDLE_INSTALL_PATH + moduleName + MERGE_ABC_ETS_MODULES;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
@ -3669,8 +3669,12 @@ void JSNApi::SynchronizVMInfo(EcmaVM *vm, const EcmaVM *hostVM)
|
|||||||
vm->SetModuleName(hostVM->GetModuleName());
|
vm->SetModuleName(hostVM->GetModuleName());
|
||||||
vm->SetAssetPath(hostVM->GetAssetPath());
|
vm->SetAssetPath(hostVM->GetAssetPath());
|
||||||
vm->SetIsBundlePack(hostVM->IsBundlePack());
|
vm->SetIsBundlePack(hostVM->IsBundlePack());
|
||||||
vm->GetAssociatedJSThread()->GetCurrentEcmaContext()->GetModuleManager()->SetExecuteMode(
|
|
||||||
hostVM->GetAssociatedJSThread()->GetCurrentEcmaContext()->GetModuleManager()->GetCurrentMode());
|
ecmascript::ModuleManager *vmModuleManager =
|
||||||
|
vm->GetAssociatedJSThread()->GetCurrentEcmaContext()->GetModuleManager();
|
||||||
|
ecmascript::ModuleManager *hostVMModuleManager =
|
||||||
|
hostVM->GetAssociatedJSThread()->GetCurrentEcmaContext()->GetModuleManager();
|
||||||
|
vmModuleManager->SetExecuteMode(hostVMModuleManager->GetExecuteMode());
|
||||||
vm->SetResolveBufferCallback(hostVM->GetResolveBufferCallback());
|
vm->SetResolveBufferCallback(hostVM->GetResolveBufferCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user