aboutsummaryrefslogtreecommitdiff
path: root/include/cps/Identifier.h
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-16 13:21:05 +0000
committer_ov4 <ov4@ov4.org>2026-10-16 13:21:05 +0000
commite44bdc6a2a0cf624b08046ecc7e5c5d5d9d2d66c (patch)
treef5276cc0dd2f34e4d30a58f80223912265a1c5a0 /include/cps/Identifier.h
parente1e789ac0249149a4aa1671f5f9260d488cb617a (diff)
fix(compiler): correct CIE semantics and diagnostic locations
Use standard WHILE headers and default-public class fields, resolve pseudocode identifiers without case sensitivity, and check signed i64 literal boundaries before conversion. Preserve source locations across recursive emission and function diagnostics. Add 22 regression cases and update compiler examples and documentation. Validated all 69 CTest entries with the original Linux Actions seed and verified the release package's embedded, native and IR output paths.
Diffstat (limited to 'include/cps/Identifier.h')
-rw-r--r--include/cps/Identifier.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/cps/Identifier.h b/include/cps/Identifier.h
new file mode 100644
index 0000000..c35f636
--- /dev/null
+++ b/include/cps/Identifier.h
@@ -0,0 +1,27 @@
+#pragma once
+#include <algorithm>
+#include <map>
+#include <set>
+#include <string>
+
+namespace cps {
+
+inline unsigned char foldIdentifier(unsigned char C) {
+ return C >= 'A' && C <= 'Z' ? C + ('a' - 'A') : C;
+}
+
+struct IdentifierLess {
+ bool operator()(const std::string &A, const std::string &B) const {
+ return std::lexicographical_compare(A.begin(), A.end(), B.begin(), B.end(),
+ [](unsigned char L, unsigned char R) { return foldIdentifier(L) < foldIdentifier(R); });
+ }
+};
+
+inline bool sameIdentifier(const std::string &A, const std::string &B) {
+ return !IdentifierLess{}(A, B) && !IdentifierLess{}(B, A);
+}
+
+template<class T> using IdentifierMap = std::map<std::string, T, IdentifierLess>;
+using IdentifierSet = std::set<std::string, IdentifierLess>;
+
+} // namespace cps