Yume
compatibility.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "util.hpp"
4#include <cstdint>
5#include <sstream>
6
7namespace yume::ty {
8class Generic;
9class BaseType;
10
11struct Conv {
12 enum struct Kind : uint8_t { None, Int, FnPtr, Virtual };
13 using enum Kind;
14
15 bool dereference = false;
17
18 [[nodiscard]] constexpr auto empty() const -> bool { return !dereference && kind == None; }
19
20 [[nodiscard]] auto to_string() const -> string {
21 if (empty())
22 return "noconv";
23
24 stringstream ss;
25 if (dereference)
26 ss << "deref ";
27 if (kind == Int)
28 ss << "int ";
29 else if (kind == FnPtr)
30 ss << "fnptr ";
31 else if (kind == Virtual)
32 ss << "virtual ";
33 return ss.str();
34 }
35};
36
37/// The compatibility between two types, for overload selection.
38struct Compat {
39 bool valid = false;
41};
42} // namespace yume::ty
A built-in integral type, such as I32 or Bool.
Definition: type.hpp:35
The compatibility between two types, for overload selection.
constexpr auto empty() const -> bool
auto to_string() const -> string