From 6cda526bd4efcee31b1ea7405dc46d7985ba64e6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 4 Jan 2024 21:36:54 +0100 Subject: masm: fix assembler bug where addr1, 0x0 (add r1, 0x0) doesn't error out. cc/ccplus: minor compiler changes, will get to them very soon... refactor: rename C++Kit to CompilerKit. Signed-off-by: Amlal El Mahrouss --- CompilerKit/StdKit/ErrorOr.hpp | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 CompilerKit/StdKit/ErrorOr.hpp (limited to 'CompilerKit/StdKit/ErrorOr.hpp') diff --git a/CompilerKit/StdKit/ErrorOr.hpp b/CompilerKit/StdKit/ErrorOr.hpp new file mode 100644 index 0000000..c2457df --- /dev/null +++ b/CompilerKit/StdKit/ErrorOr.hpp @@ -0,0 +1,58 @@ +/* + * ======================================================== + * + * CompilerKit + * Copyright Western Company, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include +#include + +namespace CompilerKit +{ +using ErrorT = UInt32; + +template +class ErrorOr final +{ + public: + ErrorOr() = default; + ~ErrorOr() = default; + + public: + explicit ErrorOr(Int32 err) + : mId(err) + {} + + explicit ErrorOr(nullPtr Null) + {} + + explicit ErrorOr(T Class) + : mRef(Class) + {} + + ErrorOr &operator=(const ErrorOr &) = default; + ErrorOr(const ErrorOr &) = default; + + Ref Leak() + { + return mRef; + } + + operator bool() + { + return mRef; + } + + private: + Ref mRef; + Int32 mId{0}; +}; + +using ErrorOrAny = ErrorOr; + +} // namespace CompilerKit -- cgit v1.2.3