From 09d50a07349df2a5fc1c62452d0f924549db83e6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 26 Oct 2025 17:51:30 +0100 Subject: feat: new ErrorOr API for NeCTI. Signed-off-by: Amlal El Mahrouss --- dev/CompilerKit/Defines.h | 4 ---- dev/CompilerKit/ErrorOr.h | 13 ++++++------- dev/CompilerKit/Frontend.h | 2 +- dev/CompilerKit/src/Backend/AssemblerAMD64.cc | 2 +- dev/CompilerKit/src/FrontendHelpers.cc | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) (limited to 'dev/CompilerKit') 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 #include #include #include @@ -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 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 mRef; - Int32 mId{0}; + ErrorT mId{0}; }; using ErrorOrAny = ErrorOr; - +using ErrorOrString = ErrorOr; } // 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. -- cgit v1.2.3