mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-08-27 02:31:17 -04:00
@@ -105,6 +105,15 @@ void JSBackend::NotifyResume()
|
||||
frontend_->SendNotification(ecmaVm_, std::make_unique<Resumed>());
|
||||
}
|
||||
|
||||
void JSBackend::NotifyAllScriptParsed()
|
||||
{
|
||||
for (auto &script : scripts_) {
|
||||
if (frontend_ != nullptr) {
|
||||
frontend_->SendNotification(ecmaVm_, ScriptParsed::Create(script.second));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool JSBackend::NotifyScriptParsed(int32_t scriptId, const CString &fileName)
|
||||
{
|
||||
auto scriptFunc = []([[maybe_unused]] PtScript *script) -> bool {
|
||||
@@ -159,17 +168,8 @@ bool JSBackend::NotifyScriptParsed(int32_t scriptId, const CString &fileName)
|
||||
// Notify script parsed event
|
||||
std::unique_ptr<PtScript> script = std::make_unique<PtScript>(scriptId, fileName, url, source);
|
||||
|
||||
std::unique_ptr<ScriptParsed> scriptParsed = std::make_unique<ScriptParsed>();
|
||||
scriptParsed->SetScriptId(script->GetScriptId())
|
||||
.SetUrl(script->GetUrl())
|
||||
.SetStartLine(0)
|
||||
.SetStartColumn(0)
|
||||
.SetEndLine(script->GetEndLine())
|
||||
.SetEndColumn(0)
|
||||
.SetExecutionContextId(0)
|
||||
.SetHash(script->GetHash());
|
||||
if (frontend_ != nullptr) {
|
||||
frontend_->SendNotification(ecmaVm_, std::move(scriptParsed));
|
||||
frontend_->SendNotification(ecmaVm_, ScriptParsed::Create(script));
|
||||
}
|
||||
|
||||
// Store parsed script in map
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
void WaitForDebugger();
|
||||
void NotifyPaused(std::optional<PtLocation> location, PauseReason reason);
|
||||
void NotifyResume();
|
||||
void NotifyAllScriptParsed();
|
||||
bool NotifyScriptParsed(int32_t scriptId, const CString &fileName);
|
||||
bool StepComplete(const PtLocation &location);
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ void RuntimeImpl::DispatcherImpl::GetProperties(const DispatchRequest &request)
|
||||
DispatchResponse RuntimeImpl::Enable()
|
||||
{
|
||||
Runtime::GetCurrent()->SetDebugMode(true);
|
||||
backend_->NotifyAllScriptParsed();
|
||||
return DispatchResponse::Ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -449,6 +449,20 @@ Local<ObjectRef> ScriptFailedToParse::ToObject(const EcmaVM *ecmaVm)
|
||||
return object;
|
||||
}
|
||||
|
||||
std::unique_ptr<ScriptParsed> ScriptParsed::Create(const std::unique_ptr<PtScript> &script)
|
||||
{
|
||||
std::unique_ptr<ScriptParsed> scriptParsed = std::make_unique<ScriptParsed>();
|
||||
scriptParsed->SetScriptId(script->GetScriptId())
|
||||
.SetUrl(script->GetUrl())
|
||||
.SetStartLine(0)
|
||||
.SetStartColumn(0)
|
||||
.SetEndLine(script->GetEndLine())
|
||||
.SetEndColumn(0)
|
||||
.SetExecutionContextId(0)
|
||||
.SetHash(script->GetHash());
|
||||
return scriptParsed;
|
||||
}
|
||||
|
||||
std::unique_ptr<ScriptParsed> ScriptParsed::Create(const EcmaVM *ecmaVm, const Local<JSValueRef> ¶ms)
|
||||
{
|
||||
if (params.IsEmpty()) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <optional>
|
||||
|
||||
#include "libpandabase/macros.h"
|
||||
#include "ecmascript/tooling/base/pt_script.h"
|
||||
#include "ecmascript/tooling/base/pt_types.h"
|
||||
#include "ecmascript/tooling/dispatcher.h"
|
||||
#include "ecmascript/mem/c_containers.h"
|
||||
@@ -474,6 +475,7 @@ class ScriptParsed final : public PtBaseEvents {
|
||||
public:
|
||||
ScriptParsed() = default;
|
||||
~ScriptParsed() override = default;
|
||||
static std::unique_ptr<ScriptParsed> Create(const std::unique_ptr<PtScript> &script);
|
||||
static std::unique_ptr<ScriptParsed> Create(const EcmaVM *ecmaVm, const Local<JSValueRef> ¶ms);
|
||||
Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user