2024-12-09 13:03:21 +01:00
|
|
|
#include "actions.hpp"
|
|
|
|
#include "vm_provider.hpp"
|
|
|
|
|
|
|
|
auto sliger::rpc::action::RunDebug::perform_action(
|
|
|
|
std::unique_ptr<sliger::rpc::BufferedWriter> writer,
|
2024-12-12 11:57:18 +01:00
|
|
|
vm_provider::VmProvider& vm) -> void
|
2024-12-09 13:03:21 +01:00
|
|
|
{
|
|
|
|
auto program = this->instructions;
|
|
|
|
vm.load_and_run(program);
|
2024-12-12 11:33:38 +01:00
|
|
|
writer->write("{ \"ok\": true }");
|
|
|
|
writer->flush();
|
2024-12-09 13:03:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
auto sliger::rpc::action::FlameGraph::perform_action(
|
|
|
|
std::unique_ptr<sliger::rpc::BufferedWriter> writer,
|
2024-12-12 11:57:18 +01:00
|
|
|
vm_provider::VmProvider& vm) -> void
|
2024-12-09 13:03:21 +01:00
|
|
|
{
|
|
|
|
auto json = vm.flame_graph_json();
|
|
|
|
if (json) {
|
2024-12-12 11:33:38 +01:00
|
|
|
writer->write(std::format(
|
2024-12-12 11:57:18 +01:00
|
|
|
"{{ \"ok\": true, \"flameGraph\": {} }}", json.value()));
|
2024-12-09 13:03:21 +01:00
|
|
|
} else {
|
2024-12-12 11:33:38 +01:00
|
|
|
writer->write("{ \"ok\": false }");
|
2024-12-09 13:03:21 +01:00
|
|
|
}
|
|
|
|
writer->flush();
|
|
|
|
};
|
|
|
|
|
|
|
|
auto sliger::rpc::action::CodeCoverage::perform_action(
|
|
|
|
std::unique_ptr<sliger::rpc::BufferedWriter> writer,
|
2024-12-12 11:57:18 +01:00
|
|
|
vm_provider::VmProvider& vm) -> void
|
2024-12-09 13:03:21 +01:00
|
|
|
{
|
|
|
|
auto json = vm.code_coverage_json();
|
|
|
|
if (json) {
|
2024-12-12 11:33:38 +01:00
|
|
|
writer->write(std::format(
|
2024-12-12 11:57:18 +01:00
|
|
|
"{{ \"ok\": true, \"codeCoverage\": {} }}", json.value()));
|
2024-12-09 13:03:21 +01:00
|
|
|
} else {
|
2024-12-12 11:33:38 +01:00
|
|
|
writer->write("{ \"ok\": false }");
|
2024-12-09 13:03:21 +01:00
|
|
|
}
|
|
|
|
writer->flush();
|
|
|
|
};
|