summaryrefslogtreecommitdiffhomepage
path: root/include/CompilerKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-08 04:46:00 -0500
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-08 04:46:00 -0500
commitcfa04915a4c7d77996b49279b5891d1402f439a5 (patch)
tree6418fa73d9f6b7d077edea83b18af586e07b11f9 /include/CompilerKit
parent2ddaf86857828500235e8b8a65c11bb2dd91b8be (diff)
refactor: Refactor `CodeGenerator.h` API.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/CompilerKit')
-rw-r--r--include/CompilerKit/CodeGenerator.h48
-rw-r--r--include/CompilerKit/Detail/Config.h2
-rw-r--r--include/CompilerKit/Utilities/Compiler.h6
3 files changed, 27 insertions, 29 deletions
diff --git a/include/CompilerKit/CodeGenerator.h b/include/CompilerKit/CodeGenerator.h
index 79b185b..259c52d 100644
--- a/include/CompilerKit/CodeGenerator.h
+++ b/include/CompilerKit/CodeGenerator.h
@@ -40,9 +40,9 @@ class AssemblyFactory final {
kArchCount = kArchUnknown - kArchAMD64,
};
- Int32 Compile(std::string sourceFile, const Int32& arch) noexcept;
+ Int32 Compile(STLString sourceFile, const Int32& arch) noexcept;
- void Mount(IAssembly* mountPtr) noexcept;
+ void Mount(IAssembly* mountPtr) noexcept;
IAssembly* Unmount() noexcept;
private:
@@ -66,7 +66,7 @@ class IAssembly {
/// @brief compile to object file.
/// @note Example C++ -> MASM -> AE object.
/// =========================================================== ///
- virtual Int32 CompileToFormat(std::string src, Int32 arch) = 0;
+ virtual Int32 CompileToFormat(STLString src, Int32 arch) = 0;
};
/// =========================================================== ///
@@ -133,9 +133,9 @@ class EncoderInterface {
NECTI_COPY_DEFAULT(EncoderInterface);
- virtual std::string CheckLine(std::string line, std::string file) = 0;
- virtual bool WriteLine(std::string line, std::string file) = 0;
- virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) = 0;
+ virtual STLString CheckLine(STLString line, STLString file) = 0;
+ virtual bool WriteLine(STLString line, STLString file) = 0;
+ virtual bool WriteNumber(const std::size_t& pos, STLString& from_what) = 0;
};
/// =========================================================== ///
@@ -151,13 +151,13 @@ class EncoderAMD64 final : public EncoderInterface {
NECTI_COPY_DEFAULT(EncoderAMD64);
- virtual std::string CheckLine(std::string line, std::string file) override;
- virtual bool WriteLine(std::string line, std::string file) override;
- virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
+ virtual STLString CheckLine(STLString line, STLString file) override;
+ virtual bool WriteLine(STLString line, STLString file) override;
+ virtual bool WriteNumber(const std::size_t& pos, STLString& from_what) override;
- virtual bool WriteNumber16(const std::size_t& pos, std::string& from_what);
- virtual bool WriteNumber32(const std::size_t& pos, std::string& from_what);
- virtual bool WriteNumber8(const std::size_t& pos, std::string& from_what);
+ virtual bool WriteNumber16(const std::size_t& pos, STLString& from_what);
+ virtual bool WriteNumber32(const std::size_t& pos, STLString& from_what);
+ virtual bool WriteNumber8(const std::size_t& pos, STLString& from_what);
};
#endif // __ASM_NEED_AMD64__
@@ -171,9 +171,9 @@ class EncoderARM64 final : public EncoderInterface {
NECTI_COPY_DEFAULT(EncoderARM64);
- virtual std::string CheckLine(std::string line, std::string file) override;
- virtual bool WriteLine(std::string line, std::string file) override;
- virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
+ virtual STLString CheckLine(STLString line, STLString file) override;
+ virtual bool WriteLine(STLString line, STLString file) override;
+ virtual bool WriteNumber(const std::size_t& pos, STLString& from_what) override;
};
#endif // __ASM_NEED_ARM64__
@@ -187,9 +187,9 @@ class Encoder64x0 final : public EncoderInterface {
NECTI_COPY_DEFAULT(Encoder64x0);
- virtual std::string CheckLine(std::string line, std::string file) override;
- virtual bool WriteLine(std::string line, std::string file) override;
- virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
+ virtual STLString CheckLine(STLString line, STLString file) override;
+ virtual bool WriteLine(STLString line, STLString file) override;
+ virtual bool WriteNumber(const std::size_t& pos, STLString& from_what) override;
};
#endif // __ASM_NEED_64x0__
@@ -203,9 +203,9 @@ class Encoder32x0 final : public EncoderInterface {
NECTI_COPY_DEFAULT(Encoder32x0);
- virtual std::string CheckLine(std::string line, std::string file) override;
- virtual bool WriteLine(std::string line, std::string file) override;
- virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
+ virtual STLString CheckLine(STLString line, STLString file) override;
+ virtual bool WriteLine(STLString line, STLString file) override;
+ virtual bool WriteNumber(const std::size_t& pos, STLString& from_what) override;
};
#endif // __ASM_NEED_32x0__
@@ -219,9 +219,9 @@ class EncoderPowerPC final : public EncoderInterface {
NECTI_COPY_DEFAULT(EncoderPowerPC);
- virtual std::string CheckLine(std::string line, std::string file) override;
- virtual bool WriteLine(std::string line, std::string file) override;
- virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
+ virtual STLString CheckLine(STLString line, STLString file) override;
+ virtual bool WriteLine(STLString line, STLString file) override;
+ virtual bool WriteNumber(const std::size_t& pos, STLString& from_what) override;
};
#endif // __ASM_NEED_32x0__
diff --git a/include/CompilerKit/Detail/Config.h b/include/CompilerKit/Detail/Config.h
index 6137e2a..74d0724 100644
--- a/include/CompilerKit/Detail/Config.h
+++ b/include/CompilerKit/Detail/Config.h
@@ -16,7 +16,7 @@
namespace CompilerKit {
inline constexpr int kBaseYear = 1900;
-using STLString = std::string;
+using STLString = std::string;
inline STLString current_date() noexcept {
auto time_data = time(nullptr);
diff --git a/include/CompilerKit/Utilities/Compiler.h b/include/CompilerKit/Utilities/Compiler.h
index 41b7771..0fa95df 100644
--- a/include/CompilerKit/Utilities/Compiler.h
+++ b/include/CompilerKit/Utilities/Compiler.h
@@ -43,9 +43,7 @@ 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;
- }
+ explicit operator bool() { return mBlob.empty() && mOffset > 0UL; }
};
inline void print_error(STLString reason, STLString file) noexcept {
@@ -120,4 +118,4 @@ inline void drvi_crash_handler(std::int32_t id) {
std::exit(NECTI_EXEC_ERROR);
}
-} // namespace Detail
+} // namespace CompilerKit::Detail