LILAC
Language to language Interop LAyer Compiler
Loading...
Searching...
No Matches
typemap.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 Yeong-won Seo
3 *
4 * This file is part of LILAC.
5 *
6 * LILAC is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3, or (at your option) any later
9 * version.
10 *
11 * LILAC is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include "pch.h"
23
24namespace lilac::cxx
25{
26 [[nodiscard]]
27 constexpr std::string GetBuiltinTypeName(clang::BuiltinType::Kind kind)
28 {
29 switch (kind)
30 {
31#define CASE___(a, ...) case clang::BuiltinType::Kind::a: __VA_OPT__(CASE__(__VA_ARGS__))
32#define CASE__(a, ...) case clang::BuiltinType::Kind::a: __VA_OPT__(CASE___(__VA_ARGS__))
33#define CASE_(name, ...) CASE__(__VA_ARGS__) return name
34 CASE_("__void", Void);
35 CASE_("__bool", Bool);
36 CASE_("__u8", Char_U);
37 CASE_("__u8", UChar);
38 CASE_("__u16", WChar_U);
39 CASE_("__u8", Char8);
40 CASE_("__u16", Char16);
41 CASE_("__u32", Char32);
42 CASE_("__u16", UShort);
43 CASE_("__u32", UInt);
44 CASE_("__uptr", ULong);
45 CASE_("__u64", ULongLong);
46 CASE_("__u128", UInt128);
47 CASE_("__s8", Char_S, SChar);
48 CASE_("__s16", WChar_S);
49 CASE_("__s16", Short);
50 CASE_("__s32", Int);
51 CASE_("__sptr", Long);
52 CASE_("__s64", LongLong);
53 CASE_("__s128", Int128);
54 CASE_("__fp16", Half);
55 CASE_("__fp32", Float);
56 CASE_("__fp64", Double);
57 CASE_("__fp16", Float16);
58 CASE_("__fp128", Float128);
59#undef CASE_
60#undef CASE__
61#undef CASE___
62
63 default:
64 throw std::runtime_error(std::format("builtin type '{}' is not supported", static_cast<int>(kind)));
65 }
66 }
67}
68
69#undef TYPEKINDMAP
constexpr std::string GetBuiltinTypeName(clang::BuiltinType::Kind kind)
Definition typemap.h:27
#define CASE_(name,...)