slige/runtime/actions.cpp

41 lines
1.1 KiB
C++
Raw Normal View History

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