summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler/Detail/ClUtils.h
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-04-25 19:21:22 +0200
committerAmlal <amlal@nekernel.org>2025-04-25 19:21:51 +0200
commitf6b400b80efc64b918c03352e93ec9de4e2369a1 (patch)
tree251a82ee3653568ef33ffdc48c83b7f54e370bc1 /dev/LibCompiler/Detail/ClUtils.h
parent20042235d1f53ae428aa154e64afdbae5d8d91ad (diff)
dev, general: codebase needed refactors and tweaks, for NeKernel's 0.0.2 release.
details: - things needed to be cleared off, short sighted decisions fixed. - the inconsistency of certain files have been fixed too. Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler/Detail/ClUtils.h')
-rw-r--r--dev/LibCompiler/Detail/ClUtils.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/dev/LibCompiler/Detail/ClUtils.h b/dev/LibCompiler/Detail/ClUtils.h
new file mode 100644
index 0000000..b14d472
--- /dev/null
+++ b/dev/LibCompiler/Detail/ClUtils.h
@@ -0,0 +1,57 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
+
+------------------------------------------- */
+
+#pragma once
+
+#include <LibCompiler/AssemblyInterface.h>
+#include <LibCompiler/Parser.h>
+
+#define kZero64Section ".zero64"
+#define kCode64Section ".code64"
+#define kData64Section ".data64"
+
+#define kZero128Section ".zero128"
+#define kCode128Section ".code128"
+#define kData128Section ".data128"
+
+#define kBlank "\e[0;30m"
+#define kRed "\e[0;31m"
+#define kWhite "\e[0;97m"
+#define kYellow "\e[0;33m"
+
+#define kStdOut (std::cout << kWhite)
+#define kStdErr (std::cout << kRed)
+
+inline static UInt32 kErrorLimit = 10;
+inline static UInt32 kAcceptableErrors = 0;
+inline static bool kVerbose = false;
+inline static bool kOutputAsBinary = false;
+
+namespace Detail {
+inline void print_error(std::string reason, std::string file) noexcept {
+ if (reason[0] == '\n') reason.erase(0, 1);
+
+ kStdErr << kRed << "[ asm ] " << kWhite
+ << ((file == "LibCompiler") ? "InternalErrorException: "
+ : ("FileException{ " + file + " }: "))
+ << kBlank << std::endl;
+ kStdErr << kRed << "[ asm ] " << kWhite << reason << kBlank << std::endl;
+
+ if (kAcceptableErrors > kErrorLimit) std::exit(3);
+
+ ++kAcceptableErrors;
+}
+
+inline void print_warning(std::string reason, std::string file) noexcept {
+ if (reason[0] == '\n') reason.erase(0, 1);
+
+ if (!file.empty()) {
+ kStdOut << kYellow << "[ asm ] " << kWhite << file << kBlank << std::endl;
+ }
+
+ kStdOut << kYellow << "[ asm ] " << kWhite << reason << kBlank << std::endl;
+}
+} // namespace Detail \ No newline at end of file