mini-llvm 0.1.0
Loading...
Searching...
No Matches
Statement.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <concepts>
6#include <format>
7#include <string>
8
10
11namespace mini_llvm::mc {
12
14public:
15 virtual ~Statement() = default;
16
17 Statement() = default;
18
19 Statement(const Statement &) = delete;
20 Statement &operator=(const Statement &) = delete;
21
22 Statement(Statement &&) = delete;
24
25 virtual std::string format() const = 0;
26};
27
28} // namespace mini_llvm::mc
29
30template <typename StatementT>
31 requires std::derived_from<StatementT, mini_llvm::mc::Statement>
32struct std::formatter<StatementT> {
33 constexpr auto parse(std::format_parse_context &ctx) {
34 return ctx.begin();
35 }
36
37 template <typename FormatContext>
38 auto format(const StatementT &stmt, FormatContext &ctx) const {
39 return std::format_to(ctx.out(), "{}", stmt.format());
40 }
41};
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Statement & operator=(Statement &&)=delete
Statement(const Statement &)=delete
virtual ~Statement()=default
virtual std::string format() const =0
Statement & operator=(const Statement &)=delete
Statement(Statement &&)=delete
Definition Directive.h:8
constexpr auto parse(std::format_parse_context &ctx)
Definition Statement.h:33
auto format(const StatementT &stmt, FormatContext &ctx) const
Definition Statement.h:38