GCC Code Coverage Report


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