summaryrefslogtreecommitdiffhomepage
path: root/dev/CompilerKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-10-26 17:51:30 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-10-26 17:51:30 +0100
commit09d50a07349df2a5fc1c62452d0f924549db83e6 (patch)
tree6e18e55ad5087973a8fabd28e2ec9c0b25d369ab /dev/CompilerKit
parentf0ee6dc640d1d1f00c40bc2f58e9d6a8fd94bd2b (diff)
feat: new ErrorOr API for NeCTI.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/CompilerKit')
-rw-r--r--dev/CompilerKit/Defines.h4
-rw-r--r--dev/CompilerKit/ErrorOr.h13
-rw-r--r--dev/CompilerKit/Frontend.h2
-rw-r--r--dev/CompilerKit/src/Backend/AssemblerAMD64.cc2
-rw-r--r--dev/CompilerKit/src/FrontendHelpers.cc2
5 files changed, 9 insertions, 14 deletions
diff --git a/dev/CompilerKit/Defines.h b/dev/CompilerKit/Defines.h
index 36d51ef..3a62b48 100644
--- a/dev/CompilerKit/Defines.h
+++ b/dev/CompilerKit/Defines.h
@@ -23,10 +23,6 @@
#define NO false
#endif // ifndef NO
-#ifndef BOOL
-#define BOOL bool
-#endif // ifndef BOOL
-
#define SizeType size_t
#define VoidPtr void*
diff --git a/dev/CompilerKit/ErrorOr.h b/dev/CompilerKit/ErrorOr.h
index ef6cb84..ba7b883 100644
--- a/dev/CompilerKit/ErrorOr.h
+++ b/dev/CompilerKit/ErrorOr.h
@@ -9,6 +9,7 @@
#pragma once
+#include <CompilerKit/StringKit.h>
#include <CompilerKit/Defines.h>
#include <CompilerKit/ErrorID.h>
#include <CompilerKit/Ref.h>
@@ -24,17 +25,15 @@ class ErrorOr final {
public:
explicit ErrorOr(Int32 err) : mId(err) {}
-
- explicit ErrorOr(nullPtr Null) {}
-
- explicit ErrorOr(T Class) : mRef(Class) {}
+ explicit ErrorOr(nullPtr null) {}
+ explicit ErrorOr(T klass) : mRef(klass) {}
ErrorOr& operator=(const ErrorOr&) = default;
ErrorOr(const ErrorOr&) = default;
Ref<T> Leak() { return mRef; }
- Int32 Error() { return mId; }
+ ErrorT Error() { return mId; }
Bool HasError() { return mId != NECTI_SUCCESS; }
@@ -42,9 +41,9 @@ class ErrorOr final {
private:
Ref<T> mRef;
- Int32 mId{0};
+ ErrorT mId{0};
};
using ErrorOrAny = ErrorOr<voidPtr>;
-
+using ErrorOrString = ErrorOr<STLString>;
} // namespace CompilerKit
diff --git a/dev/CompilerKit/Frontend.h b/dev/CompilerKit/Frontend.h
index 0f81342..efafae8 100644
--- a/dev/CompilerKit/Frontend.h
+++ b/dev/CompilerKit/Frontend.h
@@ -85,7 +85,7 @@ struct SyntaxLeafList final {
/// \param haystack base string
/// \param needle the string we search for.
/// \return if we found it or not.
-BOOL find_word(STLString haystack, STLString needle) noexcept;
+Bool find_word(STLString haystack, STLString needle) noexcept;
/// find a word within strict conditions and returns a range of it.
/// \param haystack
diff --git a/dev/CompilerKit/src/Backend/AssemblerAMD64.cc b/dev/CompilerKit/src/Backend/AssemblerAMD64.cc
index 603b441..ec71f9b 100644
--- a/dev/CompilerKit/src/Backend/AssemblerAMD64.cc
+++ b/dev/CompilerKit/src/Backend/AssemblerAMD64.cc
@@ -965,7 +965,7 @@ bool CompilerKit::EncoderAMD64::WriteLine(std::string line, std::string file) {
{.fName = "si", .fModRM = 0x6}, {.fName = "di", .fModRM = 7},
};
- BOOL foundInstruction = false;
+ Bool foundInstruction = false;
for (auto& opcodeAMD64 : kOpcodesAMD64) {
// strict check here
diff --git a/dev/CompilerKit/src/FrontendHelpers.cc b/dev/CompilerKit/src/FrontendHelpers.cc
index 37b36f7..dc81fa2 100644
--- a/dev/CompilerKit/src/FrontendHelpers.cc
+++ b/dev/CompilerKit/src/FrontendHelpers.cc
@@ -11,7 +11,7 @@ namespace CompilerKit {
/// \param haystack base string
/// \param needle the string we search for.
/// \return if we found it or not.
-BOOL find_word(STLString haystack, STLString needle) noexcept {
+Bool find_word(STLString haystack, STLString needle) noexcept {
auto index = haystack.find(needle);
// check for needle validity.