GCC Code Coverage Report


Directory: ../
File: src/ast/Attributes.h
Date: 2025-02-05 01:09:36
Exec Total Coverage
Lines: 0 0 -%
Functions: 0 0 -%
Branches: 0 0 -%

Line Branch Exec Source
1 // Copyright (c) 2021-2025 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <cstdint>
6 #include <unordered_map>
7
8 #include <ast/ASTNodes.h>
9
10 namespace spice::compiler {
11
12 // Constants
13 static constexpr const char *const ATTR_CORE_LINKER_FLAG = "core.linker.flag";
14 static constexpr const char *const ATTR_CORE_LINUX_LINKER_FLAG = "core.linux.linker.flag";
15 static constexpr const char *const ATTR_CORE_WINDOWS_LINKER_FLAG = "core.windows.linker.flag";
16 static constexpr const char *const ATTR_CORE_LINKER_ADDITIONAL_SOURCE = "core.linker.additionalSource";
17 static constexpr const char *const ATTR_CORE_LINKER_DLL = "core.linker.dll";
18 static constexpr const char *const ATTR_CORE_COMPILER_MANGLE = "core.compiler.mangle";
19 static constexpr const char *const ATTR_CORE_COMPILER_MANGLED_NAME = "core.compiler.mangledName";
20 static constexpr const char *const ATTR_CORE_COMPILER_KEEP_ON_NAME_COLLISION = "core.compiler.alwaysKeepOnNameCollision";
21 static constexpr const char *const ATTR_CORE_COMPILER_FIXED_TYPE_ID = "core.compiler.fixedTypeId";
22 static constexpr const char *const ATTR_CORE_COMPILER_EMIT_VTABLE = "core.compiler.alwaysEmitVTable";
23 static constexpr const char *const ATTR_CORE_COMPILER_PACKED = "core.compiler.packed";
24 static constexpr const char *const ATTR_CORE_COMPILER_WARNINGS_IGNORE = "core.compiler.warnings.ignore";
25 static constexpr const char *const ATTR_TEST = "test";
26 static constexpr const char *const ATTR_TEST_NAME = "test.name";
27 static constexpr const char *const ATTR_TEST_SKIP = "test.skip";
28 static constexpr const char *const ATTR_ASYNC = "async";
29 static constexpr const char *const ATTR_IGNORE_UNUSED_RETURN_VALUE = "ignoreUnusedReturnValue";
30
31 static constexpr CompileTimeValue DEFAULT_BOOL_COMPILE_VALUE{.boolValue = true};
32
33 // Structs
34 struct AttrConfigValue {
35 const uint8_t target;
36 const AttrNode::AttrType type;
37 };
38
39 // Data
40 static const std::unordered_map<std::string, AttrConfigValue> ATTR_CONFIGS = {
41 {
42 ATTR_CORE_LINKER_FLAG,
43 {
44 .target = AttrNode::AttrTarget::TARGET_MODULE,
45 .type = AttrNode::AttrType::TYPE_STRING,
46 },
47 },
48 {
49 ATTR_CORE_LINUX_LINKER_FLAG,
50 {
51 .target = AttrNode::AttrTarget::TARGET_MODULE,
52 .type = AttrNode::AttrType::TYPE_STRING,
53 },
54 },
55 {
56 ATTR_CORE_WINDOWS_LINKER_FLAG,
57 {
58 .target = AttrNode::AttrTarget::TARGET_MODULE,
59 .type = AttrNode::AttrType::TYPE_STRING,
60 },
61 },
62 {
63 ATTR_CORE_LINKER_ADDITIONAL_SOURCE,
64 {
65 .target = AttrNode::AttrTarget::TARGET_MODULE,
66 .type = AttrNode::AttrType::TYPE_STRING,
67 },
68 },
69 {
70 ATTR_CORE_COMPILER_KEEP_ON_NAME_COLLISION,
71 {
72 .target = AttrNode::AttrTarget::TARGET_MODULE,
73 .type = AttrNode::AttrType::TYPE_BOOL,
74 },
75 },
76 {
77 ATTR_CORE_COMPILER_FIXED_TYPE_ID,
78 {
79 .target = AttrNode::AttrTarget::TARGET_STRUCT | AttrNode::AttrTarget::TARGET_INTERFACE,
80 .type = AttrNode::AttrType::TYPE_INT,
81 },
82 },
83 {
84 ATTR_CORE_LINKER_DLL,
85 {
86 .target = AttrNode::AttrTarget::TARGET_EXT_DECL,
87 .type = AttrNode::AttrType::TYPE_BOOL,
88 },
89 },
90 {
91 ATTR_CORE_COMPILER_MANGLE,
92 {
93 .target = AttrNode::AttrTarget::TARGET_FCT_PROC | AttrNode::AttrTarget::TARGET_EXT_DECL,
94 .type = AttrNode::AttrType::TYPE_BOOL,
95 },
96 },
97 {
98 ATTR_CORE_COMPILER_MANGLED_NAME,
99 {
100 .target = AttrNode::AttrTarget::TARGET_FCT_PROC | AttrNode::AttrTarget::TARGET_EXT_DECL,
101 .type = AttrNode::AttrType::TYPE_STRING,
102 },
103 },
104 {
105 ATTR_CORE_COMPILER_KEEP_ON_NAME_COLLISION,
106 {
107 .target = AttrNode::AttrTarget::TARGET_MODULE,
108 .type = AttrNode::AttrType::TYPE_BOOL,
109 },
110 },
111 {
112 ATTR_CORE_COMPILER_EMIT_VTABLE,
113 {
114 .target = AttrNode::AttrTarget::TARGET_STRUCT,
115 .type = AttrNode::AttrType::TYPE_BOOL,
116 },
117 },
118 {
119 ATTR_CORE_COMPILER_PACKED,
120 {
121 .target = AttrNode::AttrTarget::TARGET_STRUCT,
122 .type = AttrNode::AttrType::TYPE_BOOL,
123 },
124 },
125 {
126 ATTR_CORE_COMPILER_WARNINGS_IGNORE,
127 {
128 .target = AttrNode::AttrTarget::TARGET_MODULE,
129 .type = AttrNode::AttrType::TYPE_BOOL,
130 },
131 },
132 {
133 ATTR_TEST,
134 {
135 .target = AttrNode::AttrTarget::TARGET_FCT_PROC,
136 .type = AttrNode::AttrType::TYPE_BOOL,
137 },
138 },
139 {
140 ATTR_TEST_NAME,
141 {
142 .target = AttrNode::AttrTarget::TARGET_FCT_PROC,
143 .type = AttrNode::AttrType::TYPE_STRING,
144 },
145 },
146 {
147 ATTR_TEST_SKIP,
148 {
149 .target = AttrNode::AttrTarget::TARGET_FCT_PROC,
150 .type = AttrNode::AttrType::TYPE_BOOL,
151 },
152 },
153 {
154 ATTR_ASYNC,
155 {
156 .target = AttrNode::AttrTarget::TARGET_FCT_PROC | AttrNode::AttrTarget::TARGET_LAMBDA,
157 .type = AttrNode::AttrType::TYPE_BOOL,
158 },
159 },
160 {
161 ATTR_IGNORE_UNUSED_RETURN_VALUE,
162 {
163 .target = AttrNode::AttrTarget::TARGET_FCT_PROC | AttrNode::AttrTarget::TARGET_LAMBDA,
164 .type = AttrNode::AttrType::TYPE_BOOL,
165 },
166 },
167 };
168
169 } // namespace spice::compiler
170