summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler/src/Detail
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-04-25 13:14:01 +0200
committerAmlal <amlal@nekernel.org>2025-04-25 13:14:01 +0200
commit20042235d1f53ae428aa154e64afdbae5d8d91ad (patch)
tree6ea42d1b30505a57301f8ff2916c78ce94ff6eaf /dev/LibCompiler/src/Detail
parent0561a8d0a6ae7588309a6e3513bbfeeef5f0aa15 (diff)
meta: update .clang-format, format codebase.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler/src/Detail')
-rw-r--r--dev/LibCompiler/src/Detail/AsmUtils.h176
-rw-r--r--dev/LibCompiler/src/Detail/ClUtils.h2
2 files changed, 79 insertions, 99 deletions
diff --git a/dev/LibCompiler/src/Detail/AsmUtils.h b/dev/LibCompiler/src/Detail/AsmUtils.h
index 997564c..358700a 100644
--- a/dev/LibCompiler/src/Detail/AsmUtils.h
+++ b/dev/LibCompiler/src/Detail/AsmUtils.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
+ Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
------------------------------------------- */
@@ -11,106 +11,86 @@
using namespace LibCompiler;
-namespace Detail
-{
- extern void print_error(std::string reason, std::string file) noexcept;
- extern void print_warning(std::string reason, std::string file) noexcept;
-} // namespace Detail
+namespace Detail {
+extern void print_error(std::string reason, std::string file) noexcept;
+extern void print_warning(std::string reason, std::string file) noexcept;
+} // namespace Detail
/// @brief Get Number from lineBuffer.
/// @param lineBuffer the lineBuffer to fetch from.
/// @param numberKey where to seek that number.
/// @return
-static NumberCast32 GetNumber32(std::string lineBuffer, std::string numberKey)
-{
- auto pos = lineBuffer.find(numberKey) + numberKey.size();
-
- while (lineBuffer[pos] == ' ')
- {
- ++pos;
- }
-
- switch (lineBuffer[pos + 1])
- {
- case 'x': {
- if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 16); !res)
- {
- if (errno != 0)
- {
- Detail::print_error("invalid hex number: " + lineBuffer, "LibCompiler");
- throw std::runtime_error("invalid_hex");
- }
- }
-
- NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 16));
-
- if (kVerbose)
- {
- kStdOut << "asm: found a base 16 number here: " << lineBuffer.substr(pos)
- << "\n";
- }
-
- return numOffset;
- }
- case 'b': {
- if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 2); !res)
- {
- if (errno != 0)
- {
- Detail::print_error("invalid binary number:" + lineBuffer, "LibCompiler");
- throw std::runtime_error("invalid_bin");
- }
- }
-
- NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 2));
-
- if (kVerbose)
- {
- kStdOut << "asm: found a base 2 number here:" << lineBuffer.substr(pos)
- << "\n";
- }
-
- return numOffset;
- }
- case 'o': {
- if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 7); !res)
- {
- if (errno != 0)
- {
- Detail::print_error("invalid octal number: " + lineBuffer, "LibCompiler");
- throw std::runtime_error("invalid_octal");
- }
- }
-
- NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 7));
-
- if (kVerbose)
- {
- kStdOut << "asm: found a base 8 number here:" << lineBuffer.substr(pos)
- << "\n";
- }
-
- return numOffset;
- }
- default: {
- if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 10); !res)
- {
- if (errno != 0)
- {
- Detail::print_error("invalid hex number: " + lineBuffer, "LibCompiler");
- throw std::runtime_error("invalid_hex");
- }
- }
-
- NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 10));
-
- if (kVerbose)
- {
- kStdOut << "asm: found a base 10 number here:" << lineBuffer.substr(pos)
- << "\n";
- }
-
- return numOffset;
- }
- }
+static NumberCast32 GetNumber32(std::string lineBuffer, std::string numberKey) {
+ auto pos = lineBuffer.find(numberKey) + numberKey.size();
+
+ while (lineBuffer[pos] == ' ') {
+ ++pos;
+ }
+
+ switch (lineBuffer[pos + 1]) {
+ case 'x': {
+ if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 16); !res) {
+ if (errno != 0) {
+ Detail::print_error("invalid hex number: " + lineBuffer, "LibCompiler");
+ throw std::runtime_error("invalid_hex");
+ }
+ }
+
+ NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 16));
+
+ if (kVerbose) {
+ kStdOut << "asm: found a base 16 number here: " << lineBuffer.substr(pos) << "\n";
+ }
+
+ return numOffset;
+ }
+ case 'b': {
+ if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 2); !res) {
+ if (errno != 0) {
+ Detail::print_error("invalid binary number:" + lineBuffer, "LibCompiler");
+ throw std::runtime_error("invalid_bin");
+ }
+ }
+
+ NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 2));
+
+ if (kVerbose) {
+ kStdOut << "asm: found a base 2 number here:" << lineBuffer.substr(pos) << "\n";
+ }
+
+ return numOffset;
+ }
+ case 'o': {
+ if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 7); !res) {
+ if (errno != 0) {
+ Detail::print_error("invalid octal number: " + lineBuffer, "LibCompiler");
+ throw std::runtime_error("invalid_octal");
+ }
+ }
+
+ NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 7));
+
+ if (kVerbose) {
+ kStdOut << "asm: found a base 8 number here:" << lineBuffer.substr(pos) << "\n";
+ }
+
+ return numOffset;
+ }
+ default: {
+ if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 10); !res) {
+ if (errno != 0) {
+ Detail::print_error("invalid hex number: " + lineBuffer, "LibCompiler");
+ throw std::runtime_error("invalid_hex");
+ }
+ }
+
+ NumberCast32 numOffset(strtol(lineBuffer.substr(pos).c_str(), nullptr, 10));
+
+ if (kVerbose) {
+ kStdOut << "asm: found a base 10 number here:" << lineBuffer.substr(pos) << "\n";
+ }
+
+ return numOffset;
+ }
+ }
}
diff --git a/dev/LibCompiler/src/Detail/ClUtils.h b/dev/LibCompiler/src/Detail/ClUtils.h
index fe788a2..024d0d2 100644
--- a/dev/LibCompiler/src/Detail/ClUtils.h
+++ b/dev/LibCompiler/src/Detail/ClUtils.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
+ Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
------------------------------------------- */