summaryrefslogtreecommitdiffhomepage
path: root/src/CompilerKit/Utilities
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-04 16:22:22 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-04 16:25:57 +0100
commit654c31b94d547e8d83be378eb5d5ab16a820dcdd (patch)
tree96b33b2722401bf556de941617b085905b371789 /src/CompilerKit/Utilities
parentcd3092186eb698a9ed175dacb6884f0404e7c062 (diff)
chore:: breaking structural changes of CompilerKit.
The Kit has been redesigned to be expandable to new language frontends. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/CompilerKit/Utilities')
-rw-r--r--src/CompilerKit/Utilities/Assembler.h8
-rw-r--r--src/CompilerKit/Utilities/Compiler.h14
-rw-r--r--src/CompilerKit/Utilities/DLL.h4
3 files changed, 17 insertions, 9 deletions
diff --git a/src/CompilerKit/Utilities/Assembler.h b/src/CompilerKit/Utilities/Assembler.h
index 3da48cc..fc965f0 100644
--- a/src/CompilerKit/Utilities/Assembler.h
+++ b/src/CompilerKit/Utilities/Assembler.h
@@ -27,7 +27,7 @@ static NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) {
case 'x': {
if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 16); !res) {
if (errno != 0) {
- Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit");
+ CompilerKit::Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit");
throw std::runtime_error("invalid_hex");
}
}
@@ -43,7 +43,7 @@ static NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) {
case 'b': {
if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 2); !res) {
if (errno != 0) {
- Detail::print_error("invalid binary number:" + lineBuffer, "CompilerKit");
+ CompilerKit::Detail::print_error("invalid binary number:" + lineBuffer, "CompilerKit");
throw std::runtime_error("invalid_bin");
}
}
@@ -59,7 +59,7 @@ static NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) {
case 'o': {
if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 7); !res) {
if (errno != 0) {
- Detail::print_error("invalid octal number: " + lineBuffer, "CompilerKit");
+ CompilerKit::Detail::print_error("invalid octal number: " + lineBuffer, "CompilerKit");
throw std::runtime_error("invalid_octal");
}
}
@@ -75,7 +75,7 @@ static NumberCast32 GetNumber32(STLString lineBuffer, STLString numberKey) {
default: {
if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 10); !res) {
if (errno != 0) {
- Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit");
+ CompilerKit::Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit");
throw std::runtime_error("invalid_hex");
}
}
diff --git a/src/CompilerKit/Utilities/Compiler.h b/src/CompilerKit/Utilities/Compiler.h
index 165ab53..bbca020 100644
--- a/src/CompilerKit/Utilities/Compiler.h
+++ b/src/CompilerKit/Utilities/Compiler.h
@@ -37,14 +37,18 @@ inline static UInt32 kAcceptableErrors = 0;
inline static bool kVerbose = false;
inline static bool kOutputAsBinary = false;
-namespace Detail {
-/// @brief Linker specific blob metadata structure
-struct DynamicLinkerBlob final {
+namespace CompilerKit::Detail {
+/// @brief Blob structure
+struct Blob final {
std::vector<Char> mBlob{}; // PEF code/bss/data blob.
UIntPtr mOffset{0UL}; // the offset of the PEF container header...
+
+ explicit operator bool() {
+ return mBlob.empty() && mOffset > 0UL;
+ }
};
-inline void print_error(std::string reason, std::string file) noexcept {
+inline void print_error(STLString reason, STLString file) noexcept {
if (reason[0] == '\n') reason.erase(0, 1);
kStdErr << reason << kBlank << std::endl;
@@ -54,7 +58,7 @@ inline void print_error(std::string reason, std::string file) noexcept {
++kAcceptableErrors;
}
-inline void print_warning(std::string reason, std::string file) noexcept {
+inline void print_warning(STLString reason, STLString file) noexcept {
if (reason[0] == '\n') reason.erase(0, 1);
kStdOut << kYellow << reason << kBlank << std::endl;
diff --git a/src/CompilerKit/Utilities/DLL.h b/src/CompilerKit/Utilities/DLL.h
index 58e0cc7..5bfe032 100644
--- a/src/CompilerKit/Utilities/DLL.h
+++ b/src/CompilerKit/Utilities/DLL.h
@@ -20,6 +20,10 @@ struct CompilerKitDylibTraits final {
CompilerKitEntrypoint fEntrypoint{nullptr};
std::mutex fMutex;
+ explicit operator bool() {
+ return fDylib && fEntrypoint;
+ }
+
CompilerKitDylibTraits& operator()(const Char* path, const Char* fEntrypoint) {
std::lock_guard<std::mutex> lock(this->fMutex);