about summary refs log tree commit diff
path: root/src/tools/miri/genmc-sys/src_cpp/MiriInterface.hpp
blob: e55522ef418975a304cedea1f31bfa5e4ef5236f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef GENMC_MIRI_INTERFACE_HPP
#define GENMC_MIRI_INTERFACE_HPP

#include "rust/cxx.h"

#include "config.h"

#include "Config/Config.hpp"
#include "Verification/GenMCDriver.hpp"

#include <iostream>

/**** Types available to Miri ****/

// Config struct defined on the Rust side and translated to C++ by cxx.rs:
struct GenmcParams;

struct MiriGenMCShim : private GenMCDriver
{

public:
	MiriGenMCShim(std::shared_ptr<const Config> conf, Mode mode /* = VerificationMode{} */)
		: GenMCDriver(std::move(conf), nullptr, mode)
	{
		std::cerr << "C++: GenMC handle created!" << std::endl;
	}

	virtual ~MiriGenMCShim()
	{
		std::cerr << "C++: GenMC handle destroyed!" << std::endl;
	}

	static std::unique_ptr<MiriGenMCShim> createHandle(const GenmcParams &config);
};

/**** Functions available to Miri ****/

// NOTE: CXX doesn't support exposing static methods to Rust currently, so we expose this function instead.
static inline auto createGenmcHandle(const GenmcParams &config) -> std::unique_ptr<MiriGenMCShim>
{
	return MiriGenMCShim::createHandle(config);
}

#endif /* GENMC_MIRI_INTERFACE_HPP */