#include "vm_provider.hpp"
#include "vm.hpp"

using namespace sliger::rpc::vm_provider;

auto VmProvider::load_and_run(std::vector<uint32_t> instructions) -> void
{
    auto vm = VM(instructions,
        {
            .flame_graph = true,
            .code_coverage = true,
            .print_stack_debug = false,
        });
    vm.run_until_done();
    this->vm = vm;
}

auto VmProvider::flame_graph_json() -> std::optional<std::string>
{
    if (this->vm) {
        return this->vm->flame_graph_json();
    } else {
        return {};
    }
}

auto VmProvider::code_coverage_json() -> std::optional<std::string>
{
    if (this->vm) {
        return this->vm->code_coverage_json();
    } else {
        return {};
    }
}