summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-07-30 08:50:15 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-07-30 08:50:15 +0100
commit1c8c5cff67b20d86c442b0917d6c1fc6407140df (patch)
tree53ebea660bef14cdc2ff5b7ebefb4049f705f997 /dev
parent073811d89c98d6e1c078a032ca2eedefebf80384 (diff)
feat! Breaking API changes of NeCTI's LibCompiler and LibDebugger.
what: - They've now become CompilerKit and DebuggerKit. - Expanding XCoff for NeBoot PowerPC backend. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev')
-rw-r--r--dev/CompilerKit/AE.h (renamed from dev/LibCompiler/AE.h)31
-rw-r--r--dev/CompilerKit/BasicString.h (renamed from dev/LibCompiler/BasicString.h)10
-rw-r--r--dev/CompilerKit/CodeGen.h (renamed from dev/LibCompiler/CodeGen.h)14
-rw-r--r--dev/CompilerKit/Defines.h (renamed from dev/LibCompiler/Defines.h)4
-rw-r--r--dev/CompilerKit/ErrorID.h (renamed from dev/LibCompiler/ErrorID.h)4
-rw-r--r--dev/CompilerKit/ErrorOr.h (renamed from dev/LibCompiler/ErrorOr.h)12
-rw-r--r--dev/CompilerKit/Frontend.h (renamed from dev/LibCompiler/Frontend.h)10
-rw-r--r--dev/CompilerKit/Macros.h (renamed from dev/LibCompiler/Macros.h)0
-rw-r--r--dev/CompilerKit/PEF.h (renamed from dev/LibCompiler/PEF.h)22
-rw-r--r--dev/CompilerKit/Ref.h (renamed from dev/LibCompiler/Ref.h)8
-rw-r--r--dev/CompilerKit/UUID.h (renamed from dev/LibCompiler/UUID.h)0
-rw-r--r--dev/CompilerKit/Version.h (renamed from dev/LibCompiler/Version.h)0
-rw-r--r--dev/CompilerKit/XCOFF.h (renamed from dev/LibCompiler/XCOFF.h)12
-rw-r--r--dev/CompilerKit/detail/32x0.h (renamed from dev/LibCompiler/Backend/32x0.h)4
-rw-r--r--dev/CompilerKit/detail/64x0.h (renamed from dev/LibCompiler/Backend/64x0.h)4
-rw-r--r--dev/CompilerKit/detail/Aarch64.h (renamed from dev/LibCompiler/Backend/Aarch64.h)4
-rw-r--r--dev/CompilerKit/detail/PowerPC.h (renamed from dev/LibCompiler/Backend/PowerPC.h)0
-rw-r--r--dev/CompilerKit/detail/X64.h (renamed from dev/LibCompiler/Backend/X64.h)4
-rw-r--r--dev/CompilerKit/lc-osx-san.json29
-rw-r--r--dev/CompilerKit/lc-osx.json24
-rw-r--r--dev/CompilerKit/lc-posix.json24
-rw-r--r--dev/CompilerKit/src/Backend/Assembler32x0.cc (renamed from dev/LibCompiler/src/Backend/Assembler32x0.cc)12
-rw-r--r--dev/CompilerKit/src/Backend/Assembler64x0.cc (renamed from dev/LibCompiler/src/Backend/Assembler64x0.cc)92
-rw-r--r--dev/CompilerKit/src/Backend/AssemblerAMD64.cc (renamed from dev/LibCompiler/src/Backend/AssemblerAMD64.cc)176
-rw-r--r--dev/CompilerKit/src/Backend/AssemblerARM64.cc (renamed from dev/LibCompiler/src/Backend/AssemblerARM64.cc)90
-rw-r--r--dev/CompilerKit/src/Backend/AssemblerPowerPC.cc (renamed from dev/LibCompiler/src/Backend/AssemblerPowerPC.cc)96
-rw-r--r--dev/CompilerKit/src/BasicString.cc (renamed from dev/LibCompiler/src/BasicString.cc)8
-rw-r--r--dev/CompilerKit/src/CodeGen.cc (renamed from dev/LibCompiler/src/CodeGen.cc)15
-rw-r--r--dev/CompilerKit/src/Frontend.cc (renamed from dev/LibCompiler/src/Frontend.cc)6
-rw-r--r--dev/CompilerKit/src/Frontend/CCompiler64x0.cc (renamed from dev/LibCompiler/src/Frontend/CCompiler64x0.cc)52
-rw-r--r--dev/CompilerKit/src/Frontend/CCompilerARM64.cc (renamed from dev/LibCompiler/src/Frontend/CCompilerARM64.cc)52
-rw-r--r--dev/CompilerKit/src/Frontend/CCompilerPower64.cc (renamed from dev/LibCompiler/src/Frontend/CCompilerPower64.cc)50
-rw-r--r--dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc (renamed from dev/LibCompiler/src/Frontend/CPlusPlusCompilerAMD64.cc)306
-rw-r--r--dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc (renamed from dev/LibCompiler/src/Linker/DynamicLinker64PEF.cc)178
-rw-r--r--dev/CompilerKit/src/Macro/CPlusPlusCompilerPreProcessor.cc (renamed from dev/LibCompiler/src/Macro/CPlusPlusCompilerPreProcessor.cc)122
-rw-r--r--dev/CompilerKit/utils/AsmUtils.h (renamed from dev/LibCompiler/Util/AsmUtils.h)16
-rw-r--r--dev/CompilerKit/utils/CompilerUtils.h (renamed from dev/LibCompiler/Util/CompilerUtils.h)16
-rw-r--r--dev/CompilerKit/utils/DylibHelpers.h (renamed from dev/LibCompiler/Util/DylibHelpers.h)6
-rw-r--r--dev/DebuggerKit/CommonCLI.inl (renamed from dev/LibDebugger/CommonCLI.inl)14
-rw-r--r--dev/DebuggerKit/DebuggerContract.h (renamed from dev/LibDebugger/DebuggerContract.h)4
-rw-r--r--dev/DebuggerKit/NeKernelContract.h (renamed from dev/LibDebugger/NeKernelContract.h)6
-rw-r--r--dev/DebuggerKit/POSIXMachContract.h (renamed from dev/LibDebugger/POSIXMachContract.h)8
-rw-r--r--dev/DebuggerKit/Version.h (renamed from dev/LibDebugger/Version.h)0
-rw-r--r--dev/DebuggerKit/ld-nekernel.json17
-rw-r--r--dev/DebuggerKit/ld-osx.json17
-rw-r--r--dev/DebuggerKit/src/NeKernelContract.cc (renamed from dev/LibDebugger/src/NeKernelContract.cc)14
-rw-r--r--dev/DebuggerKit/src/NeKernelContractCLI.cc (renamed from dev/LibDebugger/src/NeKernelContractCLI.cc)22
-rw-r--r--dev/DebuggerKit/src/POSIXMachContractCLI.cc (renamed from dev/LibDebugger/src/POSIXMachContractCLI.cc)23
-rw-r--r--dev/LibC++/__power64.inc2
-rw-r--r--dev/ThirdParty/Dialogs.h (renamed from dev/Vendor/Dialogs.h)0
50 files changed, 881 insertions, 759 deletions
diff --git a/dev/LibCompiler/AE.h b/dev/CompilerKit/AE.h
index 0a15417..3194417 100644
--- a/dev/LibCompiler/AE.h
+++ b/dev/CompilerKit/AE.h
@@ -1,7 +1,7 @@
/*
* ========================================================
*
- * LibCompiler
+ * CompilerKit
* Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
*
* ========================================================
@@ -9,7 +9,7 @@
#pragma once
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
#define kAEMag0 'A'
#define kAEMag1 'E'
@@ -19,11 +19,14 @@
#define kAEMagLen (2)
#define kAENullType (0x00)
+/// @author Amlal El Mahrouss
+
+/// @brief
// Advanced Executable File Format for ld64.
// Reloctable by offset is the default strategy.
// You can also relocate at runtime but that's up to the operating system loader.
-namespace LibCompiler {
+namespace CompilerKit {
// @brief Advanced Executable Header
// One thing to keep in mind.
// This object format, is reloctable.
@@ -55,33 +58,33 @@ enum {
kKindRelocationByOffset = 0x23f,
kKindRelocationAtRuntime = 0x34f,
};
-} // namespace LibCompiler
+} // namespace CompilerKit
// provide operator<< for AE
-inline std::ofstream& operator<<(std::ofstream& fp, LibCompiler::AEHeader& container) {
- fp.write((char*) &container, sizeof(LibCompiler::AEHeader));
+inline std::ofstream& operator<<(std::ofstream& fp, CompilerKit::AEHeader& container) {
+ fp.write((char*) &container, sizeof(CompilerKit::AEHeader));
return fp;
}
-inline std::ofstream& operator<<(std::ofstream& fp, LibCompiler::AERecordHeader& container) {
- fp.write((char*) &container, sizeof(LibCompiler::AERecordHeader));
+inline std::ofstream& operator<<(std::ofstream& fp, CompilerKit::AERecordHeader& container) {
+ fp.write((char*) &container, sizeof(CompilerKit::AERecordHeader));
return fp;
}
-inline std::ifstream& operator>>(std::ifstream& fp, LibCompiler::AEHeader& container) {
- fp.read((char*) &container, sizeof(LibCompiler::AEHeader));
+inline std::ifstream& operator>>(std::ifstream& fp, CompilerKit::AEHeader& container) {
+ fp.read((char*) &container, sizeof(CompilerKit::AEHeader));
return fp;
}
-inline std::ifstream& operator>>(std::ifstream& fp, LibCompiler::AERecordHeader& container) {
- fp.read((char*) &container, sizeof(LibCompiler::AERecordHeader));
+inline std::ifstream& operator>>(std::ifstream& fp, CompilerKit::AERecordHeader& container) {
+ fp.read((char*) &container, sizeof(CompilerKit::AERecordHeader));
return fp;
}
-namespace LibCompiler::Utils {
+namespace CompilerKit::Utils {
/**
* @brief AE Reader protocol
*
@@ -124,4 +127,4 @@ class AEReadableProtocol final {
return reinterpret_cast<TypeClass*>(raw);
}
};
-} // namespace LibCompiler::Utils
+} // namespace CompilerKit::Utils
diff --git a/dev/LibCompiler/BasicString.h b/dev/CompilerKit/BasicString.h
index 38e585f..a1ada68 100644
--- a/dev/LibCompiler/BasicString.h
+++ b/dev/CompilerKit/BasicString.h
@@ -1,7 +1,7 @@
/*
* ========================================================
*
- * LibCompiler
+ * CompilerKit
* Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
*
* ========================================================
@@ -9,10 +9,10 @@
#pragma once
-#include <LibCompiler/Defines.h>
-#include <LibCompiler/ErrorOr.h>
+#include <CompilerKit/Defines.h>
+#include <CompilerKit/ErrorOr.h>
-namespace LibCompiler {
+namespace CompilerKit {
class StringBuilder;
class BasicString;
@@ -79,4 +79,4 @@ struct StringBuilder final {
};
using PStringOr = ErrorOr<BasicString>;
-} // namespace LibCompiler
+} // namespace CompilerKit
diff --git a/dev/LibCompiler/CodeGen.h b/dev/CompilerKit/CodeGen.h
index 43242b3..9a3077b 100644
--- a/dev/LibCompiler/CodeGen.h
+++ b/dev/CompilerKit/CodeGen.h
@@ -6,14 +6,14 @@
#pragma once
-#include <LibCompiler/BasicString.h>
-#include <LibCompiler/Defines.h>
-#include <LibCompiler/Macros.h>
+#include <CompilerKit/BasicString.h>
+#include <CompilerKit/Defines.h>
+#include <CompilerKit/Macros.h>
-#define LC_ASSEMBLY_INTERFACE : public ::LibCompiler::AssemblyInterface
-#define LC_ENCODER : public ::LibCompiler::EncoderInterface
+#define LC_ASSEMBLY_INTERFACE : public ::CompilerKit::AssemblyInterface
+#define LC_ENCODER : public ::CompilerKit::EncoderInterface
-namespace LibCompiler {
+namespace CompilerKit {
class AssemblyFactory;
class AssemblyInterface;
@@ -203,4 +203,4 @@ class EncoderPowerPC final : public EncoderInterface {
};
#endif // __ASM_NEED_32x0__
-} // namespace LibCompiler
+} // namespace CompilerKit
diff --git a/dev/LibCompiler/Defines.h b/dev/CompilerKit/Defines.h
index 602814b..c3d40ac 100644
--- a/dev/LibCompiler/Defines.h
+++ b/dev/CompilerKit/Defines.h
@@ -99,7 +99,7 @@
#define LC_IMPORT_C extern "C"
#define LC_IMPORT extern
-namespace LibCompiler {
+namespace CompilerKit {
inline constexpr int kBaseYear = 1900;
typedef std::string STLString;
@@ -147,7 +147,7 @@ inline bool install_signal(Int32 signal, void (*handler)(int)) noexcept {
return true;
}
-} // namespace LibCompiler
+} // namespace CompilerKit
#define ATTRIBUTE(X) __attribute__((X))
#define PACKED ATTRIBUTE(packed)
diff --git a/dev/LibCompiler/ErrorID.h b/dev/CompilerKit/ErrorID.h
index c82fb16..22ca242 100644
--- a/dev/LibCompiler/ErrorID.h
+++ b/dev/CompilerKit/ErrorID.h
@@ -1,7 +1,7 @@
/*
* ========================================================
*
- * LibCompiler
+ * CompilerKit
* Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
*
* ========================================================
@@ -9,7 +9,7 @@
#pragma once
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
#define LIBCOMPILER_SUCCESS 0
#define LIBCOMPILER_EXEC_ERROR -30
diff --git a/dev/LibCompiler/ErrorOr.h b/dev/CompilerKit/ErrorOr.h
index 77015b1..700da23 100644
--- a/dev/LibCompiler/ErrorOr.h
+++ b/dev/CompilerKit/ErrorOr.h
@@ -1,7 +1,7 @@
/*
* ========================================================
*
- * LibCompiler
+ * CompilerKit
* Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
*
* ========================================================
@@ -9,11 +9,11 @@
#pragma once
-#include <LibCompiler/Defines.h>
-#include <LibCompiler/ErrorID.h>
-#include <LibCompiler/Ref.h>
+#include <CompilerKit/Defines.h>
+#include <CompilerKit/ErrorID.h>
+#include <CompilerKit/Ref.h>
-namespace LibCompiler {
+namespace CompilerKit {
using ErrorT = UInt32;
template <typename T>
@@ -47,4 +47,4 @@ class ErrorOr final {
using ErrorOrAny = ErrorOr<voidPtr>;
-} // namespace LibCompiler
+} // namespace CompilerKit
diff --git a/dev/LibCompiler/Frontend.h b/dev/CompilerKit/Frontend.h
index d5d9733..8af3066 100644
--- a/dev/LibCompiler/Frontend.h
+++ b/dev/CompilerKit/Frontend.h
@@ -6,11 +6,11 @@
#pragma once
-#include <LibCompiler/CodeGen.h>
+#include <CompilerKit/CodeGen.h>
-#define LC_COMPILER_FRONTEND : public ::LibCompiler::CompilerFrontendInterface
+#define LC_COMPILER_FRONTEND : public ::CompilerKit::CompilerFrontendInterface
-namespace LibCompiler {
+namespace CompilerKit {
inline static auto kInvalidFrontend = "?";
struct SyntaxLeafList;
@@ -111,11 +111,11 @@ class CompilerFrontendInterface {
//! @brief Compile a syntax tree ouf of the text.
//! Also takes the source file name for metadata.
- virtual LibCompiler::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) = 0;
+ virtual CompilerKit::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) = 0;
//! @brief What language are we dealing with?
virtual const char* Language() { return kInvalidFrontend; }
virtual bool IsValid() { return strcmp(this->Language(), kInvalidFrontend) > 0; }
};
-} // namespace LibCompiler
+} // namespace CompilerKit
diff --git a/dev/LibCompiler/Macros.h b/dev/CompilerKit/Macros.h
index 5027ffa..5027ffa 100644
--- a/dev/LibCompiler/Macros.h
+++ b/dev/CompilerKit/Macros.h
diff --git a/dev/LibCompiler/PEF.h b/dev/CompilerKit/PEF.h
index ad01a8b..a1feec6 100644
--- a/dev/LibCompiler/PEF.h
+++ b/dev/CompilerKit/PEF.h
@@ -6,7 +6,7 @@
#pragma once
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
// @file PEF.h
// @brief Preferred Executable Format
@@ -38,7 +38,7 @@
#define kPefStart "__ImageStart"
-namespace LibCompiler {
+namespace CompilerKit {
enum {
kPefArchIntel86S,
kPefArchAMD64,
@@ -107,24 +107,24 @@ enum {
kPefLinkerID = 0x1,
kPefCount = 4,
};
-} // namespace LibCompiler
+} // namespace CompilerKit
-inline std::ofstream& operator<<(std::ofstream& fp, LibCompiler::PEFContainer& container) {
- fp.write((char*) &container, sizeof(LibCompiler::PEFContainer));
+inline std::ofstream& operator<<(std::ofstream& fp, CompilerKit::PEFContainer& container) {
+ fp.write((char*) &container, sizeof(CompilerKit::PEFContainer));
return fp;
}
-inline std::ofstream& operator<<(std::ofstream& fp, LibCompiler::PEFCommandHeader& container) {
- fp.write((char*) &container, sizeof(LibCompiler::PEFCommandHeader));
+inline std::ofstream& operator<<(std::ofstream& fp, CompilerKit::PEFCommandHeader& container) {
+ fp.write((char*) &container, sizeof(CompilerKit::PEFCommandHeader));
return fp;
}
-inline std::ifstream& operator>>(std::ifstream& fp, LibCompiler::PEFContainer& container) {
- fp.read((char*) &container, sizeof(LibCompiler::PEFContainer));
+inline std::ifstream& operator>>(std::ifstream& fp, CompilerKit::PEFContainer& container) {
+ fp.read((char*) &container, sizeof(CompilerKit::PEFContainer));
return fp;
}
-inline std::ifstream& operator>>(std::ifstream& fp, LibCompiler::PEFCommandHeader& container) {
- fp.read((char*) &container, sizeof(LibCompiler::PEFCommandHeader));
+inline std::ifstream& operator>>(std::ifstream& fp, CompilerKit::PEFCommandHeader& container) {
+ fp.read((char*) &container, sizeof(CompilerKit::PEFCommandHeader));
return fp;
}
diff --git a/dev/LibCompiler/Ref.h b/dev/CompilerKit/Ref.h
index 60eafc3..a3640ac 100644
--- a/dev/LibCompiler/Ref.h
+++ b/dev/CompilerKit/Ref.h
@@ -2,7 +2,7 @@
/*
* ========================================================
*
- * LibCompiler
+ * CompilerKit
* Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
*
* ========================================================
@@ -10,9 +10,9 @@
#pragma once
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
-namespace LibCompiler {
+namespace CompilerKit {
// @author EL Mahrouss Amlal
// @brief Reference holder class, refers to a pointer of data in static memory.
template <typename T>
@@ -73,4 +73,4 @@ class NonNullRef final {
private:
Ref<T> m_Ref{nullptr};
};
-} // namespace LibCompiler
+} // namespace CompilerKit
diff --git a/dev/LibCompiler/UUID.h b/dev/CompilerKit/UUID.h
index 39db276..39db276 100644
--- a/dev/LibCompiler/UUID.h
+++ b/dev/CompilerKit/UUID.h
diff --git a/dev/LibCompiler/Version.h b/dev/CompilerKit/Version.h
index 93a7c00..93a7c00 100644
--- a/dev/LibCompiler/Version.h
+++ b/dev/CompilerKit/Version.h
diff --git a/dev/LibCompiler/XCOFF.h b/dev/CompilerKit/XCOFF.h
index 7aa13d6..83da378 100644
--- a/dev/LibCompiler/XCOFF.h
+++ b/dev/CompilerKit/XCOFF.h
@@ -14,7 +14,7 @@
#ifndef __XCOFF__
#define __XCOFF__
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
#define kXCOFF64Magic 0x01F7
@@ -23,8 +23,10 @@
#define kXCOFFLnno 0x0004
#define kXCOFFLSyms 0x0008
-namespace LibCompiler {
-/// @brief XCoff identification header.
+namespace CompilerKit {
+struct XCoffFileHeader;
+
+/// @brief XCoff file header.
typedef struct XCoffFileHeader {
UInt16 fMagic;
UInt16 fTarget;
@@ -34,6 +36,8 @@ typedef struct XCoffFileHeader {
UInt32 fNumSyms;
UInt16 fOptHdr; // ?: Number of bytes in optional header
} XCoffFileHeader;
-} // namespace LibCompiler
+
+typedef struct XCoffFileHeader* XCoffFileHeaderPtr;
+} // namespace CompilerKit
#endif // ifndef __XCOFF__
diff --git a/dev/LibCompiler/Backend/32x0.h b/dev/CompilerKit/detail/32x0.h
index 46af118..124d9f4 100644
--- a/dev/LibCompiler/Backend/32x0.h
+++ b/dev/CompilerKit/detail/32x0.h
@@ -6,10 +6,10 @@
#pragma once
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
// @brief Open32x0 support.
-// @file Backend/32x0.h
+// @file detail/32x0.h
#define LC_ASM_OPCODE(__NAME, __OPCODE, __FUNCT3, __FUNCT7) \
{.fName = __NAME, .fOpcode = __OPCODE, .fFunct3 = __FUNCT3, .fFunct7 = __FUNCT7},
diff --git a/dev/LibCompiler/Backend/64x0.h b/dev/CompilerKit/detail/64x0.h
index 5c6dbbd..af01c07 100644
--- a/dev/LibCompiler/Backend/64x0.h
+++ b/dev/CompilerKit/detail/64x0.h
@@ -6,11 +6,11 @@
#pragma once
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
#include <vector>
// @brief Open64x0 support.
-// @file Backend/64x0.h
+// @file detail/64x0.h
#define LC_ASM_OPCODE(__NAME, __OPCODE, __FUNCT3, __FUNCT7) \
{.fName = __NAME, .fOpcode = __OPCODE, .fFunct3 = __FUNCT3, .fFunct7 = __FUNCT7},
diff --git a/dev/LibCompiler/Backend/Aarch64.h b/dev/CompilerKit/detail/Aarch64.h
index 2676306..528a993 100644
--- a/dev/LibCompiler/Backend/Aarch64.h
+++ b/dev/CompilerKit/detail/Aarch64.h
@@ -6,11 +6,11 @@ Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved
#pragma once
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
#include <stdint.h>
/// @brief ARM64 encoding support.
-/// @file Backend/Aarch64.h
+/// @file detail/Aarch64.h
struct CpuOpcodeArm64;
diff --git a/dev/LibCompiler/Backend/PowerPC.h b/dev/CompilerKit/detail/PowerPC.h
index 03aea49..03aea49 100644
--- a/dev/LibCompiler/Backend/PowerPC.h
+++ b/dev/CompilerKit/detail/PowerPC.h
diff --git a/dev/LibCompiler/Backend/X64.h b/dev/CompilerKit/detail/X64.h
index f489515..3f7420a 100644
--- a/dev/LibCompiler/Backend/X64.h
+++ b/dev/CompilerKit/detail/X64.h
@@ -6,10 +6,10 @@
#pragma once
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
// @brief AMD64 support.
-// @file Backend/X64.h
+// @file detail/X64.h
#define LC_ASM_OPCODE(__NAME, __OPCODE) {.fName = __NAME, .fOpcode = __OPCODE},
diff --git a/dev/CompilerKit/lc-osx-san.json b/dev/CompilerKit/lc-osx-san.json
new file mode 100644
index 0000000..244936d
--- /dev/null
+++ b/dev/CompilerKit/lc-osx-san.json
@@ -0,0 +1,29 @@
+{
+ "compiler_path": "clang++",
+ "compiler_std": "c++20",
+ "headers_path": [
+ "../CompilerKit",
+ "../",
+ "../CompilerKit/src/",
+ "../CompilerKit/src/impl"
+ ],
+ "sources_path": [
+ "src/*.cc",
+ "src/*/*.cc"
+ ],
+ "output_name": "/usr/local/lib/libCompilerKit.dylib",
+ "compiler_flags": [
+ "-fPIC",
+ "-shared",
+ "-fstack-protector-all",
+ "-fno-omit-frame-pointer",
+ "-g",
+ "-fsanitize=address",
+ "-fsanitize=undefined"
+ ],
+ "cpp_macros": [
+ "__LIBCOMPILER__=202505",
+ "LC_USE_STRUCTS=1",
+ "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
+ ]
+} \ No newline at end of file
diff --git a/dev/CompilerKit/lc-osx.json b/dev/CompilerKit/lc-osx.json
new file mode 100644
index 0000000..3116045
--- /dev/null
+++ b/dev/CompilerKit/lc-osx.json
@@ -0,0 +1,24 @@
+{
+ "compiler_path": "clang++",
+ "compiler_std": "c++20",
+ "headers_path": [
+ "../CompilerKit",
+ "../",
+ "../CompilerKit/src/",
+ "../CompilerKit/src/impl"
+ ],
+ "sources_path": [
+ "src/*.cc",
+ "src/*/*.cc"
+ ],
+ "output_name": "/usr/local/lib/libCompilerKit.dylib",
+ "compiler_flags": [
+ "-fPIC",
+ "-shared"
+ ],
+ "cpp_macros": [
+ "__LIBCOMPILER__=202505",
+ "LC_USE_STRUCTS=1",
+ "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
+ ]
+} \ No newline at end of file
diff --git a/dev/CompilerKit/lc-posix.json b/dev/CompilerKit/lc-posix.json
new file mode 100644
index 0000000..6e824d4
--- /dev/null
+++ b/dev/CompilerKit/lc-posix.json
@@ -0,0 +1,24 @@
+{
+ "compiler_path": "g++",
+ "compiler_std": "c++20",
+ "headers_path": [
+ "../CompilerKit",
+ "../",
+ "../CompilerKit/src/",
+ "../CompilerKit/src/impl"
+ ],
+ "sources_path": [
+ "src/*.cc",
+ "src/*/*.cc"
+ ],
+ "output_name": "/usr/local/lib/libCompilerKit.so",
+ "compiler_flags": [
+ "-fPIC",
+ "-shared"
+ ],
+ "cpp_macros": [
+ "__LIBCOMPILER__=202505",
+ "LC_USE_STRUCTS=1",
+ "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
+ ]
+} \ No newline at end of file
diff --git a/dev/LibCompiler/src/Backend/Assembler32x0.cc b/dev/CompilerKit/src/Backend/Assembler32x0.cc
index b7ff321..e298d2d 100644
--- a/dev/LibCompiler/src/Backend/Assembler32x0.cc
+++ b/dev/CompilerKit/src/Backend/Assembler32x0.cc
@@ -21,11 +21,11 @@
#define __ASM_NEED_32x0__ 1
#endif
-#include <LibCompiler/AE.h>
-#include <LibCompiler/Backend/32x0.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/PEF.h>
-#include <LibCompiler/Util/CompilerUtils.h>
+#include <CompilerKit/AE.h>
+#include <CompilerKit/detail/32x0.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/PEF.h>
+#include <CompilerKit/utils/CompilerUtils.h>
/////////////////////////////////////////////////////////////////////////////////////////
@@ -34,6 +34,6 @@
/////////////////////////////////////////////////////////////////////////////////////////
LIBCOMPILER_MODULE(NEAssemblerMain32000) {
- LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler);
+ CompilerKit::install_signal(SIGSEGV, Detail::drvi_crash_handler);
return EXIT_SUCCESS;
}
diff --git a/dev/LibCompiler/src/Backend/Assembler64x0.cc b/dev/CompilerKit/src/Backend/Assembler64x0.cc
index 765bea2..32b199d 100644
--- a/dev/LibCompiler/src/Backend/Assembler64x0.cc
+++ b/dev/CompilerKit/src/Backend/Assembler64x0.cc
@@ -21,11 +21,11 @@
#define __ASM_NEED_64x0__ 1
#endif
-#include <LibCompiler/AE.h>
-#include <LibCompiler/Backend/64x0.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/PEF.h>
-#include <LibCompiler/Util/CompilerUtils.h>
+#include <CompilerKit/AE.h>
+#include <CompilerKit/detail/64x0.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/PEF.h>
+#include <CompilerKit/utils/CompilerUtils.h>
#include <algorithm>
#include <filesystem>
#include <fstream>
@@ -38,7 +38,7 @@
/////////////////////
-static char kOutputArch = LibCompiler::kPefArch64000;
+static char kOutputArch = CompilerKit::kPefArch64000;
constexpr auto k64x0IPAlignment = 0x1U;
@@ -49,10 +49,10 @@ static std::vector<std::pair<std::string, std::uintptr_t>> kOriginLabel;
static std::vector<e64k_num_t> kBytes;
-static LibCompiler::AERecordHeader kCurrentRecord{
- .fName = "", .fKind = LibCompiler::kPefCode, .fSize = 0, .fOffset = 0};
+static CompilerKit::AERecordHeader kCurrentRecord{
+ .fName = "", .fKind = CompilerKit::kPefCode, .fSize = 0, .fOffset = 0};
-static std::vector<LibCompiler::AERecordHeader> kRecords;
+static std::vector<CompilerKit::AERecordHeader> kRecords;
static std::vector<std::string> kUndefinedSymbols;
static const std::string kUndefinedSymbol = ":UndefinedSymbol:";
@@ -68,7 +68,7 @@ static bool asm_read_attributes(std::string line);
/////////////////////////////////////////////////////////////////////////////////////////
LIBCOMPILER_MODULE(AssemblerMain64x0) {
- LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler);
+ CompilerKit::install_signal(SIGSEGV, Detail::drvi_crash_handler);
for (size_t i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
@@ -124,13 +124,13 @@ LIBCOMPILER_MODULE(AssemblerMain64x0) {
std::string line;
- LibCompiler::AEHeader hdr{0};
+ CompilerKit::AEHeader hdr{0};
memset(hdr.fPad, kAENullType, kAEPad);
hdr.fMagic[0] = kAEMag0;
hdr.fMagic[1] = kAEMag1;
- hdr.fSize = sizeof(LibCompiler::AEHeader);
+ hdr.fSize = sizeof(CompilerKit::AEHeader);
hdr.fArch = kOutputArch;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -139,7 +139,7 @@ LIBCOMPILER_MODULE(AssemblerMain64x0) {
/////////////////////////////////////////////////////////////////////////////////////////
- LibCompiler::Encoder64x0 asm64;
+ CompilerKit::Encoder64x0 asm64;
while (std::getline(file_ptr, line)) {
if (auto ln = asm64.CheckLine(line, argv[i]); !ln.empty()) {
@@ -153,7 +153,7 @@ LIBCOMPILER_MODULE(AssemblerMain64x0) {
} catch (const std::exception& e) {
if (kVerbose) {
std::string what = e.what();
- Detail::print_warning("exit because of: " + what, "LibCompiler");
+ Detail::print_warning("exit because of: " + what, "CompilerKit");
}
std::filesystem::remove(object_output);
@@ -189,7 +189,7 @@ LIBCOMPILER_MODULE(AssemblerMain64x0) {
for (auto& rec : kRecords) {
if (kVerbose) kStdOut << "Assembler64x0: Wrote record " << rec.fName << " to file...\n";
- rec.fFlags |= LibCompiler::kKindRelocationAtRuntime;
+ rec.fFlags |= CompilerKit::kKindRelocationAtRuntime;
rec.fOffset = record_count;
++record_count;
@@ -200,7 +200,7 @@ LIBCOMPILER_MODULE(AssemblerMain64x0) {
++record_count;
for (auto& sym : kUndefinedSymbols) {
- LibCompiler::AERecordHeader _record_hdr{0};
+ CompilerKit::AERecordHeader _record_hdr{0};
if (kVerbose) kStdOut << "Assembler64x0: Wrote symbol " << sym << " to file...\n";
@@ -266,9 +266,9 @@ asm_fail_exit:
static bool asm_read_attributes(std::string line) {
// extern_segment is the opposite of public_segment, it signals to the ld
// that we need this symbol.
- if (LibCompiler::find_word(line, "extern_segment")) {
+ if (CompilerKit::find_word(line, "extern_segment")) {
if (kOutputAsBinary) {
- Detail::print_error("Invalid extern_segment directive in flat binary mode.", "LibCompiler");
+ Detail::print_error("Invalid extern_segment directive in flat binary mode.", "CompilerKit");
throw std::runtime_error("invalid_extern_segment_bin");
}
@@ -292,20 +292,20 @@ static bool asm_read_attributes(std::string line) {
if (name.find(".code64") != std::string::npos) {
// data is treated as code.
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
} else if (name.find(".data64") != std::string::npos) {
// no code will be executed from here.
- kCurrentRecord.fKind = LibCompiler::kPefData;
+ kCurrentRecord.fKind = CompilerKit::kPefData;
} else if (name.find(".zero64") != std::string::npos) {
// this is a bss section.
- kCurrentRecord.fKind = LibCompiler::kPefZero;
+ kCurrentRecord.fKind = CompilerKit::kPefZero;
}
// this is a special case for the start stub.
// we want this so that ld can find it.
if (name == kPefStart) {
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
}
// now we can tell the code size of the previous kCurrentRecord.
@@ -326,9 +326,9 @@ static bool asm_read_attributes(std::string line) {
// public_segment is a special keyword used by Assembler64x0 to tell the AE output stage to
// mark this section as a header. it currently supports .code64, .data64.,
// .zero64
- else if (LibCompiler::find_word(line, "public_segment")) {
+ else if (CompilerKit::find_word(line, "public_segment")) {
if (kOutputAsBinary) {
- Detail::print_error("Invalid public_segment directive in flat binary mode.", "LibCompiler");
+ Detail::print_error("Invalid public_segment directive in flat binary mode.", "CompilerKit");
throw std::runtime_error("invalid_public_segment_bin");
}
@@ -344,24 +344,24 @@ static bool asm_read_attributes(std::string line) {
// data is treated as code.
name_copy.erase(name_copy.find(".code64"), strlen(".code64"));
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
} else if (name.find(".data64") != std::string::npos) {
// no code will be executed from here.
name_copy.erase(name_copy.find(".data64"), strlen(".data64"));
- kCurrentRecord.fKind = LibCompiler::kPefData;
+ kCurrentRecord.fKind = CompilerKit::kPefData;
} else if (name.find(".zero64") != std::string::npos) {
// this is a bss section.
name_copy.erase(name_copy.find(".zero64"), strlen(".zero64"));
- kCurrentRecord.fKind = LibCompiler::kPefZero;
+ kCurrentRecord.fKind = CompilerKit::kPefZero;
}
// this is a special case for the start stub.
// we want this so that ld can find it.
if (name == kPefStart) {
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
}
while (name_copy.find(" ") != std::string::npos) name_copy.erase(name_copy.find(" "), 1);
@@ -409,12 +409,12 @@ bool is_valid_64x0(std::string str) {
/////////////////////////////////////////////////////////////////////////////////////////
-std::string LibCompiler::Encoder64x0::CheckLine(std::string line, std::string file) {
+std::string CompilerKit::Encoder64x0::CheckLine(std::string line, std::string file) {
std::string err_str;
- if (line.empty() || LibCompiler::find_word(line, "extern_segment") ||
- LibCompiler::find_word(line, "public_segment") || line.find('#') != std::string::npos ||
- LibCompiler::find_word(line, ";")) {
+ if (line.empty() || CompilerKit::find_word(line, "extern_segment") ||
+ CompilerKit::find_word(line, "public_segment") || line.find('#') != std::string::npos ||
+ CompilerKit::find_word(line, ";")) {
if (line.find('#') != std::string::npos) {
line.erase(line.find('#'));
} else if (line.find(';') != std::string::npos) {
@@ -496,7 +496,7 @@ std::string LibCompiler::Encoder64x0::CheckLine(std::string line, std::string fi
// if it is like that -> addr1, 0x0
if (auto it = std::find(filter_inst.begin(), filter_inst.end(), opcode64x0.fName);
it == filter_inst.cend()) {
- if (LibCompiler::find_word(line, opcode64x0.fName)) {
+ if (CompilerKit::find_word(line, opcode64x0.fName)) {
if (!isspace(line[line.find(opcode64x0.fName) + strlen(opcode64x0.fName)])) {
err_str += "\nMissing space between ";
err_str += opcode64x0.fName;
@@ -515,19 +515,19 @@ std::string LibCompiler::Encoder64x0::CheckLine(std::string line, std::string fi
return err_str;
}
-bool LibCompiler::Encoder64x0::WriteNumber(const std::size_t& pos, std::string& jump_label) {
+bool CompilerKit::Encoder64x0::WriteNumber(const std::size_t& pos, std::string& jump_label) {
if (!isdigit(jump_label[pos])) return false;
switch (jump_label[pos + 1]) {
case 'x': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16); !res) {
if (errno != 0) {
- Detail::print_error("invalid hex number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid hex number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_hex_number");
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
for (char& i : num.number) {
kBytes.push_back(i);
@@ -542,12 +542,12 @@ bool LibCompiler::Encoder64x0::WriteNumber(const std::size_t& pos, std::string&
case 'b': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2); !res) {
if (errno != 0) {
- Detail::print_error("invalid binary number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid binary number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_bin");
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
if (kVerbose) {
kStdOut << "Assembler64x0: found a base 2 number here: " << jump_label.substr(pos) << "\n";
@@ -562,12 +562,12 @@ bool LibCompiler::Encoder64x0::WriteNumber(const std::size_t& pos, std::string&
case 'o': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7); !res) {
if (errno != 0) {
- Detail::print_error("invalid octal number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid octal number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_octal");
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
if (kVerbose) {
kStdOut << "Assembler64x0: found a base 8 number here: " << jump_label.substr(pos) << "\n";
@@ -591,7 +591,7 @@ bool LibCompiler::Encoder64x0::WriteNumber(const std::size_t& pos, std::string&
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
for (char& i : num.number) {
kBytes.push_back(i);
@@ -610,12 +610,12 @@ bool LibCompiler::Encoder64x0::WriteNumber(const std::size_t& pos, std::string&
/////////////////////////////////////////////////////////////////////////////////////////
-bool LibCompiler::Encoder64x0::WriteLine(std::string line, std::string file) {
- if (LibCompiler::find_word(line, "public_segment ")) return true;
+bool CompilerKit::Encoder64x0::WriteLine(std::string line, std::string file) {
+ if (CompilerKit::find_word(line, "public_segment ")) return true;
for (auto& opcode64x0 : kOpcodes64x0) {
// strict check here
- if (LibCompiler::find_word(line, opcode64x0.fName) && Detail::algorithm::is_valid_64x0(line)) {
+ if (CompilerKit::find_word(line, opcode64x0.fName) && Detail::algorithm::is_valid_64x0(line)) {
std::string name(opcode64x0.fName);
std::string jump_label, cpy_jump_label;
@@ -645,7 +645,7 @@ bool LibCompiler::Encoder64x0::WriteLine(std::string line, std::string file) {
// it ranges from r0 to r19
// something like r190 doesn't exist in the instruction set.
- if (kOutputArch == LibCompiler::kPefArch64000) {
+ if (kOutputArch == CompilerKit::kPefArch64000) {
if (isdigit(line[line_index + 3]) && isdigit(line[line_index + 2])) {
reg_str += line[line_index + 3];
Detail::print_error("invalid register index, r" + reg_str +
@@ -797,7 +797,7 @@ bool LibCompiler::Encoder64x0::WriteLine(std::string line, std::string file) {
<< " to address: " << label.second << std::endl;
}
- LibCompiler::NumberCast64 num(label.second);
+ CompilerKit::NumberCast64 num(label.second);
for (auto& num : num.number) {
kBytes.push_back(num);
diff --git a/dev/LibCompiler/src/Backend/AssemblerAMD64.cc b/dev/CompilerKit/src/Backend/AssemblerAMD64.cc
index 4d03fd7..0446a10 100644
--- a/dev/LibCompiler/src/Backend/AssemblerAMD64.cc
+++ b/dev/CompilerKit/src/Backend/AssemblerAMD64.cc
@@ -21,7 +21,7 @@
/////////////////////////////////////////////////////////////////////////////////////////
-#include "LibCompiler/Defines.h"
+#include "CompilerKit/Defines.h"
#ifndef __ASM_NEED_AMD64__
#define __ASM_NEED_AMD64__ 1
#endif
@@ -29,10 +29,10 @@
#define kAssemblerPragmaSymStr "#"
#define kAssemblerPragmaSym '#'
-#include <LibCompiler/AE.h>
-#include <LibCompiler/Backend/X64.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/PEF.h>
+#include <CompilerKit/AE.h>
+#include <CompilerKit/detail/X64.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/PEF.h>
#include <algorithm>
#include <cstdlib>
#include <filesystem>
@@ -51,7 +51,7 @@
#define kWhite "\e[0;97m"
#define kYellow "\e[0;33m"
-static char kOutputArch = LibCompiler::kPefArchAMD64;
+static char kOutputArch = CompilerKit::kPefArchAMD64;
constexpr auto kIPAlignement = 0x1U;
@@ -65,10 +65,10 @@ static std::int32_t kRegisterBitWidth = 16U;
static std::vector<i64_byte_t> kAppBytes;
-static LibCompiler::AERecordHeader kCurrentRecord{
- .fName = "", .fKind = LibCompiler::kPefCode, .fSize = 0, .fOffset = 0};
+static CompilerKit::AERecordHeader kCurrentRecord{
+ .fName = "", .fKind = CompilerKit::kPefCode, .fSize = 0, .fOffset = 0};
-static std::vector<LibCompiler::AERecordHeader> kRecords;
+static std::vector<CompilerKit::AERecordHeader> kRecords;
static std::vector<std::string> kDefinedSymbols;
static std::vector<std::string> kUndefinedSymbols;
@@ -77,7 +77,7 @@ static const std::string kUndefinedSymbol = ":UndefinedSymbol:";
// \brief forward decl.
static bool asm_read_attributes(std::string line);
-#include <LibCompiler/Util/AsmUtils.h>
+#include <CompilerKit/utils/AsmUtils.h>
/////////////////////////////////////////////////////////////////////////////////////////
@@ -88,7 +88,7 @@ static bool asm_read_attributes(std::string line);
LIBCOMPILER_MODULE(AssemblerMainAMD64) {
//////////////// CPU OPCODES BEGIN ////////////////
- LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler);
+ CompilerKit::install_signal(SIGSEGV, Detail::drvi_crash_handler);
std::string opcodes_jump[kJumpLimit] = {"ja", "jae", "jb", "jbe", "jc", "je", "jg", "jge",
"jl", "jle", "jna", "jnae", "jnb", "jnbe", "jnc", "jne",
@@ -182,13 +182,13 @@ LIBCOMPILER_MODULE(AssemblerMainAMD64) {
std::string line;
- LibCompiler::AEHeader hdr{0};
+ CompilerKit::AEHeader hdr{0};
memset(hdr.fPad, kAENullType, kAEPad);
hdr.fMagic[0] = kAEMag0;
hdr.fMagic[1] = kAEMag1;
- hdr.fSize = sizeof(LibCompiler::AEHeader);
+ hdr.fSize = sizeof(CompilerKit::AEHeader);
hdr.fArch = kOutputArch;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -197,7 +197,7 @@ LIBCOMPILER_MODULE(AssemblerMainAMD64) {
/////////////////////////////////////////////////////////////////////////////////////////
- LibCompiler::EncoderAMD64 asm64;
+ CompilerKit::EncoderAMD64 asm64;
if (kVerbose) {
kStdOut << "Compiling: " + asm_input << "\n";
@@ -216,7 +216,7 @@ LIBCOMPILER_MODULE(AssemblerMainAMD64) {
} catch (const std::exception& e) {
if (kVerbose) {
std::string what = e.what();
- Detail::print_warning("exit because of: " + what, "LibCompiler");
+ Detail::print_warning("exit because of: " + what, "CompilerKit");
}
try {
@@ -256,7 +256,7 @@ LIBCOMPILER_MODULE(AssemblerMainAMD64) {
for (auto& rec : kRecords) {
if (kVerbose) kStdOut << "AssemblerAMD64: Wrote record " << rec.fName << " to file...\n";
- rec.fFlags |= LibCompiler::kKindRelocationAtRuntime;
+ rec.fFlags |= CompilerKit::kKindRelocationAtRuntime;
rec.fOffset = record_count;
++record_count;
@@ -267,7 +267,7 @@ LIBCOMPILER_MODULE(AssemblerMainAMD64) {
++record_count;
for (auto& sym : kUndefinedSymbols) {
- LibCompiler::AERecordHeader _record_hdr{0};
+ CompilerKit::AERecordHeader _record_hdr{0};
if (kVerbose) kStdOut << "AssemblerAMD64: Wrote symbol " << sym << " to file...\n";
@@ -339,9 +339,9 @@ asm_fail_exit:
static bool asm_read_attributes(std::string line) {
// extern_segment is the opposite of public_segment, it signals to the ld
// that we need this symbol.
- if (LibCompiler::find_word(line, "extern_segment")) {
+ if (CompilerKit::find_word(line, "extern_segment")) {
if (kOutputAsBinary) {
- Detail::print_error("Invalid directive in flat binary mode.", "LibCompiler");
+ Detail::print_error("Invalid directive in flat binary mode.", "CompilerKit");
throw std::runtime_error("invalid_extern_segment_bin");
}
@@ -364,20 +364,20 @@ static bool asm_read_attributes(std::string line) {
if (name.find(kPefCode64) != std::string::npos) {
// data is treated as code.
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
} else if (name.find(kPefData64) != std::string::npos) {
// no code will be executed from here.
- kCurrentRecord.fKind = LibCompiler::kPefData;
+ kCurrentRecord.fKind = CompilerKit::kPefData;
} else if (name.find(kPefZero64) != std::string::npos) {
// this is a bss section.
- kCurrentRecord.fKind = LibCompiler::kPefZero;
+ kCurrentRecord.fKind = CompilerKit::kPefZero;
}
// this is a special case for the start stub.
// we want this so that ld can find it.
if (name == kPefStart) {
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
}
// now we can tell the code size of the previous kCurrentRecord.
@@ -398,9 +398,9 @@ static bool asm_read_attributes(std::string line) {
// public_segment is a special keyword used by AssemblerAMD64 to tell the AE output stage to
// mark this section as a header. it currently supports .code64, .data64 and
// .zero64.
- else if (LibCompiler::find_word(line, "public_segment")) {
+ else if (CompilerKit::find_word(line, "public_segment")) {
if (kOutputAsBinary) {
- Detail::print_error("Invalid directive in flat binary mode.", "LibCompiler");
+ Detail::print_error("Invalid directive in flat binary mode.", "CompilerKit");
throw std::runtime_error("invalid_public_segment_bin");
}
@@ -413,7 +413,7 @@ static bool asm_read_attributes(std::string line) {
}
if (std::find(kDefinedSymbols.begin(), kDefinedSymbols.end(), name) != kDefinedSymbols.end()) {
- Detail::print_error("Symbol already defined.", "LibCompiler");
+ Detail::print_error("Symbol already defined.", "CompilerKit");
throw std::runtime_error("invalid_public_segment_bin");
}
@@ -423,24 +423,24 @@ static bool asm_read_attributes(std::string line) {
// data is treated as code.
name_copy.erase(name_copy.find(".code64"), strlen(".code64"));
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
} else if (name.find(".data64") != std::string::npos) {
// no code will be executed from here.
name_copy.erase(name_copy.find(".data64"), strlen(".data64"));
- kCurrentRecord.fKind = LibCompiler::kPefData;
+ kCurrentRecord.fKind = CompilerKit::kPefData;
} else if (name.find(".zero64") != std::string::npos) {
// this is a bss section.
name_copy.erase(name_copy.find(".zero64"), strlen(".zero64"));
- kCurrentRecord.fKind = LibCompiler::kPefZero;
+ kCurrentRecord.fKind = CompilerKit::kPefZero;
}
// this is a special case for the start stub.
// we want this so that ld can find it.
if (name == kPefStart) {
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
}
while (name_copy.find(" ") != std::string::npos) name_copy.erase(name_copy.find(" "), 1);
@@ -492,12 +492,12 @@ bool is_valid_amd64(std::string str) {
/////////////////////////////////////////////////////////////////////////////////////////
-std::string LibCompiler::EncoderAMD64::CheckLine(std::string line, std::string file) {
+std::string CompilerKit::EncoderAMD64::CheckLine(std::string line, std::string file) {
std::string err_str;
- if (line.empty() || LibCompiler::find_word(line, "extern_segment") ||
- LibCompiler::find_word(line, "public_segment") ||
- LibCompiler::find_word(line, kAssemblerPragmaSymStr) || LibCompiler::find_word(line, ";") ||
+ if (line.empty() || CompilerKit::find_word(line, "extern_segment") ||
+ CompilerKit::find_word(line, "public_segment") ||
+ CompilerKit::find_word(line, kAssemblerPragmaSymStr) || CompilerKit::find_word(line, ";") ||
line[0] == kAssemblerPragmaSym) {
if (line.find(';') != std::string::npos) {
line.erase(line.find(';'));
@@ -548,7 +548,7 @@ std::string LibCompiler::EncoderAMD64::CheckLine(std::string line, std::string f
}
}
for (auto& opcodeAMD64 : kOpcodesAMD64) {
- if (LibCompiler::find_word(line, opcodeAMD64.fName)) {
+ if (CompilerKit::find_word(line, opcodeAMD64.fName)) {
return err_str;
}
}
@@ -558,20 +558,20 @@ std::string LibCompiler::EncoderAMD64::CheckLine(std::string line, std::string f
return err_str;
}
-bool LibCompiler::EncoderAMD64::WriteNumber(const std::size_t& pos, std::string& jump_label) {
+bool CompilerKit::EncoderAMD64::WriteNumber(const std::size_t& pos, std::string& jump_label) {
if (!isdigit(jump_label[pos])) return false;
switch (jump_label[pos + 1]) {
case 'x': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16); !res) {
if (errno != 0) {
- Detail::print_error("invalid hex number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid hex number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_hex");
}
}
- LibCompiler::NumberCast64 num =
- LibCompiler::NumberCast64(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
+ CompilerKit::NumberCast64 num =
+ CompilerKit::NumberCast64(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
for (char& i : num.number) {
if (i == 0) i = 0xFF;
@@ -589,13 +589,13 @@ bool LibCompiler::EncoderAMD64::WriteNumber(const std::size_t& pos, std::string&
case 'b': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2); !res) {
if (errno != 0) {
- Detail::print_error("invalid binary number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid binary number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_bin");
}
}
- LibCompiler::NumberCast64 num =
- LibCompiler::NumberCast64(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
+ CompilerKit::NumberCast64 num =
+ CompilerKit::NumberCast64(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
if (kVerbose) {
kStdOut << "AssemblerAMD64: Found a base 2 number here: " << jump_label.substr(pos) << "\n";
@@ -612,13 +612,13 @@ bool LibCompiler::EncoderAMD64::WriteNumber(const std::size_t& pos, std::string&
case 'o': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7); !res) {
if (errno != 0) {
- Detail::print_error("invalid octal number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid octal number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_octal");
}
}
- LibCompiler::NumberCast64 num =
- LibCompiler::NumberCast64(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
+ CompilerKit::NumberCast64 num =
+ CompilerKit::NumberCast64(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
if (kVerbose) {
kStdOut << "AssemblerAMD64: Found a base 8 number here: " << jump_label.substr(pos) << "\n";
@@ -644,8 +644,8 @@ bool LibCompiler::EncoderAMD64::WriteNumber(const std::size_t& pos, std::string&
}
}
- LibCompiler::NumberCast64 num =
- LibCompiler::NumberCast64(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
+ CompilerKit::NumberCast64 num =
+ CompilerKit::NumberCast64(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
for (char& i : num.number) {
if (i == 0) i = 0xFF;
@@ -660,7 +660,7 @@ bool LibCompiler::EncoderAMD64::WriteNumber(const std::size_t& pos, std::string&
return true;
}
-bool LibCompiler::EncoderAMD64::WriteNumber32(const std::size_t& pos, std::string& jump_label) {
+bool CompilerKit::EncoderAMD64::WriteNumber32(const std::size_t& pos, std::string& jump_label) {
if (!isdigit(jump_label[pos])) return false;
switch (jump_label[pos + 1]) {
@@ -672,7 +672,7 @@ bool LibCompiler::EncoderAMD64::WriteNumber32(const std::size_t& pos, std::strin
return false;
}
- LibCompiler::NumberCast32 num = LibCompiler::NumberCast32(res);
+ CompilerKit::NumberCast32 num = CompilerKit::NumberCast32(res);
for (char& i : num.number) {
if (i == 0) i = 0xFF;
@@ -695,7 +695,7 @@ bool LibCompiler::EncoderAMD64::WriteNumber32(const std::size_t& pos, std::strin
return false;
}
- LibCompiler::NumberCast32 num = LibCompiler::NumberCast32(res);
+ CompilerKit::NumberCast32 num = CompilerKit::NumberCast32(res);
if (kVerbose) {
kStdOut << "AssemblerAMD64: Found a base 2 number here: " << jump_label.substr(pos) << "\n";
@@ -717,7 +717,7 @@ bool LibCompiler::EncoderAMD64::WriteNumber32(const std::size_t& pos, std::strin
return false;
}
- LibCompiler::NumberCast32 num = LibCompiler::NumberCast32(res);
+ CompilerKit::NumberCast32 num = CompilerKit::NumberCast32(res);
if (kVerbose) {
kStdOut << "AssemblerAMD64: Found a base 8 number here: " << jump_label.substr(pos) << "\n";
@@ -743,7 +743,7 @@ bool LibCompiler::EncoderAMD64::WriteNumber32(const std::size_t& pos, std::strin
return false;
}
- LibCompiler::NumberCast32 num = LibCompiler::NumberCast32(res);
+ CompilerKit::NumberCast32 num = CompilerKit::NumberCast32(res);
for (char& i : num.number) {
if (i == 0) i = 0xFF;
@@ -758,20 +758,20 @@ bool LibCompiler::EncoderAMD64::WriteNumber32(const std::size_t& pos, std::strin
return true;
}
-bool LibCompiler::EncoderAMD64::WriteNumber16(const std::size_t& pos, std::string& jump_label) {
+bool CompilerKit::EncoderAMD64::WriteNumber16(const std::size_t& pos, std::string& jump_label) {
if (!isdigit(jump_label[pos])) return false;
switch (jump_label[pos + 1]) {
case 'x': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16); !res) {
if (errno != 0) {
- Detail::print_error("invalid hex number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid hex number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_hex");
}
}
- LibCompiler::NumberCast16 num =
- LibCompiler::NumberCast16(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
+ CompilerKit::NumberCast16 num =
+ CompilerKit::NumberCast16(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
for (char& i : num.number) {
if (i == 0) i = 0xFF;
@@ -789,13 +789,13 @@ bool LibCompiler::EncoderAMD64::WriteNumber16(const std::size_t& pos, std::strin
case 'b': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2); !res) {
if (errno != 0) {
- Detail::print_error("invalid binary number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid binary number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_bin");
}
}
- LibCompiler::NumberCast16 num =
- LibCompiler::NumberCast16(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
+ CompilerKit::NumberCast16 num =
+ CompilerKit::NumberCast16(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
if (kVerbose) {
kStdOut << "AssemblerAMD64: Found a base 2 number here: " << jump_label.substr(pos) << "\n";
@@ -812,13 +812,13 @@ bool LibCompiler::EncoderAMD64::WriteNumber16(const std::size_t& pos, std::strin
case 'o': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7); !res) {
if (errno != 0) {
- Detail::print_error("invalid octal number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid octal number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_octal");
}
}
- LibCompiler::NumberCast16 num =
- LibCompiler::NumberCast16(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
+ CompilerKit::NumberCast16 num =
+ CompilerKit::NumberCast16(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
if (kVerbose) {
kStdOut << "AssemblerAMD64: Found a base 8 number here: " << jump_label.substr(pos) << "\n";
@@ -844,8 +844,8 @@ bool LibCompiler::EncoderAMD64::WriteNumber16(const std::size_t& pos, std::strin
}
}
- LibCompiler::NumberCast16 num =
- LibCompiler::NumberCast16(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
+ CompilerKit::NumberCast16 num =
+ CompilerKit::NumberCast16(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
for (char& i : num.number) {
if (i == 0) i = 0xFF;
@@ -860,20 +860,20 @@ bool LibCompiler::EncoderAMD64::WriteNumber16(const std::size_t& pos, std::strin
return true;
}
-bool LibCompiler::EncoderAMD64::WriteNumber8(const std::size_t& pos, std::string& jump_label) {
+bool CompilerKit::EncoderAMD64::WriteNumber8(const std::size_t& pos, std::string& jump_label) {
if (!isdigit(jump_label[pos])) return false;
switch (jump_label[pos + 1]) {
case 'x': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16); !res) {
if (errno != 0) {
- Detail::print_error("invalid hex number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid hex number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_hex");
}
}
- LibCompiler::NumberCast8 num =
- LibCompiler::NumberCast8(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
+ CompilerKit::NumberCast8 num =
+ CompilerKit::NumberCast8(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
kAppBytes.push_back(num.number);
@@ -887,13 +887,13 @@ bool LibCompiler::EncoderAMD64::WriteNumber8(const std::size_t& pos, std::string
case 'b': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2); !res) {
if (errno != 0) {
- Detail::print_error("invalid binary number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid binary number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_bin");
}
}
- LibCompiler::NumberCast8 num =
- LibCompiler::NumberCast8(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
+ CompilerKit::NumberCast8 num =
+ CompilerKit::NumberCast8(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
if (kVerbose) {
kStdOut << "AssemblerAMD64: Found a base 2 number here: " << jump_label.substr(pos) << "\n";
@@ -906,13 +906,13 @@ bool LibCompiler::EncoderAMD64::WriteNumber8(const std::size_t& pos, std::string
case 'o': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7); !res) {
if (errno != 0) {
- Detail::print_error("invalid octal number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid octal number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_octal");
}
}
- LibCompiler::NumberCast8 num =
- LibCompiler::NumberCast8(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
+ CompilerKit::NumberCast8 num =
+ CompilerKit::NumberCast8(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
if (kVerbose) {
kStdOut << "AssemblerAMD64: Found a base 8 number here: " << jump_label.substr(pos) << "\n";
@@ -934,8 +934,8 @@ bool LibCompiler::EncoderAMD64::WriteNumber8(const std::size_t& pos, std::string
}
}
- LibCompiler::NumberCast8 num =
- LibCompiler::NumberCast8(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
+ CompilerKit::NumberCast8 num =
+ CompilerKit::NumberCast8(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
kAppBytes.push_back(num.number);
@@ -952,11 +952,11 @@ bool LibCompiler::EncoderAMD64::WriteNumber8(const std::size_t& pos, std::string
/////////////////////////////////////////////////////////////////////////////////////////
-bool LibCompiler::EncoderAMD64::WriteLine(std::string line, std::string file) {
- if (LibCompiler::find_word(line, "public_segment ")) return true;
+bool CompilerKit::EncoderAMD64::WriteLine(std::string line, std::string file) {
+ if (CompilerKit::find_word(line, "public_segment ")) return true;
struct RegMapAMD64 {
- LibCompiler::STLString fName;
+ CompilerKit::STLString fName;
i64_byte_t fModRM;
};
@@ -971,7 +971,7 @@ bool LibCompiler::EncoderAMD64::WriteLine(std::string line, std::string file) {
for (auto& opcodeAMD64 : kOpcodesAMD64) {
// strict check here
- if (LibCompiler::find_word(line, opcodeAMD64.fName) &&
+ if (CompilerKit::find_word(line, opcodeAMD64.fName) &&
Detail::algorithm::is_valid_amd64(line)) {
foundInstruction = true;
std::string name(opcodeAMD64.fName);
@@ -984,7 +984,7 @@ bool LibCompiler::EncoderAMD64::WriteLine(std::string line, std::string file) {
uint64_t bits = kRegisterBitWidth;
if (substr.find(",") == std::string::npos) {
- Detail::print_error("Syntax error: missing right operand.", "LibCompiler");
+ Detail::print_error("Syntax error: missing right operand.", "CompilerKit");
throw std::runtime_error("syntax_err");
}
@@ -1048,7 +1048,7 @@ bool LibCompiler::EncoderAMD64::WriteLine(std::string line, std::string file) {
} else if (bits == 16) {
if (hasRBasedRegs) {
Detail::print_error("Invalid combination of operands and registers.",
- "LibCompiler");
+ "CompilerKit");
throw std::runtime_error("comb_op_reg");
} else {
kAppBytes.emplace_back(0x66);
@@ -1086,33 +1086,33 @@ bool LibCompiler::EncoderAMD64::WriteLine(std::string line, std::string file) {
}
if (currentRegList[1].fName[0] == 'r' && currentRegList[0].fName[0] == 'e') {
- Detail::print_error("Invalid combination of operands and registers.", "LibCompiler");
+ Detail::print_error("Invalid combination of operands and registers.", "CompilerKit");
throw std::runtime_error("comb_op_reg");
}
if (currentRegList[0].fName[0] == 'r' && currentRegList[1].fName[0] == 'e') {
- Detail::print_error("Invalid combination of operands and registers.", "LibCompiler");
+ Detail::print_error("Invalid combination of operands and registers.", "CompilerKit");
throw std::runtime_error("comb_op_reg");
}
if (bits == 16) {
if (currentRegList[0].fName[0] == 'r' || currentRegList[0].fName[0] == 'e') {
- Detail::print_error("Invalid combination of operands and registers.", "LibCompiler");
+ Detail::print_error("Invalid combination of operands and registers.", "CompilerKit");
throw std::runtime_error("comb_op_reg");
}
if (currentRegList[1].fName[0] == 'r' || currentRegList[1].fName[0] == 'e') {
- Detail::print_error("Invalid combination of operands and registers.", "LibCompiler");
+ Detail::print_error("Invalid combination of operands and registers.", "CompilerKit");
throw std::runtime_error("comb_op_reg");
}
} else {
if (currentRegList[0].fName[0] != 'r' || currentRegList[0].fName[0] == 'e') {
- Detail::print_error("Invalid combination of operands and registers.", "LibCompiler");
+ Detail::print_error("Invalid combination of operands and registers.", "CompilerKit");
throw std::runtime_error("comb_op_reg");
}
if (currentRegList[1].fName[0] != 'r' || currentRegList[1].fName[0] == 'e') {
- Detail::print_error("Invalid combination of operands and registers.", "LibCompiler");
+ Detail::print_error("Invalid combination of operands and registers.", "CompilerKit");
throw std::runtime_error("comb_op_reg");
}
}
diff --git a/dev/LibCompiler/src/Backend/AssemblerARM64.cc b/dev/CompilerKit/src/Backend/AssemblerARM64.cc
index a1cc6dc..d290e24 100644
--- a/dev/LibCompiler/src/Backend/AssemblerARM64.cc
+++ b/dev/CompilerKit/src/Backend/AssemblerARM64.cc
@@ -19,13 +19,13 @@
#define __ASM_NEED_ARM64__ 1
#endif
-#include <LibCompiler/AE.h>
-#include <LibCompiler/Backend/Aarch64.h>
-#include <LibCompiler/ErrorID.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/PEF.h>
-#include <LibCompiler/Util/AsmUtils.h>
-#include <LibCompiler/Version.h>
+#include <CompilerKit/AE.h>
+#include <CompilerKit/detail/Aarch64.h>
+#include <CompilerKit/ErrorID.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/PEF.h>
+#include <CompilerKit/utils/AsmUtils.h>
+#include <CompilerKit/Version.h>
#include <algorithm>
#include <filesystem>
#include <fstream>
@@ -45,7 +45,7 @@
constexpr auto cPowerIPAlignment = 0x1U;
-static Char kOutputArch = LibCompiler::kPefArchARM64;
+static Char kOutputArch = CompilerKit::kPefArchARM64;
static std::size_t kCounter = 1UL;
@@ -54,10 +54,10 @@ static std::vector<std::pair<std::string, std::uintptr_t>> kOriginLabel;
static std::vector<uint8_t> kBytes;
-static LibCompiler::AERecordHeader kCurrentRecord{
- .fName = "", .fKind = LibCompiler::kPefCode, .fSize = 0, .fOffset = 0};
+static CompilerKit::AERecordHeader kCurrentRecord{
+ .fName = "", .fKind = CompilerKit::kPefCode, .fSize = 0, .fOffset = 0};
-static std::vector<LibCompiler::AERecordHeader> kRecords;
+static std::vector<CompilerKit::AERecordHeader> kRecords;
static std::vector<std::string> kUndefinedSymbols;
static const std::string kUndefinedSymbol = ":UndefinedSymbol:";
@@ -73,7 +73,7 @@ static bool asm_read_attributes(std::string line);
/////////////////////////////////////////////////////////////////////////////////////////
LIBCOMPILER_MODULE(AssemblerMainARM64) {
- LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler);
+ CompilerKit::install_signal(SIGSEGV, Detail::drvi_crash_handler);
for (size_t i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
@@ -129,13 +129,13 @@ LIBCOMPILER_MODULE(AssemblerMainARM64) {
std::string line;
- LibCompiler::AEHeader hdr{0};
+ CompilerKit::AEHeader hdr{0};
memset(hdr.fPad, kAENullType, kAEPad);
hdr.fMagic[0] = kAEMag0;
hdr.fMagic[1] = kAEMag1;
- hdr.fSize = sizeof(LibCompiler::AEHeader);
+ hdr.fSize = sizeof(CompilerKit::AEHeader);
hdr.fArch = kOutputArch;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -144,7 +144,7 @@ LIBCOMPILER_MODULE(AssemblerMainARM64) {
/////////////////////////////////////////////////////////////////////////////////////////
- LibCompiler::EncoderARM64 asm64;
+ CompilerKit::EncoderARM64 asm64;
while (std::getline(file_ptr, line)) {
if (auto ln = asm64.CheckLine(line, argv[i]); !ln.empty()) {
@@ -158,7 +158,7 @@ LIBCOMPILER_MODULE(AssemblerMainARM64) {
} catch (const std::exception& e) {
if (kVerbose) {
std::string what = e.what();
- Detail::print_warning("exit because of: " + what, "LibCompiler");
+ Detail::print_warning("exit because of: " + what, "CompilerKit");
}
std::filesystem::remove(object_output);
@@ -192,7 +192,7 @@ LIBCOMPILER_MODULE(AssemblerMainARM64) {
std::size_t record_count = 0UL;
for (auto& record_hdr : kRecords) {
- record_hdr.fFlags |= LibCompiler::kKindRelocationAtRuntime;
+ record_hdr.fFlags |= CompilerKit::kKindRelocationAtRuntime;
record_hdr.fOffset = record_count;
++record_count;
@@ -205,7 +205,7 @@ LIBCOMPILER_MODULE(AssemblerMainARM64) {
++record_count;
for (auto& sym : kUndefinedSymbols) {
- LibCompiler::AERecordHeader undefined_sym{0};
+ CompilerKit::AERecordHeader undefined_sym{0};
if (kVerbose) kStdOut << "AssemblerARM64: Wrote symbol " << sym << " to file...\n";
@@ -271,16 +271,16 @@ asm_fail_exit:
static bool asm_read_attributes(std::string line) {
// extern_segment is the opposite of public_segment, it signals to the li
// that we need this symbol.
- if (LibCompiler::find_word(line, "extern_segment")) {
+ if (CompilerKit::find_word(line, "extern_segment")) {
if (kOutputAsBinary) {
- Detail::print_error("Invalid extern_segment directive in flat binary mode.", "LibCompiler");
+ Detail::print_error("Invalid extern_segment directive in flat binary mode.", "CompilerKit");
throw std::runtime_error("invalid_extern_segment_bin");
}
auto name = line.substr(line.find("extern_segment") + strlen("extern_segment") + 1);
if (name.size() == 0) {
- Detail::print_error("Invalid extern_segment", "LibCompiler");
+ Detail::print_error("Invalid extern_segment", "CompilerKit");
throw std::runtime_error("invalid_extern_segment");
}
@@ -296,20 +296,20 @@ static bool asm_read_attributes(std::string line) {
if (name.find(".code64") != std::string::npos) {
// data is treated as code.
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
} else if (name.find(".data64") != std::string::npos) {
// no code will be executed from here.
- kCurrentRecord.fKind = LibCompiler::kPefData;
+ kCurrentRecord.fKind = CompilerKit::kPefData;
} else if (name.find(".zero64") != std::string::npos) {
// this is a bss section.
- kCurrentRecord.fKind = LibCompiler::kPefZero;
+ kCurrentRecord.fKind = CompilerKit::kPefZero;
}
// this is a special case for the start stub.
// we want this so that li can find it.
if (name == kPefStart) {
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
}
// now we can tell the code size of the previous kCurrentRecord.
@@ -330,9 +330,9 @@ static bool asm_read_attributes(std::string line) {
// public_segment is a special keyword used by Assembler to tell the AE output stage to
// mark this section as a header. it currently supports .code64, .data64.,
// .zero64
- else if (LibCompiler::find_word(line, "public_segment")) {
+ else if (CompilerKit::find_word(line, "public_segment")) {
if (kOutputAsBinary) {
- Detail::print_error("Invalid public_segment directive in flat binary mode.", "LibCompiler");
+ Detail::print_error("Invalid public_segment directive in flat binary mode.", "CompilerKit");
throw std::runtime_error("invalid_public_segment_bin");
}
@@ -348,24 +348,24 @@ static bool asm_read_attributes(std::string line) {
// data is treated as code.
name_copy.erase(name_copy.find(".code64"), strlen(".code64"));
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
} else if (name.find(".data64") != std::string::npos) {
// no code will be executed from here.
name_copy.erase(name_copy.find(".data64"), strlen(".data64"));
- kCurrentRecord.fKind = LibCompiler::kPefData;
+ kCurrentRecord.fKind = CompilerKit::kPefData;
} else if (name.find(".zero64") != std::string::npos) {
// this is a bss section.
name_copy.erase(name_copy.find(".zero64"), strlen(".zero64"));
- kCurrentRecord.fKind = LibCompiler::kPefZero;
+ kCurrentRecord.fKind = CompilerKit::kPefZero;
}
// this is a special case for the start stub.
// we want this so that li can find it.
if (name == kPefStart) {
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
}
while (name_copy.find(" ") != std::string::npos) name_copy.erase(name_copy.find(" "), 1);
@@ -413,12 +413,12 @@ bool is_valid_arm64(std::string str) {
/////////////////////////////////////////////////////////////////////////////////////////
-std::string LibCompiler::EncoderARM64::CheckLine(std::string line, std::string file) {
+std::string CompilerKit::EncoderARM64::CheckLine(std::string line, std::string file) {
std::string err_str;
- if (line.empty() || LibCompiler::find_word(line, "extern_segment") ||
- LibCompiler::find_word(line, "public_segment") || line.find('#') != std::string::npos ||
- LibCompiler::find_word(line, ";")) {
+ if (line.empty() || CompilerKit::find_word(line, "extern_segment") ||
+ CompilerKit::find_word(line, "public_segment") || line.find('#') != std::string::npos ||
+ CompilerKit::find_word(line, ";")) {
if (line.find('#') != std::string::npos) {
line.erase(line.find('#'));
} else if (line.find(';') != std::string::npos) {
@@ -480,19 +480,19 @@ std::string LibCompiler::EncoderARM64::CheckLine(std::string line, std::string f
return err_str;
}
-bool LibCompiler::EncoderARM64::WriteNumber(const std::size_t& pos, std::string& jump_label) {
+bool CompilerKit::EncoderARM64::WriteNumber(const std::size_t& pos, std::string& jump_label) {
if (!isdigit(jump_label[pos])) return false;
switch (jump_label[pos + 1]) {
case 'x': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16); !res) {
if (errno != 0) {
- Detail::print_error("invalid hex number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid hex number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_hex");
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
for (char& i : num.number) {
kBytes.push_back(i);
@@ -508,12 +508,12 @@ bool LibCompiler::EncoderARM64::WriteNumber(const std::size_t& pos, std::string&
case 'b': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2); !res) {
if (errno != 0) {
- Detail::print_error("invalid binary number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid binary number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_bin");
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
if (kVerbose) {
kStdOut << "AssemblerARM64: found a base 2 number here: " << jump_label.substr(pos) << "\n";
@@ -528,12 +528,12 @@ bool LibCompiler::EncoderARM64::WriteNumber(const std::size_t& pos, std::string&
case 'o': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7); !res) {
if (errno != 0) {
- Detail::print_error("invalid octal number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid octal number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_octal");
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
if (kVerbose) {
kStdOut << "AssemblerARM64: found a base 8 number here: " << jump_label.substr(pos) << "\n";
@@ -557,7 +557,7 @@ bool LibCompiler::EncoderARM64::WriteNumber(const std::size_t& pos, std::string&
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
for (char& i : num.number) {
kBytes.push_back(i);
@@ -576,8 +576,8 @@ bool LibCompiler::EncoderARM64::WriteNumber(const std::size_t& pos, std::string&
/////////////////////////////////////////////////////////////////////////////////////////
-bool LibCompiler::EncoderARM64::WriteLine(std::string line, std::string file) {
- if (LibCompiler::find_word(line, "public_segment")) return false;
+bool CompilerKit::EncoderARM64::WriteLine(std::string line, std::string file) {
+ if (CompilerKit::find_word(line, "public_segment")) return false;
if (!Detail::algorithm::is_valid_arm64(line)) return false;
diff --git a/dev/LibCompiler/src/Backend/AssemblerPowerPC.cc b/dev/CompilerKit/src/Backend/AssemblerPowerPC.cc
index b979f64..a04a52b 100644
--- a/dev/LibCompiler/src/Backend/AssemblerPowerPC.cc
+++ b/dev/CompilerKit/src/Backend/AssemblerPowerPC.cc
@@ -19,13 +19,13 @@
#define __ASM_NEED_PPC__ 1
#endif
-#include <LibCompiler/AE.h>
-#include <LibCompiler/Backend/PowerPC.h>
-#include <LibCompiler/ErrorID.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/PEF.h>
-#include <LibCompiler/Util/AsmUtils.h>
-#include <LibCompiler/Version.h>
+#include <CompilerKit/AE.h>
+#include <CompilerKit/detail/PowerPC.h>
+#include <CompilerKit/ErrorID.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/PEF.h>
+#include <CompilerKit/utils/AsmUtils.h>
+#include <CompilerKit/Version.h>
#include <algorithm>
#include <filesystem>
#include <fstream>
@@ -45,7 +45,7 @@
constexpr auto cPowerIPAlignment = 0x4U;
-static Char kOutputArch = LibCompiler::kPefArchPowerPC;
+static Char kOutputArch = CompilerKit::kPefArchPowerPC;
static std::size_t kCounter = 1UL;
@@ -54,10 +54,10 @@ static std::vector<std::pair<std::string, std::uintptr_t>> kOriginLabel;
static std::vector<uint8_t> kBytes;
-static LibCompiler::AERecordHeader kCurrentRecord{
- .fName = "", .fKind = LibCompiler::kPefCode, .fSize = 0, .fOffset = 0};
+static CompilerKit::AERecordHeader kCurrentRecord{
+ .fName = "", .fKind = CompilerKit::kPefCode, .fSize = 0, .fOffset = 0};
-static std::vector<LibCompiler::AERecordHeader> kRecords;
+static std::vector<CompilerKit::AERecordHeader> kRecords;
static std::vector<std::string> kUndefinedSymbols;
static const std::string kUndefinedSymbol = ":UndefinedSymbol:";
@@ -73,7 +73,7 @@ static bool asm_read_attributes(std::string line);
/////////////////////////////////////////////////////////////////////////////////////////
LIBCOMPILER_MODULE(AssemblerMainPower64) {
- LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler);
+ CompilerKit::install_signal(SIGSEGV, Detail::drvi_crash_handler);
for (size_t i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
@@ -129,13 +129,13 @@ LIBCOMPILER_MODULE(AssemblerMainPower64) {
std::string line;
- LibCompiler::AEHeader hdr{0};
+ CompilerKit::AEHeader hdr{0};
memset(hdr.fPad, kAENullType, kAEPad);
hdr.fMagic[0] = kAEMag0;
hdr.fMagic[1] = kAEMag1;
- hdr.fSize = sizeof(LibCompiler::AEHeader);
+ hdr.fSize = sizeof(CompilerKit::AEHeader);
hdr.fArch = kOutputArch;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -144,7 +144,7 @@ LIBCOMPILER_MODULE(AssemblerMainPower64) {
/////////////////////////////////////////////////////////////////////////////////////////
- LibCompiler::EncoderPowerPC asm64;
+ CompilerKit::EncoderPowerPC asm64;
while (std::getline(file_ptr, line)) {
if (auto ln = asm64.CheckLine(line, argv[i]); !ln.empty()) {
@@ -158,7 +158,7 @@ LIBCOMPILER_MODULE(AssemblerMainPower64) {
} catch (const std::exception& e) {
if (kVerbose) {
std::string what = e.what();
- Detail::print_warning("exit because of: " + what, "LibCompiler");
+ Detail::print_warning("exit because of: " + what, "CompilerKit");
}
std::filesystem::remove(object_output);
@@ -192,7 +192,7 @@ LIBCOMPILER_MODULE(AssemblerMainPower64) {
std::size_t record_count = 0UL;
for (auto& record_hdr : kRecords) {
- record_hdr.fFlags |= LibCompiler::kKindRelocationAtRuntime;
+ record_hdr.fFlags |= CompilerKit::kKindRelocationAtRuntime;
record_hdr.fOffset = record_count;
++record_count;
@@ -205,7 +205,7 @@ LIBCOMPILER_MODULE(AssemblerMainPower64) {
++record_count;
for (auto& sym : kUndefinedSymbols) {
- LibCompiler::AERecordHeader undefined_sym{0};
+ CompilerKit::AERecordHeader undefined_sym{0};
if (kVerbose) kStdOut << "AssemblerPower: Wrote symbol " << sym << " to file...\n";
@@ -271,16 +271,16 @@ asm_fail_exit:
static bool asm_read_attributes(std::string line) {
// extern_segment is the opposite of public_segment, it signals to the li
// that we need this symbol.
- if (LibCompiler::find_word(line, "extern_segment")) {
+ if (CompilerKit::find_word(line, "extern_segment")) {
if (kOutputAsBinary) {
- Detail::print_error("Invalid extern_segment directive in flat binary mode.", "LibCompiler");
+ Detail::print_error("Invalid extern_segment directive in flat binary mode.", "CompilerKit");
throw std::runtime_error("invalid_extern_segment_bin");
}
auto name = line.substr(line.find("extern_segment") + strlen("extern_segment") + 1);
if (name.size() == 0) {
- Detail::print_error("Invalid extern_segment", "LibCompiler");
+ Detail::print_error("Invalid extern_segment", "CompilerKit");
throw std::runtime_error("invalid_extern_segment");
}
@@ -296,20 +296,20 @@ static bool asm_read_attributes(std::string line) {
if (name.find(".code64") != std::string::npos) {
// data is treated as code.
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
} else if (name.find(".data64") != std::string::npos) {
// no code will be executed from here.
- kCurrentRecord.fKind = LibCompiler::kPefData;
+ kCurrentRecord.fKind = CompilerKit::kPefData;
} else if (name.find(".zero64") != std::string::npos) {
// this is a bss section.
- kCurrentRecord.fKind = LibCompiler::kPefZero;
+ kCurrentRecord.fKind = CompilerKit::kPefZero;
}
// this is a special case for the start stub.
// we want this so that li can find it.
if (name == kPefStart) {
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
}
// now we can tell the code size of the previous kCurrentRecord.
@@ -330,9 +330,9 @@ static bool asm_read_attributes(std::string line) {
// public_segment is a special keyword used by AssemblerPower to tell the AE output stage to
// mark this section as a header. it currently supports .code64, .data64.,
// .zero64
- else if (LibCompiler::find_word(line, "public_segment")) {
+ else if (CompilerKit::find_word(line, "public_segment")) {
if (kOutputAsBinary) {
- Detail::print_error("Invalid public_segment directive in flat binary mode.", "LibCompiler");
+ Detail::print_error("Invalid public_segment directive in flat binary mode.", "CompilerKit");
throw std::runtime_error("invalid_public_segment_bin");
}
@@ -348,24 +348,24 @@ static bool asm_read_attributes(std::string line) {
// data is treated as code.
name_copy.erase(name_copy.find(".code64"), strlen(".code64"));
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
} else if (name.find(".data64") != std::string::npos) {
// no code will be executed from here.
name_copy.erase(name_copy.find(".data64"), strlen(".data64"));
- kCurrentRecord.fKind = LibCompiler::kPefData;
+ kCurrentRecord.fKind = CompilerKit::kPefData;
} else if (name.find(".zero64") != std::string::npos) {
// this is a bss section.
name_copy.erase(name_copy.find(".zero64"), strlen(".zero64"));
- kCurrentRecord.fKind = LibCompiler::kPefZero;
+ kCurrentRecord.fKind = CompilerKit::kPefZero;
}
// this is a special case for the start stub.
// we want this so that li can find it.
if (name == kPefStart) {
- kCurrentRecord.fKind = LibCompiler::kPefCode;
+ kCurrentRecord.fKind = CompilerKit::kPefCode;
}
while (name_copy.find(" ") != std::string::npos) name_copy.erase(name_copy.find(" "), 1);
@@ -413,12 +413,12 @@ bool is_valid_power64(std::string str) {
/////////////////////////////////////////////////////////////////////////////////////////
-std::string LibCompiler::EncoderPowerPC::CheckLine(std::string line, std::string file) {
+std::string CompilerKit::EncoderPowerPC::CheckLine(std::string line, std::string file) {
std::string err_str;
- if (line.empty() || LibCompiler::find_word(line, "extern_segment") ||
- LibCompiler::find_word(line, "public_segment") || line.find('#') != std::string::npos ||
- LibCompiler::find_word(line, ";")) {
+ if (line.empty() || CompilerKit::find_word(line, "extern_segment") ||
+ CompilerKit::find_word(line, "public_segment") || line.find('#') != std::string::npos ||
+ CompilerKit::find_word(line, ";")) {
if (line.find('#') != std::string::npos) {
line.erase(line.find('#'));
} else if (line.find(';') != std::string::npos) {
@@ -484,7 +484,7 @@ std::string LibCompiler::EncoderPowerPC::CheckLine(std::string line, std::string
std::vector<std::string> filter_inst = {"blr", "bl", "sc"};
for (auto& opcode_risc : kOpcodesPowerPC) {
- if (LibCompiler::find_word(line, opcode_risc.name)) {
+ if (CompilerKit::find_word(line, opcode_risc.name)) {
for (auto& op : operands_inst) {
// if only the instruction was found.
if (line == op) {
@@ -498,7 +498,7 @@ std::string LibCompiler::EncoderPowerPC::CheckLine(std::string line, std::string
// if it is like that -> addr1, 0x0
if (auto it = std::find(filter_inst.begin(), filter_inst.end(), opcode_risc.name);
it == filter_inst.cend()) {
- if (LibCompiler::find_word(line, opcode_risc.name)) {
+ if (CompilerKit::find_word(line, opcode_risc.name)) {
if (!isspace(line[line.find(opcode_risc.name) + strlen(opcode_risc.name)])) {
err_str += "\nMissing space between ";
err_str += opcode_risc.name;
@@ -517,19 +517,19 @@ std::string LibCompiler::EncoderPowerPC::CheckLine(std::string line, std::string
return err_str;
}
-bool LibCompiler::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::string& jump_label) {
+bool CompilerKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::string& jump_label) {
if (!isdigit(jump_label[pos])) return false;
switch (jump_label[pos + 1]) {
case 'x': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16); !res) {
if (errno != 0) {
- Detail::print_error("invalid hex number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid hex number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_hex");
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16));
for (char& i : num.number) {
kBytes.push_back(i);
@@ -545,12 +545,12 @@ bool LibCompiler::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::strin
case 'b': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2); !res) {
if (errno != 0) {
- Detail::print_error("invalid binary number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid binary number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_bin");
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2));
if (kVerbose) {
kStdOut << "AssemblerPower: found a base 2 number here: " << jump_label.substr(pos) << "\n";
@@ -565,12 +565,12 @@ bool LibCompiler::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::strin
case 'o': {
if (auto res = strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7); !res) {
if (errno != 0) {
- Detail::print_error("invalid octal number: " + jump_label, "LibCompiler");
+ Detail::print_error("invalid octal number: " + jump_label, "CompilerKit");
throw std::runtime_error("invalid_octal");
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7));
if (kVerbose) {
kStdOut << "AssemblerPower: found a base 8 number here: " << jump_label.substr(pos) << "\n";
@@ -594,7 +594,7 @@ bool LibCompiler::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::strin
}
}
- LibCompiler::NumberCast64 num(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
+ CompilerKit::NumberCast64 num(strtol(jump_label.substr(pos).c_str(), nullptr, 10));
for (char& i : num.number) {
kBytes.push_back(i);
@@ -613,13 +613,13 @@ bool LibCompiler::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::strin
/////////////////////////////////////////////////////////////////////////////////////////
-bool LibCompiler::EncoderPowerPC::WriteLine(std::string line, std::string file) {
- if (LibCompiler::find_word(line, "public_segment")) return false;
+bool CompilerKit::EncoderPowerPC::WriteLine(std::string line, std::string file) {
+ if (CompilerKit::find_word(line, "public_segment")) return false;
if (!Detail::algorithm::is_valid_power64(line)) return false;
for (auto& opcode_risc : kOpcodesPowerPC) {
// strict check here
- if (LibCompiler::find_word(line, opcode_risc.name)) {
+ if (CompilerKit::find_word(line, opcode_risc.name)) {
std::string name(opcode_risc.name);
std::string jump_label, cpy_jump_label;
std::vector<size_t> found_registers_index;
diff --git a/dev/LibCompiler/src/BasicString.cc b/dev/CompilerKit/src/BasicString.cc
index c4cb763..ca257c0 100644
--- a/dev/LibCompiler/src/BasicString.cc
+++ b/dev/CompilerKit/src/BasicString.cc
@@ -1,7 +1,7 @@
/*
* ========================================================
*
- * LibCompiler
+ * CompilerKit
* Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
*
* ========================================================
@@ -18,9 +18,9 @@
*
*/
-#include <LibCompiler/BasicString.h>
+#include <CompilerKit/BasicString.h>
-namespace LibCompiler {
+namespace CompilerKit {
Char* BasicString::Data() {
return m_Data;
}
@@ -204,4 +204,4 @@ BasicString& BasicString::operator+=(const BasicString& rhs) {
return *this;
}
-} // namespace LibCompiler
+} // namespace CompilerKit
diff --git a/dev/LibCompiler/src/CodeGen.cc b/dev/CompilerKit/src/CodeGen.cc
index a6fff71..e59001d 100644
--- a/dev/LibCompiler/src/CodeGen.cc
+++ b/dev/CompilerKit/src/CodeGen.cc
@@ -4,21 +4,20 @@
------------------------------------------- */
-#include <LibCompiler/CodeGen.h>
-#include <LibCompiler/ErrorID.h>
+#include <CompilerKit/CodeGen.h>
+#include <CompilerKit/ErrorID.h>
/**
* @file CodeGen.cc
- * @author amlal (amlal@nekernel.org)
- * @brief Assembler Kit (Code generation kit)
- * @version 0.1
- * @date 2024-01-27
+ * @author Amlal El Mahrouss (amlal@nekernel.org)
+ * @brief CodeGen API of NeCTI
+ * @version 0.0.2
*
* @copyright Copyright (c) 2024-2025 Amlal El Mahrouss
*
*/
-namespace LibCompiler {
+namespace CompilerKit {
///! @brief Compile for specific format (ELF, PEF, ZBIN)
Int32 AssemblyFactory::Compile(STLString sourceFile, const Int32& arch) noexcept {
if (sourceFile.length() < 1) return LIBCOMPILER_UNIMPLEMENTED;
@@ -50,4 +49,4 @@ AssemblyInterface* AssemblyFactory::Unmount() noexcept {
return mount_prev;
}
-} // namespace LibCompiler
+} // namespace CompilerKit
diff --git a/dev/LibCompiler/src/Frontend.cc b/dev/CompilerKit/src/Frontend.cc
index 2ed5309..37b36f7 100644
--- a/dev/LibCompiler/src/Frontend.cc
+++ b/dev/CompilerKit/src/Frontend.cc
@@ -4,9 +4,9 @@
------------------------------------------- */
-#include <LibCompiler/Frontend.h>
+#include <CompilerKit/Frontend.h>
-namespace LibCompiler {
+namespace CompilerKit {
/// find the perfect matching word in a haystack.
/// \param haystack base string
/// \param needle the string we search for.
@@ -48,4 +48,4 @@ SizeType find_word_range(STLString haystack, STLString needle) noexcept {
return STLString::npos;
}
-} // namespace LibCompiler \ No newline at end of file
+} // namespace CompilerKit \ No newline at end of file
diff --git a/dev/LibCompiler/src/Frontend/CCompiler64x0.cc b/dev/CompilerKit/src/Frontend/CCompiler64x0.cc
index 295de89..ae2939b 100644
--- a/dev/LibCompiler/src/Frontend/CCompiler64x0.cc
+++ b/dev/CompilerKit/src/Frontend/CCompiler64x0.cc
@@ -10,10 +10,10 @@
/// BUGS: 0
/// TODO: none
-#include <LibCompiler/Backend/64x0.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/UUID.h>
-#include <LibCompiler/Util/CompilerUtils.h>
+#include <CompilerKit/detail/64x0.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/UUID.h>
+#include <CompilerKit/utils/CompilerUtils.h>
#include <cstdio>
#include <fstream>
#include <iostream>
@@ -24,7 +24,7 @@
#include <vector>
/* C driver */
-/* This is part of the LibCompiler. */
+/* This is part of the CompilerKit. */
/* (c) Amlal El Mahrouss */
/// @author EL Mahrouss Amlal (amlel)
@@ -75,10 +75,10 @@ struct CompilerStructMap final {
};
struct CompilerState final {
- std::vector<LibCompiler::SyntaxLeafList> fSyntaxTreeList;
+ std::vector<CompilerKit::SyntaxLeafList> fSyntaxTreeList;
std::vector<CompilerRegisterMap> kStackFrame;
std::vector<CompilerStructMap> kStructMap;
- LibCompiler::SyntaxLeafList* fSyntaxTree{nullptr};
+ CompilerKit::SyntaxLeafList* fSyntaxTree{nullptr};
std::unique_ptr<std::ofstream> fOutputAssembly;
std::string fLastFile;
std::string fLastError;
@@ -125,7 +125,7 @@ static std::string kRegisterPrefix = kAsmRegisterPrefix;
/////////////////////////////////////////
static std::vector<std::string> kFileList;
-static LibCompiler::AssemblyFactory kFactory;
+static CompilerKit::AssemblyFactory kFactory;
static bool kInStruct = false;
static bool kOnWhileLoop = false;
static bool kOnForLoop = false;
@@ -134,7 +134,7 @@ static bool kIfFound = false;
static size_t kBracesCount = 0UL;
/* @brief C compiler backend for C */
-class CompilerFrontend64x0 final : public LibCompiler::CompilerFrontendInterface {
+class CompilerFrontend64x0 final : public CompilerKit::CompilerFrontendInterface {
public:
explicit CompilerFrontend64x0() = default;
~CompilerFrontend64x0() override = default;
@@ -142,7 +142,7 @@ class CompilerFrontend64x0 final : public LibCompiler::CompilerFrontendInterface
LIBCOMPILER_COPY_DEFAULT(CompilerFrontend64x0);
std::string Check(const char* text, const char* file);
- LibCompiler::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) override;
+ CompilerKit::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) override;
const char* Language() override { return "64k C"; }
};
@@ -182,7 +182,7 @@ union double_cast final {
/////////////////////////////////////////////////////////////////////////////////////////
-LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontend64x0::Compile(std::string text_, std::string file) {
+CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontend64x0::Compile(std::string text_, std::string file) {
std::string text = text_;
bool typeFound = false;
@@ -198,7 +198,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontend64x0::Compile(std::strin
// start parsing
for (size_t text_index = 0; text_index < text.size(); ++text_index) {
- auto syntaxLeaf = LibCompiler::SyntaxLeafList::SyntaxLeaf();
+ auto syntaxLeaf = CompilerKit::SyntaxLeafList::SyntaxLeaf();
auto gen = uuids::uuid_random_generator{generator};
uuids::uuid out = gen();
@@ -614,7 +614,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontend64x0::Compile(std::strin
syntaxLeaf.fUserValue.clear();
}
- auto syntaxLeaf = LibCompiler::SyntaxLeafList::SyntaxLeaf();
+ auto syntaxLeaf = CompilerKit::SyntaxLeafList::SyntaxLeaf();
syntaxLeaf.fUserValue = "\n";
kState.fSyntaxTree->fLeafList.push_back(syntaxLeaf);
@@ -824,7 +824,7 @@ cc_next:
// extern does not declare anything, it extern_segments a variable.
// so that's why it's not declare upper.
- if (LibCompiler::find_word(ln, "extern")) {
+ if (CompilerKit::find_word(ln, "extern")) {
auto substr = ln.substr(ln.find("extern") + strlen("extern"));
kCompilerVariables.push_back({.fValue = substr});
}
@@ -881,7 +881,7 @@ cc_next:
skip_braces_check:
for (auto& key : kCompilerTypes) {
- if (LibCompiler::find_word(ln, key.fName)) {
+ if (CompilerKit::find_word(ln, key.fName)) {
if (isdigit(ln[ln.find(key.fName) + key.fName.size() + 1])) {
err_str += "\nNumber cannot be set for ";
err_str += key.fName;
@@ -954,9 +954,9 @@ skip_braces_check:
}
if (ln.find('(') != std::string::npos) {
- if (ln.find(';') == std::string::npos && !LibCompiler::find_word(ln, "|") &&
- !LibCompiler::find_word(ln, "||") && !LibCompiler::find_word(ln, "&") &&
- !LibCompiler::find_word(ln, "&&") && !LibCompiler::find_word(ln, "~")) {
+ if (ln.find(';') == std::string::npos && !CompilerKit::find_word(ln, "|") &&
+ !CompilerKit::find_word(ln, "||") && !CompilerKit::find_word(ln, "&") &&
+ !CompilerKit::find_word(ln, "&&") && !CompilerKit::find_word(ln, "~")) {
bool found_func = false;
size_t i = ln.find('(');
std::vector<char> opens;
@@ -1051,7 +1051,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
LIBCOMPILER_COPY_DEFAULT(AssemblyCCInterface);
- UInt32 Arch() noexcept override { return LibCompiler::AssemblyFactory::kArch64x0; }
+ UInt32 Arch() noexcept override { return CompilerKit::AssemblyFactory::kArch64x0; }
Int32 CompileToFormat(std::string src, Int32 arch) override {
if (kCompilerFrontend == nullptr) return 1;
@@ -1075,13 +1075,13 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
kState.fOutputAssembly = std::make_unique<std::ofstream>(dest);
- auto fmt = LibCompiler::current_date();
+ auto fmt = CompilerKit::current_date();
(*kState.fOutputAssembly) << "# Path: " << src_file << "\n";
(*kState.fOutputAssembly) << "# Language: 64x0 Assembly (Generated from ANSI C)\n";
(*kState.fOutputAssembly) << "# Date: " << fmt << "\n\n";
- LibCompiler::SyntaxLeafList syntax;
+ CompilerKit::SyntaxLeafList syntax;
kState.fSyntaxTreeList.push_back(syntax);
kState.fSyntaxTree = &kState.fSyntaxTreeList[kState.fSyntaxTreeList.size() - 1];
@@ -1108,7 +1108,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
std::vector<std::string> access_keywords = {"->", "."};
for (auto& access_ident : access_keywords) {
- if (LibCompiler::find_word(leaf.fUserValue, access_ident)) {
+ if (CompilerKit::find_word(leaf.fUserValue, access_ident)) {
for (auto& struc : kState.kStructMap) {
/// TODO:
}
@@ -1116,7 +1116,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
}
for (auto& keyword : keywords) {
- if (LibCompiler::find_word(leaf.fUserValue, keyword)) {
+ if (CompilerKit::find_word(leaf.fUserValue, keyword)) {
std::size_t cnt = 0UL;
for (auto& reg : kState.kStackFrame) {
@@ -1140,7 +1140,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
}
}
- if (LibCompiler::find_word(leaf.fUserValue, needle)) {
+ if (CompilerKit::find_word(leaf.fUserValue, needle)) {
if (leaf.fUserValue.find("extern_segment " + needle) != std::string::npos) {
std::string range = "extern_segment " + needle;
leaf.fUserValue.replace(leaf.fUserValue.find("extern_segment " + needle),
@@ -1184,7 +1184,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
/////////////////////////////////////////////////////////////////////////////////////////
-#include <LibCompiler/Version.h>
+#include <CompilerKit/Version.h>
#define kPrintF printf
#define kSplashCxx() kPrintF(kWhite "NE C Driver, %s, (c) Amlal El Mahrouss\n", kDistVersion)
@@ -1210,7 +1210,7 @@ LIBCOMPILER_MODULE(CompilerCLang64x0) {
bool skip = false;
kFactory.Mount(new AssemblyCCInterface());
- kMachine = LibCompiler::AssemblyFactory::kArch64x0;
+ kMachine = CompilerKit::AssemblyFactory::kArch64x0;
kCompilerFrontend = new CompilerFrontend64x0();
for (auto index = 1UL; index < argc; ++index) {
diff --git a/dev/LibCompiler/src/Frontend/CCompilerARM64.cc b/dev/CompilerKit/src/Frontend/CCompilerARM64.cc
index a169e52..764bec2 100644
--- a/dev/LibCompiler/src/Frontend/CCompilerARM64.cc
+++ b/dev/CompilerKit/src/Frontend/CCompilerARM64.cc
@@ -10,10 +10,10 @@
/// BUGS: 0
/// TODO: none
-#include <LibCompiler/Backend/Aarch64.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/UUID.h>
-#include <LibCompiler/Util/CompilerUtils.h>
+#include <CompilerKit/detail/Aarch64.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/UUID.h>
+#include <CompilerKit/utils/CompilerUtils.h>
#include <cstdio>
#include <fstream>
#include <iostream>
@@ -24,7 +24,7 @@
#include <vector>
/* C driver */
-/* This is part of the LibCompiler. */
+/* This is part of the CompilerKit. */
/* (c) Amlal El Mahrouss */
/// @author EL Mahrouss Amlal (amlel)
@@ -75,10 +75,10 @@ struct CompilerStructMap final {
};
struct CompilerState final {
- std::vector<LibCompiler::SyntaxLeafList> fSyntaxTreeList;
+ std::vector<CompilerKit::SyntaxLeafList> fSyntaxTreeList;
std::vector<CompilerRegisterMap> kStackFrame;
std::vector<CompilerStructMap> kStructMap;
- LibCompiler::SyntaxLeafList* fSyntaxTree{nullptr};
+ CompilerKit::SyntaxLeafList* fSyntaxTree{nullptr};
std::unique_ptr<std::ofstream> fOutputAssembly;
std::string fLastFile;
std::string fLastError;
@@ -125,7 +125,7 @@ static std::string kRegisterPrefix = kAsmRegisterPrefix;
/////////////////////////////////////////
static std::vector<std::string> kFileList;
-static LibCompiler::AssemblyFactory kFactory;
+static CompilerKit::AssemblyFactory kFactory;
static bool kInStruct = false;
static bool kOnWhileLoop = false;
static bool kOnForLoop = false;
@@ -134,7 +134,7 @@ static bool kIfFound = false;
static size_t kBracesCount = 0UL;
/* @brief C compiler backend for C */
-class CompilerFrontendARM64 final : public LibCompiler::CompilerFrontendInterface {
+class CompilerFrontendARM64 final : public CompilerKit::CompilerFrontendInterface {
public:
explicit CompilerFrontendARM64() = default;
~CompilerFrontendARM64() override = default;
@@ -142,7 +142,7 @@ class CompilerFrontendARM64 final : public LibCompiler::CompilerFrontendInterfac
LIBCOMPILER_COPY_DEFAULT(CompilerFrontendARM64);
std::string Check(const char* text, const char* file);
- LibCompiler::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) override;
+ CompilerKit::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) override;
const char* Language() override { return "64k C"; }
};
@@ -182,7 +182,7 @@ union double_cast final {
/////////////////////////////////////////////////////////////////////////////////////////
-LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendARM64::Compile(std::string text, std::string file) {
+CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendARM64::Compile(std::string text, std::string file) {
bool typeFound = false;
bool fnFound = false;
@@ -196,7 +196,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendARM64::Compile(std::stri
// start parsing
for (size_t text_index = 0; text_index < text.size(); ++text_index) {
- auto syntaxLeaf = LibCompiler::SyntaxLeafList::SyntaxLeaf();
+ auto syntaxLeaf = CompilerKit::SyntaxLeafList::SyntaxLeaf();
auto gen = uuids::uuid_random_generator{generator};
uuids::uuid out = gen();
@@ -612,7 +612,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendARM64::Compile(std::stri
syntaxLeaf.fUserValue.clear();
}
- auto syntaxLeaf = LibCompiler::SyntaxLeafList::SyntaxLeaf();
+ auto syntaxLeaf = CompilerKit::SyntaxLeafList::SyntaxLeaf();
syntaxLeaf.fUserValue = "\n";
kState.fSyntaxTree->fLeafList.push_back(syntaxLeaf);
@@ -822,7 +822,7 @@ cc_next:
// extern does not declare anything, it extern_segments a variable.
// so that's why it's not declare upper.
- if (LibCompiler::find_word(ln, "extern")) {
+ if (CompilerKit::find_word(ln, "extern")) {
auto substr = ln.substr(ln.find("extern") + strlen("extern"));
kCompilerVariables.push_back({.fValue = substr});
}
@@ -879,7 +879,7 @@ cc_next:
skip_braces_check:
for (auto& key : kCompilerTypes) {
- if (LibCompiler::find_word(ln, key.fName)) {
+ if (CompilerKit::find_word(ln, key.fName)) {
if (isdigit(ln[ln.find(key.fName) + key.fName.size() + 1])) {
err_str += "\nNumber cannot be set for ";
err_str += key.fName;
@@ -952,9 +952,9 @@ skip_braces_check:
}
if (ln.find('(') != std::string::npos) {
- if (ln.find(';') == std::string::npos && !LibCompiler::find_word(ln, "|") &&
- !LibCompiler::find_word(ln, "||") && !LibCompiler::find_word(ln, "&") &&
- !LibCompiler::find_word(ln, "&&") && !LibCompiler::find_word(ln, "~")) {
+ if (ln.find(';') == std::string::npos && !CompilerKit::find_word(ln, "|") &&
+ !CompilerKit::find_word(ln, "||") && !CompilerKit::find_word(ln, "&") &&
+ !CompilerKit::find_word(ln, "&&") && !CompilerKit::find_word(ln, "~")) {
bool found_func = false;
size_t i = ln.find('(');
std::vector<char> opens;
@@ -1049,7 +1049,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
LIBCOMPILER_COPY_DEFAULT(AssemblyCCInterface);
- UInt32 Arch() noexcept override { return LibCompiler::AssemblyFactory::kArchAARCH64; }
+ UInt32 Arch() noexcept override { return CompilerKit::AssemblyFactory::kArchAARCH64; }
Int32 CompileToFormat(std::string src, Int32 arch) override {
if (kCompilerFrontend == nullptr) return 1;
@@ -1073,13 +1073,13 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
kState.fOutputAssembly = std::make_unique<std::ofstream>(dest);
- auto fmt = LibCompiler::current_date();
+ auto fmt = CompilerKit::current_date();
(*kState.fOutputAssembly) << "# Path: " << src_file << "\n";
(*kState.fOutputAssembly) << "# Language: ARM64 Assembly (Generated from ANSI C)\n";
(*kState.fOutputAssembly) << "# Date: " << fmt << "\n\n";
- LibCompiler::SyntaxLeafList syntax;
+ CompilerKit::SyntaxLeafList syntax;
kState.fSyntaxTreeList.push_back(syntax);
kState.fSyntaxTree = &kState.fSyntaxTreeList[kState.fSyntaxTreeList.size() - 1];
@@ -1106,7 +1106,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
std::vector<std::string> access_keywords = {"->", "."};
for (auto& access_ident : access_keywords) {
- if (LibCompiler::find_word(leaf.fUserValue, access_ident)) {
+ if (CompilerKit::find_word(leaf.fUserValue, access_ident)) {
for (auto& struc : kState.kStructMap) {
/// TODO:
}
@@ -1114,7 +1114,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
}
for (auto& keyword : keywords) {
- if (LibCompiler::find_word(leaf.fUserValue, keyword)) {
+ if (CompilerKit::find_word(leaf.fUserValue, keyword)) {
std::size_t cnt = 0UL;
for (auto& reg : kState.kStackFrame) {
@@ -1138,7 +1138,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
}
}
- if (LibCompiler::find_word(leaf.fUserValue, needle)) {
+ if (CompilerKit::find_word(leaf.fUserValue, needle)) {
if (leaf.fUserValue.find("extern_segment " + needle) != std::string::npos) {
std::string range = "extern_segment " + needle;
leaf.fUserValue.replace(leaf.fUserValue.find("extern_segment " + needle),
@@ -1182,7 +1182,7 @@ class AssemblyCCInterface final LC_ASSEMBLY_INTERFACE {
/////////////////////////////////////////////////////////////////////////////////////////
-#include <LibCompiler/Version.h>
+#include <CompilerKit/Version.h>
#define kPrintF printf
#define kSplashCxx() kPrintF(kWhite "NE C Driver, %s, (c) Amlal El Mahrouss\n", kDistVersion)
@@ -1208,7 +1208,7 @@ LIBCOMPILER_MODULE(CompilerCLangARM64) {
bool skip = false;
kFactory.Mount(new AssemblyCCInterface());
- kMachine = LibCompiler::AssemblyFactory::kArchAARCH64;
+ kMachine = CompilerKit::AssemblyFactory::kArchAARCH64;
kCompilerFrontend = new CompilerFrontendARM64();
for (auto index = 1UL; index < argc; ++index) {
diff --git a/dev/LibCompiler/src/Frontend/CCompilerPower64.cc b/dev/CompilerKit/src/Frontend/CCompilerPower64.cc
index cd50dfa..aaa2308 100644
--- a/dev/LibCompiler/src/Frontend/CCompilerPower64.cc
+++ b/dev/CompilerKit/src/Frontend/CCompilerPower64.cc
@@ -7,10 +7,10 @@
* ========================================================
*/
-#include <LibCompiler/Backend/PowerPC.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/UUID.h>
-#include <LibCompiler/Util/CompilerUtils.h>
+#include <CompilerKit/detail/PowerPC.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/UUID.h>
+#include <CompilerKit/utils/CompilerUtils.h>
#include <cstdio>
#include <fstream>
#include <iostream>
@@ -66,10 +66,10 @@ struct CompilerStructMap final {
};
struct CompilerState final {
- std::vector<LibCompiler::SyntaxLeafList> fSyntaxTreeList;
+ std::vector<CompilerKit::SyntaxLeafList> fSyntaxTreeList;
std::vector<CompilerRegisterMap> kStackFrame;
std::vector<CompilerStructMap> kStructMap;
- LibCompiler::SyntaxLeafList* fSyntaxTree{nullptr};
+ CompilerKit::SyntaxLeafList* fSyntaxTree{nullptr};
std::unique_ptr<std::ofstream> fOutputAssembly;
std::string fLastFile;
std::string fLastError;
@@ -116,7 +116,7 @@ static std::string kRegisterPrefix = kAsmRegisterPrefix;
/////////////////////////////////////////
static std::vector<std::string> kFileList;
-static LibCompiler::AssemblyFactory kFactory;
+static CompilerKit::AssemblyFactory kFactory;
static bool kInStruct = false;
static bool kOnWhileLoop = false;
static bool kOnForLoop = false;
@@ -125,7 +125,7 @@ static bool kIfFound = false;
static size_t kBracesCount = 0UL;
/* @brief C compiler backend for C */
-class CompilerFrontendPower64 final : public LibCompiler::CompilerFrontendInterface {
+class CompilerFrontendPower64 final : public CompilerKit::CompilerFrontendInterface {
public:
explicit CompilerFrontendPower64() = default;
~CompilerFrontendPower64() override = default;
@@ -133,7 +133,7 @@ class CompilerFrontendPower64 final : public LibCompiler::CompilerFrontendInterf
LIBCOMPILER_COPY_DEFAULT(CompilerFrontendPower64);
std::string Check(const char* text, const char* file);
- LibCompiler::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) override;
+ CompilerKit::SyntaxLeafList::SyntaxLeaf Compile(std::string text, std::string file) override;
const char* Language() override { return "POWER C"; }
};
@@ -173,7 +173,7 @@ union double_cast final {
/////////////////////////////////////////////////////////////////////////////////////////
-LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendPower64::Compile(std::string text_, std::string file) {
+CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendPower64::Compile(std::string text_, std::string file) {
std::string text = text_;
bool typeFound = false;
@@ -189,7 +189,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendPower64::Compile(std::st
// start parsing
for (size_t text_index = 0; text_index < text.size(); ++text_index) {
- auto syntax_leaf = LibCompiler::SyntaxLeafList::SyntaxLeaf();
+ auto syntax_leaf = CompilerKit::SyntaxLeafList::SyntaxLeaf();
auto gen = uuids::uuid_random_generator{generator};
uuids::uuid out = gen();
@@ -632,7 +632,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendPower64::Compile(std::st
syntax_leaf.fUserValue.clear();
}
- auto syntax_leaf = LibCompiler::SyntaxLeafList::SyntaxLeaf();
+ auto syntax_leaf = CompilerKit::SyntaxLeafList::SyntaxLeaf();
syntax_leaf.fUserValue = "\n";
kState.fSyntaxTree->fLeafList.push_back(syntax_leaf);
@@ -842,7 +842,7 @@ cc_next:
// extern does not declare anything, it extern_segments a variable.
// so that's why it's not declare upper.
- if (LibCompiler::find_word(ln, "extern")) {
+ if (CompilerKit::find_word(ln, "extern")) {
auto substr = ln.substr(ln.find("extern") + strlen("extern"));
kCompilerVariables.push_back({.fValue = substr});
}
@@ -899,7 +899,7 @@ cc_next:
skip_braces_check:
for (auto& key : kCompilerTypes) {
- if (LibCompiler::find_word(ln, key.fName)) {
+ if (CompilerKit::find_word(ln, key.fName)) {
if (isdigit(ln[ln.find(key.fName) + key.fName.size() + 1])) {
err_str += "\nNumber cannot be set for ";
err_str += key.fName;
@@ -972,9 +972,9 @@ skip_braces_check:
}
if (ln.find('(') != std::string::npos) {
- if (ln.find(';') == std::string::npos && !LibCompiler::find_word(ln, "|") &&
- !LibCompiler::find_word(ln, "||") && !LibCompiler::find_word(ln, "&") &&
- !LibCompiler::find_word(ln, "&&") && !LibCompiler::find_word(ln, "~")) {
+ if (ln.find(';') == std::string::npos && !CompilerKit::find_word(ln, "|") &&
+ !CompilerKit::find_word(ln, "||") && !CompilerKit::find_word(ln, "&") &&
+ !CompilerKit::find_word(ln, "&&") && !CompilerKit::find_word(ln, "~")) {
bool found_func = false;
size_t i = ln.find('(');
std::vector<char> opens;
@@ -1069,7 +1069,7 @@ class AssemblyMountpointCLang final LC_ASSEMBLY_INTERFACE {
LIBCOMPILER_COPY_DEFAULT(AssemblyMountpointCLang);
- UInt32 Arch() noexcept override { return LibCompiler::AssemblyFactory::kArchPowerPC; }
+ UInt32 Arch() noexcept override { return CompilerKit::AssemblyFactory::kArchPowerPC; }
Int32 CompileToFormat(std::string src, Int32 arch) override {
if (kCompilerFrontend == nullptr) return 1;
@@ -1093,13 +1093,13 @@ class AssemblyMountpointCLang final LC_ASSEMBLY_INTERFACE {
kState.fOutputAssembly = std::make_unique<std::ofstream>(dest);
- auto fmt = LibCompiler::current_date();
+ auto fmt = CompilerKit::current_date();
(*kState.fOutputAssembly) << "# Path: " << src_file << "\n";
(*kState.fOutputAssembly) << "# Language: POWER Assembly (Generated from C)\n";
(*kState.fOutputAssembly) << "# Date: " << fmt << "\n\n";
- LibCompiler::SyntaxLeafList syntax;
+ CompilerKit::SyntaxLeafList syntax;
kState.fSyntaxTreeList.push_back(syntax);
kState.fSyntaxTree = &kState.fSyntaxTreeList[kState.fSyntaxTreeList.size() - 1];
@@ -1126,7 +1126,7 @@ class AssemblyMountpointCLang final LC_ASSEMBLY_INTERFACE {
std::vector<std::string> access_keywords = {"->", "."};
for (auto& access_ident : access_keywords) {
- if (LibCompiler::find_word(leaf.fUserValue, access_ident)) {
+ if (CompilerKit::find_word(leaf.fUserValue, access_ident)) {
for (auto& struc : kState.kStructMap) {
/// TODO:
}
@@ -1134,7 +1134,7 @@ class AssemblyMountpointCLang final LC_ASSEMBLY_INTERFACE {
}
for (auto& keyword : keywords) {
- if (LibCompiler::find_word(leaf.fUserValue, keyword)) {
+ if (CompilerKit::find_word(leaf.fUserValue, keyword)) {
std::size_t cnt = 0UL;
for (auto& reg : kState.kStackFrame) {
@@ -1158,7 +1158,7 @@ class AssemblyMountpointCLang final LC_ASSEMBLY_INTERFACE {
}
}
- if (LibCompiler::find_word(leaf.fUserValue, needle)) {
+ if (CompilerKit::find_word(leaf.fUserValue, needle)) {
if (leaf.fUserValue.find("extern_segment ") != std::string::npos) {
std::string range = "extern_segment ";
leaf.fUserValue.replace(leaf.fUserValue.find(range), range.size(), "");
@@ -1201,7 +1201,7 @@ class AssemblyMountpointCLang final LC_ASSEMBLY_INTERFACE {
/////////////////////////////////////////////////////////////////////////////////////////
-#include <LibCompiler/Version.h>
+#include <CompilerKit/Version.h>
#define kPrintF printf
#define kSplashCxx() kPrintF(kWhite "cc, %s, (c) Amlal El Mahrouss\n", kDistVersion)
@@ -1227,7 +1227,7 @@ LIBCOMPILER_MODULE(CompilerCLangPowerPC) {
bool skip = false;
kFactory.Mount(new AssemblyMountpointCLang());
- kMachine = LibCompiler::AssemblyFactory::kArchPowerPC;
+ kMachine = CompilerKit::AssemblyFactory::kArchPowerPC;
kCompilerFrontend = new CompilerFrontendPower64();
for (auto index = 1UL; index < argc; ++index) {
diff --git a/dev/LibCompiler/src/Frontend/CPlusPlusCompilerAMD64.cc b/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc
index 726b277..c38378a 100644
--- a/dev/LibCompiler/src/Frontend/CPlusPlusCompilerAMD64.cc
+++ b/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc
@@ -14,14 +14,14 @@
#define kExitOK (EXIT_SUCCESS)
#define kExitNO (EXIT_FAILURE)
-#include <LibCompiler/Backend/X64.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/PEF.h>
-#include <LibCompiler/UUID.h>
-#include <LibCompiler/Util/CompilerUtils.h>
+#include <CompilerKit/detail/X64.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/PEF.h>
+#include <CompilerKit/UUID.h>
+#include <CompilerKit/utils/CompilerUtils.h>
/* NeKernel C++ Compiler Driver */
-/* This is part of the LibCompiler. */
+/* This is part of the CompilerKit. */
/* (c) Amlal El Mahrouss 2024-2025 */
/// @author EL Mahrouss Amlal (amlal@nekernel.org)
@@ -66,23 +66,23 @@ std::filesystem::path expand_home(const std::filesystem::path& p) {
}
struct CompilerRegisterMap final {
- LibCompiler::STLString fName;
- LibCompiler::STLString fReg;
+ CompilerKit::STLString fName;
+ CompilerKit::STLString fReg;
};
/// \brief Offset based struct/class
struct CompilerStructMap final {
- LibCompiler::STLString fName;
- LibCompiler::STLString fReg;
- std::vector<std::pair<UInt32, LibCompiler::STLString>> fOffsets;
+ CompilerKit::STLString fName;
+ CompilerKit::STLString fReg;
+ std::vector<std::pair<UInt32, CompilerKit::STLString>> fOffsets;
};
/// \brief Compiler state structure.
struct CompilerState final {
std::vector<CompilerRegisterMap> fStackMapVector;
std::vector<CompilerStructMap> fStructMapVector;
- LibCompiler::STLString fLastFile;
- LibCompiler::STLString fLastError;
+ CompilerKit::STLString fLastFile;
+ CompilerKit::STLString fLastError;
};
} // namespace Detail
@@ -93,7 +93,7 @@ static Int32 kOnClassScope = 0;
/////////////////////////////////////////////////////////////////////////////////////////
// Target architecture.
-static Int32 kMachine = LibCompiler::AssemblyFactory::kArchAMD64;
+static Int32 kMachine = CompilerKit::AssemblyFactory::kArchAMD64;
/////////////////////////////////////////
@@ -101,7 +101,7 @@ static Int32 kMachine = LibCompiler::AssemblyFactory::kArchAMD64;
/////////////////////////////////////////
-static std::vector<LibCompiler::CompilerKeyword> kKeywords;
+static std::vector<CompilerKit::CompilerKeyword> kKeywords;
/////////////////////////////////////////
@@ -109,7 +109,7 @@ static std::vector<LibCompiler::CompilerKeyword> kKeywords;
/////////////////////////////////////////
-static LibCompiler::AssemblyFactory kFactory;
+static CompilerKit::AssemblyFactory kFactory;
static Boolean kInStruct = false;
static Boolean kOnWhileLoop = false;
static Boolean kOnForLoop = false;
@@ -124,8 +124,8 @@ class CompilerFrontendCPlusPlusAMD64 final LC_COMPILER_FRONTEND {
LIBCOMPILER_COPY_DEFAULT(CompilerFrontendCPlusPlusAMD64);
- LibCompiler::SyntaxLeafList::SyntaxLeaf Compile(const LibCompiler::STLString text,
- LibCompiler::STLString file) override;
+ CompilerKit::SyntaxLeafList::SyntaxLeaf Compile(const CompilerKit::STLString text,
+ CompilerKit::STLString file) override;
const char* Language() override;
};
@@ -134,15 +134,15 @@ class CompilerFrontendCPlusPlusAMD64 final LC_COMPILER_FRONTEND {
static CompilerFrontendCPlusPlusAMD64* kCompilerFrontend = nullptr;
-static std::vector<LibCompiler::STLString> kRegisterMap;
+static std::vector<CompilerKit::STLString> kRegisterMap;
-static std::vector<LibCompiler::STLString> kRegisterList = {
+static std::vector<CompilerKit::STLString> kRegisterList = {
"rbx", "rsi", "r10", "r11", "r12", "r13", "r14", "r15", "xmm12", "xmm13", "xmm14", "xmm15",
};
/// @brief The PEF calling convention (caller must save rax, rbp)
/// @note callee must return via **rax**.
-static std::vector<LibCompiler::STLString> kRegisterConventionCallList = {
+static std::vector<CompilerKit::STLString> kRegisterConventionCallList = {
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
};
@@ -155,7 +155,7 @@ const char* CompilerFrontendCPlusPlusAMD64::Language() {
}
static std::uintptr_t kOrigin = kPefBaseOrigin;
-static std::vector<std::pair<LibCompiler::STLString, std::uintptr_t>> kOriginMap;
+static std::vector<std::pair<CompilerKit::STLString, std::uintptr_t>> kOriginMap;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -164,19 +164,19 @@ static std::vector<std::pair<LibCompiler::STLString, std::uintptr_t>> kOriginMap
/////////////////////////////////////////////////////////////////////////////////////////
-LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
- LibCompiler::STLString text, LibCompiler::STLString file) {
- LibCompiler::SyntaxLeafList::SyntaxLeaf syntax_tree;
+CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
+ CompilerKit::STLString text, CompilerKit::STLString file) {
+ CompilerKit::SyntaxLeafList::SyntaxLeaf syntax_tree;
if (text.length() < 1) return syntax_tree;
std::size_t index = 0UL;
- std::vector<std::pair<LibCompiler::CompilerKeyword, std::size_t>> keywords_list;
+ std::vector<std::pair<CompilerKit::CompilerKeyword, std::size_t>> keywords_list;
for (auto& keyword : kKeywords) {
if (text.find(keyword.keyword_name) != std::string::npos) {
switch (keyword.keyword_kind) {
- case LibCompiler::kKeywordKindCommentInline: {
+ case CompilerKit::kKeywordKindCommentInline: {
break;
}
default:
@@ -188,17 +188,17 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
// Safe guard: can't go before start of string
if (pos > 0 && text[pos - 1] == '+' &&
- keyword.keyword_kind == LibCompiler::kKeywordKindVariableAssign)
+ keyword.keyword_kind == CompilerKit::kKeywordKindVariableAssign)
continue;
if (pos > 0 && text[pos - 1] == '-' &&
- keyword.keyword_kind == LibCompiler::kKeywordKindVariableAssign)
+ keyword.keyword_kind == CompilerKit::kKeywordKindVariableAssign)
continue;
// Safe guard: don't go out of range
if ((pos + keyword.keyword_name.size()) < text.size() &&
text[pos + keyword.keyword_name.size()] == '=' &&
- keyword.keyword_kind == LibCompiler::kKeywordKindVariableAssign)
+ keyword.keyword_kind == CompilerKit::kKeywordKindVariableAssign)
continue;
keywords_list.emplace_back(std::make_pair(keyword, index));
@@ -207,28 +207,28 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
}
for (auto& keyword : keywords_list) {
- if (text.find(keyword.first.keyword_name) == LibCompiler::STLString::npos) continue;
+ if (text.find(keyword.first.keyword_name) == CompilerKit::STLString::npos) continue;
switch (keyword.first.keyword_kind) {
- case LibCompiler::KeywordKind::kKeywordKindClass: {
+ case CompilerKit::KeywordKind::kKeywordKindClass: {
++kOnClassScope;
break;
}
- case LibCompiler::KeywordKind::kKeywordKindIf: {
+ case CompilerKit::KeywordKind::kKeywordKindIf: {
std::size_t keywordPos = text.find(keyword.first.keyword_name);
std::size_t openParen = text.find("(", keywordPos);
std::size_t closeParen = text.find(")", openParen);
- if (keywordPos == LibCompiler::STLString::npos ||
- openParen == LibCompiler::STLString::npos ||
- closeParen == LibCompiler::STLString::npos || closeParen <= openParen) {
+ if (keywordPos == CompilerKit::STLString::npos ||
+ openParen == CompilerKit::STLString::npos ||
+ closeParen == CompilerKit::STLString::npos || closeParen <= openParen) {
Detail::print_error("Malformed if expression: " + text, file);
break;
}
auto expr = text.substr(openParen + 1, closeParen - openParen - 1);
- if (expr.find(">=") != LibCompiler::STLString::npos) {
+ if (expr.find(">=") != CompilerKit::STLString::npos) {
auto left = text.substr(
text.find(keyword.first.keyword_name) + keyword.first.keyword_name.size() + 2,
expr.find("<=") + strlen("<="));
@@ -270,7 +270,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
for (auto pairRight : kRegisterMap) {
++indexRight;
- LibCompiler::STLString instr = "mov ";
+ CompilerKit::STLString instr = "mov ";
if (pairRight != valueOfVar) {
auto& valueOfVarOpposite = isdigit(left[0]) ? left : right;
@@ -297,7 +297,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
lc_done_iterarting_on_if:
- LibCompiler::STLString symbol_name_fn = text;
+ CompilerKit::STLString symbol_name_fn = text;
symbol_name_fn.erase(symbol_name_fn.find(keyword.first.keyword_name));
@@ -311,7 +311,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
break;
}
- case LibCompiler::KeywordKind::kKeywordKindFunctionStart: {
+ case CompilerKit::KeywordKind::kKeywordKindFunctionStart: {
for (auto& ch : text) {
if (isdigit(ch)) {
goto dont_accept;
@@ -324,7 +324,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
break;
accept:
- LibCompiler::STLString symbol_name_fn = text;
+ CompilerKit::STLString symbol_name_fn = text;
size_t indexFnName = 0;
// this one is for the type.
@@ -337,12 +337,12 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
symbol_name_fn = text.substr(indexFnName);
- if (text.find("return ") != LibCompiler::STLString::npos) {
+ if (text.find("return ") != CompilerKit::STLString::npos) {
text.erase(0, text.find("return "));
break;
}
- if (text.ends_with(";") && text.find("return") == LibCompiler::STLString::npos)
+ if (text.ends_with(";") && text.find("return") == CompilerKit::STLString::npos)
goto lc_write_assembly;
else if (text.size() <= indexFnName)
Detail::print_error("Invalid function name: " + symbol_name_fn, file);
@@ -358,7 +358,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
++indexFnName;
}
- if (symbol_name_fn.find("(") != LibCompiler::STLString::npos) {
+ if (symbol_name_fn.find("(") != CompilerKit::STLString::npos) {
symbol_name_fn.erase(symbol_name_fn.find("("));
}
@@ -372,7 +372,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
lc_write_assembly:
auto it =
std::find_if(kOriginMap.begin(), kOriginMap.end(),
- [&symbol_name_fn](std::pair<LibCompiler::STLString, std::uintptr_t> pair) -> bool {
+ [&symbol_name_fn](std::pair<CompilerKit::STLString, std::uintptr_t> pair) -> bool {
return symbol_name_fn == pair.first;
});
@@ -384,7 +384,7 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
kOrigin += 1UL;
}
}
- case LibCompiler::KeywordKind::kKeywordKindFunctionEnd: {
+ case CompilerKit::KeywordKind::kKeywordKindFunctionEnd: {
if (kOnClassScope) --kOnClassScope;
if (text.ends_with(";")) break;
@@ -399,48 +399,48 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
break;
}
- case LibCompiler::KeywordKind::kKeywordKindEndInstr:
- case LibCompiler::KeywordKind::kKeywordKindVariableInc:
- case LibCompiler::KeywordKind::kKeywordKindVariableDec:
- case LibCompiler::KeywordKind::kKeywordKindVariableAssign: {
- LibCompiler::STLString valueOfVar = "";
+ case CompilerKit::KeywordKind::kKeywordKindEndInstr:
+ case CompilerKit::KeywordKind::kKeywordKindVariableInc:
+ case CompilerKit::KeywordKind::kKeywordKindVariableDec:
+ case CompilerKit::KeywordKind::kKeywordKindVariableAssign: {
+ CompilerKit::STLString valueOfVar = "";
- if (keyword.first.keyword_kind == LibCompiler::KeywordKind::kKeywordKindVariableInc) {
+ if (keyword.first.keyword_kind == CompilerKit::KeywordKind::kKeywordKindVariableInc) {
valueOfVar = text.substr(text.find("+=") + 2);
} else if (keyword.first.keyword_kind ==
- LibCompiler::KeywordKind::kKeywordKindVariableDec) {
+ CompilerKit::KeywordKind::kKeywordKindVariableDec) {
valueOfVar = text.substr(text.find("-=") + 2);
} else if (keyword.first.keyword_kind ==
- LibCompiler::KeywordKind::kKeywordKindVariableAssign) {
+ CompilerKit::KeywordKind::kKeywordKindVariableAssign) {
valueOfVar = text.substr(text.find("=") + 1);
- } else if (keyword.first.keyword_kind == LibCompiler::KeywordKind::kKeywordKindEndInstr) {
+ } else if (keyword.first.keyword_kind == CompilerKit::KeywordKind::kKeywordKindEndInstr) {
break;
}
- while (valueOfVar.find(";") != LibCompiler::STLString::npos &&
- keyword.first.keyword_kind != LibCompiler::KeywordKind::kKeywordKindEndInstr) {
+ while (valueOfVar.find(";") != CompilerKit::STLString::npos &&
+ keyword.first.keyword_kind != CompilerKit::KeywordKind::kKeywordKindEndInstr) {
valueOfVar.erase(valueOfVar.find(";"));
}
- LibCompiler::STLString varName = text;
+ CompilerKit::STLString varName = text;
- if (keyword.first.keyword_kind == LibCompiler::KeywordKind::kKeywordKindVariableInc) {
+ if (keyword.first.keyword_kind == CompilerKit::KeywordKind::kKeywordKindVariableInc) {
varName.erase(varName.find("+="));
} else if (keyword.first.keyword_kind ==
- LibCompiler::KeywordKind::kKeywordKindVariableDec) {
+ CompilerKit::KeywordKind::kKeywordKindVariableDec) {
varName.erase(varName.find("-="));
} else if (keyword.first.keyword_kind ==
- LibCompiler::KeywordKind::kKeywordKindVariableAssign) {
+ CompilerKit::KeywordKind::kKeywordKindVariableAssign) {
varName.erase(varName.find("="));
- } else if (keyword.first.keyword_kind == LibCompiler::KeywordKind::kKeywordKindEndInstr) {
+ } else if (keyword.first.keyword_kind == CompilerKit::KeywordKind::kKeywordKindEndInstr) {
varName.erase(varName.find(";"));
}
static Boolean typeFound = false;
for (auto& keyword : kKeywords) {
- if (keyword.keyword_kind == LibCompiler::kKeywordKindType) {
- if (text.find(keyword.keyword_name) != LibCompiler::STLString::npos) {
+ if (keyword.keyword_kind == CompilerKit::kKeywordKindType) {
+ if (text.find(keyword.keyword_name) != CompilerKit::STLString::npos) {
if (text[text.find(keyword.keyword_name)] == ' ') {
typeFound = false;
continue;
@@ -451,22 +451,22 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
}
}
- LibCompiler::STLString instr = "mov ";
+ CompilerKit::STLString instr = "mov ";
- std::vector<LibCompiler::STLString> newVars;
+ std::vector<CompilerKit::STLString> newVars;
if (typeFound &&
- keyword.first.keyword_kind != LibCompiler::KeywordKind::kKeywordKindVariableInc &&
- keyword.first.keyword_kind != LibCompiler::KeywordKind::kKeywordKindVariableDec) {
+ keyword.first.keyword_kind != CompilerKit::KeywordKind::kKeywordKindVariableInc &&
+ keyword.first.keyword_kind != CompilerKit::KeywordKind::kKeywordKindVariableDec) {
if (kRegisterMap.size() > kRegisterList.size()) {
++kFunctionEmbedLevel;
}
- while (varName.find(" ") != LibCompiler::STLString::npos) {
+ while (varName.find(" ") != CompilerKit::STLString::npos) {
varName.erase(varName.find(" "), 1);
}
- while (varName.find("\t") != LibCompiler::STLString::npos) {
+ while (varName.find("\t") != CompilerKit::STLString::npos) {
varName.erase(varName.find("\t"), 1);
}
@@ -534,8 +534,8 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
done:
for (auto& keyword : kKeywords) {
- if (keyword.keyword_kind == LibCompiler::kKeywordKindType &&
- varName.find(keyword.keyword_name) != LibCompiler::STLString::npos) {
+ if (keyword.keyword_kind == CompilerKit::kKeywordKindType &&
+ varName.find(keyword.keyword_name) != CompilerKit::STLString::npos) {
varName.erase(varName.find(keyword.keyword_name), keyword.keyword_name.size());
break;
}
@@ -549,31 +549,31 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
kRegisterMap.insert(kRegisterMap.end(), newVars.begin(), newVars.end());
if (keyword.second > 0 &&
- kKeywords[keyword.second - 1].keyword_kind == LibCompiler::kKeywordKindType ||
- kKeywords[keyword.second - 1].keyword_kind == LibCompiler::kKeywordKindTypePtr) {
+ kKeywords[keyword.second - 1].keyword_kind == CompilerKit::kKeywordKindType ||
+ kKeywords[keyword.second - 1].keyword_kind == CompilerKit::kKeywordKindTypePtr) {
syntax_tree.fUserValue = "\n";
continue;
}
- if (keyword.first.keyword_kind == LibCompiler::KeywordKind::kKeywordKindEndInstr) {
+ if (keyword.first.keyword_kind == CompilerKit::KeywordKind::kKeywordKindEndInstr) {
syntax_tree.fUserValue = "\n";
continue;
}
- if (keyword.first.keyword_kind == LibCompiler::KeywordKind::kKeywordKindVariableInc) {
+ if (keyword.first.keyword_kind == CompilerKit::KeywordKind::kKeywordKindVariableInc) {
instr = "add ";
} else if (keyword.first.keyword_kind ==
- LibCompiler::KeywordKind::kKeywordKindVariableDec) {
+ CompilerKit::KeywordKind::kKeywordKindVariableDec) {
instr = "sub ";
}
- LibCompiler::STLString varErrCpy = varName;
+ CompilerKit::STLString varErrCpy = varName;
- while (varName.find(" ") != LibCompiler::STLString::npos) {
+ while (varName.find(" ") != CompilerKit::STLString::npos) {
varName.erase(varName.find(" "), 1);
}
- while (varName.find("\t") != LibCompiler::STLString::npos) {
+ while (varName.find("\t") != CompilerKit::STLString::npos) {
varName.erase(varName.find("\t"), 1);
}
@@ -585,11 +585,11 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
valueOfVar.erase(i, 1);
}
- while (valueOfVar.find(" ") != LibCompiler::STLString::npos) {
+ while (valueOfVar.find(" ") != CompilerKit::STLString::npos) {
valueOfVar.erase(valueOfVar.find(" "), 1);
}
- while (valueOfVar.find("\t") != LibCompiler::STLString::npos) {
+ while (valueOfVar.find("\t") != CompilerKit::STLString::npos) {
valueOfVar.erase(valueOfVar.find("\t"), 1);
}
@@ -639,10 +639,10 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
break;
}
- case LibCompiler::KeywordKind::kKeywordKindReturn: {
+ case CompilerKit::KeywordKind::kKeywordKindReturn: {
try {
auto pos = text.find("return") + strlen("return") + 1;
- LibCompiler::STLString subText = text.substr(pos);
+ CompilerKit::STLString subText = text.substr(pos);
subText = subText.erase(subText.find(";"));
size_t indxReg = 0UL;
@@ -674,13 +674,13 @@ LibCompiler::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile(
}
if (syntax_tree.fUserValue.empty()) {
- if (subText.find("(") != LibCompiler::STLString::npos) {
+ if (subText.find("(") != CompilerKit::STLString::npos) {
subText.erase(subText.find("("));
auto it = std::find_if(
kOriginMap.begin(), kOriginMap.end(),
- [&subText](std::pair<LibCompiler::STLString, std::uintptr_t> pair) -> bool {
- return pair.first.find(subText) != LibCompiler::STLString::npos;
+ [&subText](std::pair<CompilerKit::STLString, std::uintptr_t> pair) -> bool {
+ return pair.first.find(subText) != CompilerKit::STLString::npos;
});
if (it == kOriginMap.end())
@@ -725,18 +725,18 @@ class AssemblyCPlusPlusInterfaceAMD64 final LC_ASSEMBLY_INTERFACE {
LIBCOMPILER_COPY_DEFAULT(AssemblyCPlusPlusInterfaceAMD64);
- UInt32 Arch() noexcept override { return LibCompiler::AssemblyFactory::kArchAMD64; }
+ UInt32 Arch() noexcept override { return CompilerKit::AssemblyFactory::kArchAMD64; }
- Int32 CompileToFormat(LibCompiler::STLString src, Int32 arch) override {
+ Int32 CompileToFormat(CompilerKit::STLString src, Int32 arch) override {
if (kCompilerFrontend == nullptr) return kExitNO;
- LibCompiler::STLString dest = src;
+ CompilerKit::STLString dest = src;
dest += ".pp.masm";
std::ofstream out_fp(dest);
std::ifstream src_fp = std::ifstream(src + ".pp");
- LibCompiler::STLString line_source;
+ CompilerKit::STLString line_source;
out_fp << "#bits 64\n";
out_fp << "#org " << kOrigin << "\n\n";
@@ -759,70 +759,70 @@ class AssemblyCPlusPlusInterfaceAMD64 final LC_ASSEMBLY_INTERFACE {
LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
Boolean skip = false;
- kKeywords.emplace_back("if", LibCompiler::kKeywordKindIf);
- kKeywords.emplace_back("else", LibCompiler::kKeywordKindElse);
- kKeywords.emplace_back("else if", LibCompiler::kKeywordKindElseIf);
-
- kKeywords.emplace_back("class", LibCompiler::kKeywordKindClass);
- kKeywords.emplace_back("struct", LibCompiler::kKeywordKindClass);
- kKeywords.emplace_back("namespace", LibCompiler::kKeywordKindNamespace);
- kKeywords.emplace_back("typedef", LibCompiler::kKeywordKindTypedef);
- kKeywords.emplace_back("using", LibCompiler::kKeywordKindTypedef);
- kKeywords.emplace_back("{", LibCompiler::kKeywordKindBodyStart);
- kKeywords.emplace_back("}", LibCompiler::kKeywordKindBodyEnd);
- kKeywords.emplace_back("auto", LibCompiler::kKeywordKindVariable);
- kKeywords.emplace_back("int", LibCompiler::kKeywordKindType);
- kKeywords.emplace_back("bool", LibCompiler::kKeywordKindType);
- kKeywords.emplace_back("unsigned", LibCompiler::kKeywordKindType);
- kKeywords.emplace_back("short", LibCompiler::kKeywordKindType);
- kKeywords.emplace_back("char", LibCompiler::kKeywordKindType);
- kKeywords.emplace_back("long", LibCompiler::kKeywordKindType);
- kKeywords.emplace_back("float", LibCompiler::kKeywordKindType);
- kKeywords.emplace_back("double", LibCompiler::kKeywordKindType);
- kKeywords.emplace_back("void", LibCompiler::kKeywordKindType);
-
- kKeywords.emplace_back("auto*", LibCompiler::kKeywordKindVariablePtr);
- kKeywords.emplace_back("int*", LibCompiler::kKeywordKindTypePtr);
- kKeywords.emplace_back("bool*", LibCompiler::kKeywordKindTypePtr);
- kKeywords.emplace_back("unsigned*", LibCompiler::kKeywordKindTypePtr);
- kKeywords.emplace_back("short*", LibCompiler::kKeywordKindTypePtr);
- kKeywords.emplace_back("char*", LibCompiler::kKeywordKindTypePtr);
- kKeywords.emplace_back("long*", LibCompiler::kKeywordKindTypePtr);
- kKeywords.emplace_back("float*", LibCompiler::kKeywordKindTypePtr);
- kKeywords.emplace_back("double*", LibCompiler::kKeywordKindTypePtr);
- kKeywords.emplace_back("void*", LibCompiler::kKeywordKindTypePtr);
-
- kKeywords.emplace_back("(", LibCompiler::kKeywordKindFunctionStart);
- kKeywords.emplace_back(")", LibCompiler::kKeywordKindFunctionEnd);
- kKeywords.emplace_back("=", LibCompiler::kKeywordKindVariableAssign);
- kKeywords.emplace_back("+=", LibCompiler::kKeywordKindVariableInc);
- kKeywords.emplace_back("-=", LibCompiler::kKeywordKindVariableDec);
- kKeywords.emplace_back("const", LibCompiler::kKeywordKindConstant);
- kKeywords.emplace_back("*", LibCompiler::kKeywordKindPtr);
- kKeywords.emplace_back("->", LibCompiler::kKeywordKindPtrAccess);
- kKeywords.emplace_back(".", LibCompiler::kKeywordKindAccess);
- kKeywords.emplace_back(",", LibCompiler::kKeywordKindArgSeparator);
- kKeywords.emplace_back(";", LibCompiler::kKeywordKindEndInstr);
- kKeywords.emplace_back(":", LibCompiler::kKeywordKindSpecifier);
- kKeywords.emplace_back("public:", LibCompiler::kKeywordKindSpecifier);
- kKeywords.emplace_back("private:", LibCompiler::kKeywordKindSpecifier);
- kKeywords.emplace_back("protected:", LibCompiler::kKeywordKindSpecifier);
- kKeywords.emplace_back("final", LibCompiler::kKeywordKindSpecifier);
- kKeywords.emplace_back("return", LibCompiler::kKeywordKindReturn);
- kKeywords.emplace_back("/*", LibCompiler::kKeywordKindCommentMultiLineStart);
- kKeywords.emplace_back("*/", LibCompiler::kKeywordKindCommentMultiLineEnd);
- kKeywords.emplace_back("//", LibCompiler::kKeywordKindCommentInline);
- kKeywords.emplace_back("==", LibCompiler::kKeywordKindEq);
- kKeywords.emplace_back("!=", LibCompiler::kKeywordKindNotEq);
- kKeywords.emplace_back(">=", LibCompiler::kKeywordKindGreaterEq);
- kKeywords.emplace_back("<=", LibCompiler::kKeywordKindLessEq);
+ kKeywords.emplace_back("if", CompilerKit::kKeywordKindIf);
+ kKeywords.emplace_back("else", CompilerKit::kKeywordKindElse);
+ kKeywords.emplace_back("else if", CompilerKit::kKeywordKindElseIf);
+
+ kKeywords.emplace_back("class", CompilerKit::kKeywordKindClass);
+ kKeywords.emplace_back("struct", CompilerKit::kKeywordKindClass);
+ kKeywords.emplace_back("namespace", CompilerKit::kKeywordKindNamespace);
+ kKeywords.emplace_back("typedef", CompilerKit::kKeywordKindTypedef);
+ kKeywords.emplace_back("using", CompilerKit::kKeywordKindTypedef);
+ kKeywords.emplace_back("{", CompilerKit::kKeywordKindBodyStart);
+ kKeywords.emplace_back("}", CompilerKit::kKeywordKindBodyEnd);
+ kKeywords.emplace_back("auto", CompilerKit::kKeywordKindVariable);
+ kKeywords.emplace_back("int", CompilerKit::kKeywordKindType);
+ kKeywords.emplace_back("bool", CompilerKit::kKeywordKindType);
+ kKeywords.emplace_back("unsigned", CompilerKit::kKeywordKindType);
+ kKeywords.emplace_back("short", CompilerKit::kKeywordKindType);
+ kKeywords.emplace_back("char", CompilerKit::kKeywordKindType);
+ kKeywords.emplace_back("long", CompilerKit::kKeywordKindType);
+ kKeywords.emplace_back("float", CompilerKit::kKeywordKindType);
+ kKeywords.emplace_back("double", CompilerKit::kKeywordKindType);
+ kKeywords.emplace_back("void", CompilerKit::kKeywordKindType);
+
+ kKeywords.emplace_back("auto*", CompilerKit::kKeywordKindVariablePtr);
+ kKeywords.emplace_back("int*", CompilerKit::kKeywordKindTypePtr);
+ kKeywords.emplace_back("bool*", CompilerKit::kKeywordKindTypePtr);
+ kKeywords.emplace_back("unsigned*", CompilerKit::kKeywordKindTypePtr);
+ kKeywords.emplace_back("short*", CompilerKit::kKeywordKindTypePtr);
+ kKeywords.emplace_back("char*", CompilerKit::kKeywordKindTypePtr);
+ kKeywords.emplace_back("long*", CompilerKit::kKeywordKindTypePtr);
+ kKeywords.emplace_back("float*", CompilerKit::kKeywordKindTypePtr);
+ kKeywords.emplace_back("double*", CompilerKit::kKeywordKindTypePtr);
+ kKeywords.emplace_back("void*", CompilerKit::kKeywordKindTypePtr);
+
+ kKeywords.emplace_back("(", CompilerKit::kKeywordKindFunctionStart);
+ kKeywords.emplace_back(")", CompilerKit::kKeywordKindFunctionEnd);
+ kKeywords.emplace_back("=", CompilerKit::kKeywordKindVariableAssign);
+ kKeywords.emplace_back("+=", CompilerKit::kKeywordKindVariableInc);
+ kKeywords.emplace_back("-=", CompilerKit::kKeywordKindVariableDec);
+ kKeywords.emplace_back("const", CompilerKit::kKeywordKindConstant);
+ kKeywords.emplace_back("*", CompilerKit::kKeywordKindPtr);
+ kKeywords.emplace_back("->", CompilerKit::kKeywordKindPtrAccess);
+ kKeywords.emplace_back(".", CompilerKit::kKeywordKindAccess);
+ kKeywords.emplace_back(",", CompilerKit::kKeywordKindArgSeparator);
+ kKeywords.emplace_back(";", CompilerKit::kKeywordKindEndInstr);
+ kKeywords.emplace_back(":", CompilerKit::kKeywordKindSpecifier);
+ kKeywords.emplace_back("public:", CompilerKit::kKeywordKindSpecifier);
+ kKeywords.emplace_back("private:", CompilerKit::kKeywordKindSpecifier);
+ kKeywords.emplace_back("protected:", CompilerKit::kKeywordKindSpecifier);
+ kKeywords.emplace_back("final", CompilerKit::kKeywordKindSpecifier);
+ kKeywords.emplace_back("return", CompilerKit::kKeywordKindReturn);
+ kKeywords.emplace_back("/*", CompilerKit::kKeywordKindCommentMultiLineStart);
+ kKeywords.emplace_back("*/", CompilerKit::kKeywordKindCommentMultiLineEnd);
+ kKeywords.emplace_back("//", CompilerKit::kKeywordKindCommentInline);
+ kKeywords.emplace_back("==", CompilerKit::kKeywordKindEq);
+ kKeywords.emplace_back("!=", CompilerKit::kKeywordKindNotEq);
+ kKeywords.emplace_back(">=", CompilerKit::kKeywordKindGreaterEq);
+ kKeywords.emplace_back("<=", CompilerKit::kKeywordKindLessEq);
kErrorLimit = 0;
kCompilerFrontend = new CompilerFrontendCPlusPlusAMD64();
kFactory.Mount(new AssemblyCPlusPlusInterfaceAMD64());
- LibCompiler::install_signal(SIGSEGV, Detail::drvi_crash_handler);
+ CompilerKit::install_signal(SIGSEGV, Detail::drvi_crash_handler);
for (auto index = 1UL; index < argc; ++index) {
if (!argv[index]) break;
@@ -859,7 +859,7 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
continue;
}
- LibCompiler::STLString err = "Unknown option: ";
+ CompilerKit::STLString err = "Unknown option: ";
err += argv[index];
Detail::print_error(err, "cxxdrv");
@@ -867,11 +867,11 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
continue;
}
- LibCompiler::STLString argv_i = argv[index];
+ CompilerKit::STLString argv_i = argv[index];
- std::vector<LibCompiler::STLString> exts = kExtListCxx;
+ std::vector<CompilerKit::STLString> exts = kExtListCxx;
- for (LibCompiler::STLString ext : exts) {
+ for (CompilerKit::STLString ext : exts) {
if (argv_i.ends_with(ext)) {
if (kFactory.Compile(argv_i, kMachine) != kExitOK) {
return LIBCOMPILER_INVALID_DATA;
diff --git a/dev/LibCompiler/src/Linker/DynamicLinker64PEF.cc b/dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc
index 698cf61..3fde11b 100644
--- a/dev/LibCompiler/src/Linker/DynamicLinker64PEF.cc
+++ b/dev/CompilerKit/src/Linker/DynamicLinker64PEF.cc
@@ -14,14 +14,14 @@
/// It will be loaded when the program loader will start the image.
-#include <LibCompiler/Defines.h>
-#include <LibCompiler/ErrorID.h>
-#include <LibCompiler/CodeGen.h>
-#include <LibCompiler/PEF.h>
-#include <LibCompiler/UUID.h>
-#include <LibCompiler/Version.h>
-#include <LibCompiler/AE.h>
-#include <LibCompiler/Util/CompilerUtils.h>
+#include <CompilerKit/Defines.h>
+#include <CompilerKit/ErrorID.h>
+#include <CompilerKit/CodeGen.h>
+#include <CompilerKit/PEF.h>
+#include <CompilerKit/UUID.h>
+#include <CompilerKit/Version.h>
+#include <CompilerKit/AE.h>
+#include <CompilerKit/utils/CompilerUtils.h>
#define kLinkerVersionStr \
"NeKernel.org 64-Bit Linker (Preferred Executable Format) %s, (c) Amlal El Mahrouss " \
@@ -56,10 +56,10 @@ enum {
kABITypeInvalid = 0xFFFF,
};
-static LibCompiler::STLString kOutput = "a" kPefExt;
+static CompilerKit::STLString kOutput = "a" kPefExt;
static Int32 kAbi = kABITypeNE;
static Int32 kSubArch = kPefNoSubCpu;
-static Int32 kArch = LibCompiler::kPefArchInvalid;
+static Int32 kArch = CompilerKit::kPefArchInvalid;
static Bool kFatBinaryEnable = false;
static Bool kStartFound = false;
static Bool kDuplicateSymbols = false;
@@ -69,7 +69,7 @@ static const Char* kLdDefineSymbol = ":UndefinedSymbol:";
static const Char* kLdDynamicSym = ":RuntimeSymbol:";
/* object code and list. */
-static std::vector<LibCompiler::STLString> kObjectList;
+static std::vector<CompilerKit::STLString> kObjectList;
static std::vector<Detail::DynamicLinkerBlob> kObjectBytes;
/// @brief NE 64-bit Linker.
@@ -109,27 +109,27 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
continue;
} else if (StringCompare(argv[linker_arg], "-64k") == 0) {
- kArch = LibCompiler::kPefArch64000;
+ kArch = CompilerKit::kPefArch64000;
continue;
} else if (StringCompare(argv[linker_arg], "-amd64") == 0) {
- kArch = LibCompiler::kPefArchAMD64;
+ kArch = CompilerKit::kPefArchAMD64;
continue;
} else if (StringCompare(argv[linker_arg], "-32k") == 0) {
- kArch = LibCompiler::kPefArch32000;
+ kArch = CompilerKit::kPefArch32000;
continue;
} else if (StringCompare(argv[linker_arg], "-power64") == 0) {
- kArch = LibCompiler::kPefArchPowerPC;
+ kArch = CompilerKit::kPefArchPowerPC;
continue;
} else if (StringCompare(argv[linker_arg], "-riscv64") == 0) {
- kArch = LibCompiler::kPefArchRISCV;
+ kArch = CompilerKit::kPefArchRISCV;
continue;
} else if (StringCompare(argv[linker_arg], "-arm64") == 0) {
- kArch = LibCompiler::kPefArchARM64;
+ kArch = CompilerKit::kPefArchARM64;
continue;
} else if (StringCompare(argv[linker_arg], "-verbose") == 0) {
@@ -141,7 +141,7 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
continue;
}
- if (kOutput.find(kPefExt) != LibCompiler::STLString::npos)
+ if (kOutput.find(kPefExt) != CompilerKit::STLString::npos)
kOutput.erase(kOutput.find(kPefExt), strlen(kPefExt));
kOutput += kPefDylibExt;
@@ -189,17 +189,17 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
}
// PEF expects a valid target architecture when outputing a binary.
- if (kArch == LibCompiler::kPefArchInvalid) {
+ if (kArch == CompilerKit::kPefArchInvalid) {
kConsoleOut << "no target architecture set, can't continue." << std::endl;
return LIBCOMPILER_EXEC_ERROR;
}
- LibCompiler::PEFContainer pef_container{};
+ CompilerKit::PEFContainer pef_container{};
int32_t archs = kArch;
pef_container.Count = 0UL;
- pef_container.Kind = is_executable ? LibCompiler::kPefKindExec : LibCompiler::kPefKindDylib;
+ pef_container.Kind = is_executable ? CompilerKit::kPefKindExec : CompilerKit::kPefKindDylib;
pef_container.SubCpu = kSubArch;
pef_container.Linker = kLinkerId; // Amlal El Mahrouss Linker
pef_container.Abi = kAbi; // Multi-Processor UX ABI
@@ -211,7 +211,7 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
// specify the start address, can be 0x10000
pef_container.Start = kLinkerDefaultOrigin;
- pef_container.HdrSz = sizeof(LibCompiler::PEFContainer);
+ pef_container.HdrSz = sizeof(CompilerKit::PEFContainer);
pef_container.Checksum = 0UL;
std::ofstream output_fc(kOutput, std::ofstream::binary);
@@ -226,19 +226,19 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
//! Read AE to convert as PEF.
- std::vector<LibCompiler::PEFCommandHeader> command_headers;
- LibCompiler::Utils::AEReadableProtocol reader_protocol{};
+ std::vector<CompilerKit::PEFCommandHeader> command_headers;
+ CompilerKit::Utils::AEReadableProtocol reader_protocol{};
for (const auto& objectFile : kObjectList) {
if (!std::filesystem::exists(objectFile)) continue;
- LibCompiler::AEHeader hdr{};
+ CompilerKit::AEHeader hdr{};
reader_protocol._Fp = std::ifstream(objectFile, std::ifstream::binary);
reader_protocol._Fp >> hdr;
if (hdr.fMagic[0] == kAEMag0 && hdr.fMagic[1] == kAEMag1 &&
- hdr.fSize == sizeof(LibCompiler::AEHeader)) {
+ hdr.fSize == sizeof(CompilerKit::AEHeader)) {
if (hdr.fArch != kArch) {
if (kVerbose) kConsoleOut << "is this a FAT binary? : ";
@@ -266,33 +266,33 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
pef_container.Count = cnt;
- char_type* raw_ae_records = new char_type[cnt * sizeof(LibCompiler::AERecordHeader)];
+ char_type* raw_ae_records = new char_type[cnt * sizeof(CompilerKit::AERecordHeader)];
if (!raw_ae_records) {
if (kVerbose) kConsoleOut << "allocation failed for records of count: " << cnt << "\n";
}
- std::memset(raw_ae_records, 0, cnt * sizeof(LibCompiler::AERecordHeader));
+ std::memset(raw_ae_records, 0, cnt * sizeof(CompilerKit::AERecordHeader));
auto* ae_records = reader_protocol.Read(raw_ae_records, cnt);
size_t org = kLinkerDefaultOrigin;
for (size_t ae_record_index = 0; ae_record_index < cnt; ++ae_record_index) {
- LibCompiler::PEFCommandHeader command_header{0};
+ CompilerKit::PEFCommandHeader command_header{0};
std::size_t offset_of_obj = ae_records[ae_record_index].fOffset;
MemoryCopy(command_header.Name, ae_records[ae_record_index].fName, kPefNameLen);
- LibCompiler::STLString cmd_hdr_name(command_header.Name);
+ CompilerKit::STLString cmd_hdr_name(command_header.Name);
// check this header if it's any valid.
- if (cmd_hdr_name.find(kPefCode64) == LibCompiler::STLString::npos &&
- cmd_hdr_name.find(kPefData64) == LibCompiler::STLString::npos &&
- cmd_hdr_name.find(kPefZero64) == LibCompiler::STLString::npos) {
- if (cmd_hdr_name.find(kPefStart) == LibCompiler::STLString::npos &&
+ if (cmd_hdr_name.find(kPefCode64) == CompilerKit::STLString::npos &&
+ cmd_hdr_name.find(kPefData64) == CompilerKit::STLString::npos &&
+ cmd_hdr_name.find(kPefZero64) == CompilerKit::STLString::npos) {
+ if (cmd_hdr_name.find(kPefStart) == CompilerKit::STLString::npos &&
*command_header.Name == 0) {
- if (cmd_hdr_name.find(kLdDefineSymbol) != LibCompiler::STLString::npos) {
+ if (cmd_hdr_name.find(kLdDefineSymbol) != CompilerKit::STLString::npos) {
goto ld_mark_header;
} else {
continue;
@@ -300,8 +300,8 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
}
}
- if (cmd_hdr_name.find(kPefStart) != LibCompiler::STLString::npos &&
- cmd_hdr_name.find(kPefCode64) != LibCompiler::STLString::npos) {
+ if (cmd_hdr_name.find(kPefStart) != CompilerKit::STLString::npos &&
+ cmd_hdr_name.find(kPefCode64) != CompilerKit::STLString::npos) {
kStartFound = true;
}
@@ -358,21 +358,21 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
output_fc.seekp(std::streamsize(pef_container.HdrSz));
- std::vector<LibCompiler::STLString> not_found;
- std::vector<LibCompiler::STLString> symbols;
+ std::vector<CompilerKit::STLString> not_found;
+ std::vector<CompilerKit::STLString> symbols;
// step 2: check for errors (multiple symbols, undefined ones)
for (auto& command_hdr : command_headers) {
// check if this symbol needs to be resolved.
- if (LibCompiler::STLString(command_hdr.Name).find(kLdDefineSymbol) !=
- LibCompiler::STLString::npos &&
- LibCompiler::STLString(command_hdr.Name).find(kLdDynamicSym) ==
- LibCompiler::STLString::npos) {
+ if (CompilerKit::STLString(command_hdr.Name).find(kLdDefineSymbol) !=
+ CompilerKit::STLString::npos &&
+ CompilerKit::STLString(command_hdr.Name).find(kLdDynamicSym) ==
+ CompilerKit::STLString::npos) {
if (kVerbose) kConsoleOut << "Found undefined symbol: " << command_hdr.Name << "\n";
if (auto it = std::find(not_found.begin(), not_found.end(),
- LibCompiler::STLString(command_hdr.Name));
+ CompilerKit::STLString(command_hdr.Name));
it == not_found.end()) {
not_found.emplace_back(command_hdr.Name);
}
@@ -385,27 +385,27 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
for (size_t not_found_idx = 0; not_found_idx < command_headers.size(); ++not_found_idx) {
if (const auto it = std::find(not_found.begin(), not_found.end(),
- LibCompiler::STLString(command_headers[not_found_idx].Name));
+ CompilerKit::STLString(command_headers[not_found_idx].Name));
it != not_found.end()) {
- LibCompiler::STLString symbol_imp = *it;
+ CompilerKit::STLString symbol_imp = *it;
- if (symbol_imp.find(kLdDefineSymbol) == LibCompiler::STLString::npos) continue;
+ if (symbol_imp.find(kLdDefineSymbol) == CompilerKit::STLString::npos) continue;
// erase the lookup prefix.
symbol_imp.erase(0, symbol_imp.find(kLdDefineSymbol) + strlen(kLdDefineSymbol));
// demangle everything.
- while (symbol_imp.find('$') != LibCompiler::STLString::npos)
+ while (symbol_imp.find('$') != CompilerKit::STLString::npos)
symbol_imp.erase(symbol_imp.find('$'), 1);
// the reason we do is because, this may not match the symbol, and we need
// to look for other matching symbols.
for (auto& command_hdr : command_headers) {
- if (LibCompiler::STLString(command_hdr.Name).find(symbol_imp) !=
- LibCompiler::STLString::npos &&
- LibCompiler::STLString(command_hdr.Name).find(kLdDefineSymbol) ==
- LibCompiler::STLString::npos) {
- LibCompiler::STLString undefined_symbol = command_hdr.Name;
+ if (CompilerKit::STLString(command_hdr.Name).find(symbol_imp) !=
+ CompilerKit::STLString::npos &&
+ CompilerKit::STLString(command_hdr.Name).find(kLdDefineSymbol) ==
+ CompilerKit::STLString::npos) {
+ CompilerKit::STLString undefined_symbol = command_hdr.Name;
auto result_of_sym = undefined_symbol.substr(undefined_symbol.find(symbol_imp));
for (int i = 0; result_of_sym[i] != 0; ++i) {
@@ -438,37 +438,37 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
// step 4: write all PEF commands.
- LibCompiler::PEFCommandHeader date_cmd_hdr{};
+ CompilerKit::PEFCommandHeader date_cmd_hdr{};
time_t timestamp = time(nullptr);
- LibCompiler::STLString timeStampStr = "Container:BuildEpoch:";
+ CompilerKit::STLString timeStampStr = "Container:BuildEpoch:";
timeStampStr += std::to_string(timestamp);
strncpy(date_cmd_hdr.Name, timeStampStr.c_str(), timeStampStr.size());
date_cmd_hdr.Flags = 0;
- date_cmd_hdr.Kind = LibCompiler::kPefZero;
+ date_cmd_hdr.Kind = CompilerKit::kPefZero;
date_cmd_hdr.Offset = output_fc.tellp();
date_cmd_hdr.Size = timeStampStr.size();
command_headers.push_back(date_cmd_hdr);
- LibCompiler::PEFCommandHeader abi_cmd_hdr{};
+ CompilerKit::PEFCommandHeader abi_cmd_hdr{};
- LibCompiler::STLString abi = kLinkerAbiContainer;
+ CompilerKit::STLString abi = kLinkerAbiContainer;
switch (kArch) {
- case LibCompiler::kPefArchAMD64: {
+ case CompilerKit::kPefArchAMD64: {
abi += "MSFT";
break;
}
- case LibCompiler::kPefArchPowerPC: {
+ case CompilerKit::kPefArchPowerPC: {
abi += "SYSV";
break;
}
- case LibCompiler::kPefArch32000:
- case LibCompiler::kPefArch64000: {
+ case CompilerKit::kPefArch32000:
+ case CompilerKit::kPefArch64000: {
abi += "_NEP";
break;
}
@@ -483,11 +483,11 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
abi_cmd_hdr.Size = abi.size();
abi_cmd_hdr.Offset = output_fc.tellp();
abi_cmd_hdr.Flags = 0;
- abi_cmd_hdr.Kind = LibCompiler::kPefLinkerID;
+ abi_cmd_hdr.Kind = CompilerKit::kPefLinkerID;
command_headers.push_back(abi_cmd_hdr);
- LibCompiler::PEFCommandHeader stack_cmd_hdr{0};
+ CompilerKit::PEFCommandHeader stack_cmd_hdr{0};
stack_cmd_hdr.Cpu = kArch;
stack_cmd_hdr.Flags = 0;
@@ -498,7 +498,7 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
command_headers.push_back(stack_cmd_hdr);
- LibCompiler::PEFCommandHeader uuid_cmd_hdr{};
+ CompilerKit::PEFCommandHeader uuid_cmd_hdr{};
std::random_device rd;
@@ -516,26 +516,26 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
uuid_cmd_hdr.Size = strlen(uuid_cmd_hdr.Name);
uuid_cmd_hdr.Offset = output_fc.tellp();
- uuid_cmd_hdr.Flags = LibCompiler::kPefLinkerID;
- uuid_cmd_hdr.Kind = LibCompiler::kPefZero;
+ uuid_cmd_hdr.Flags = CompilerKit::kPefLinkerID;
+ uuid_cmd_hdr.Kind = CompilerKit::kPefZero;
command_headers.push_back(uuid_cmd_hdr);
// prepare a symbol vector.
- std::vector<LibCompiler::STLString> undef_symbols;
- std::vector<LibCompiler::STLString> dupl_symbols;
- std::vector<LibCompiler::STLString> resolve_symbols;
+ std::vector<CompilerKit::STLString> undef_symbols;
+ std::vector<CompilerKit::STLString> dupl_symbols;
+ std::vector<CompilerKit::STLString> resolve_symbols;
constexpr Int32 kPaddingOffset = 16;
size_t previous_offset =
- (command_headers.size() * sizeof(LibCompiler::PEFCommandHeader)) + kPaddingOffset;
+ (command_headers.size() * sizeof(CompilerKit::PEFCommandHeader)) + kPaddingOffset;
- LibCompiler::PEFCommandHeader end_exec_hdr;
+ CompilerKit::PEFCommandHeader end_exec_hdr;
end_exec_hdr.Offset = output_fc.tellp();
- end_exec_hdr.Flags = LibCompiler::kPefLinkerID;
- end_exec_hdr.Kind = LibCompiler::kPefZero;
+ end_exec_hdr.Flags = CompilerKit::kPefLinkerID;
+ end_exec_hdr.Kind = CompilerKit::kPefZero;
MemoryCopy(end_exec_hdr.Name, "Container:Exec:END", strlen("Container:Exec:END"));
@@ -547,15 +547,15 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
// And check for any duplications
for (size_t commandHeaderIndex = 0UL; commandHeaderIndex < command_headers.size();
++commandHeaderIndex) {
- if (LibCompiler::STLString(command_headers[commandHeaderIndex].Name).find(kLdDefineSymbol) !=
- LibCompiler::STLString::npos &&
- LibCompiler::STLString(command_headers[commandHeaderIndex].Name).find(kLdDynamicSym) ==
- LibCompiler::STLString::npos) {
+ if (CompilerKit::STLString(command_headers[commandHeaderIndex].Name).find(kLdDefineSymbol) !=
+ CompilerKit::STLString::npos &&
+ CompilerKit::STLString(command_headers[commandHeaderIndex].Name).find(kLdDynamicSym) ==
+ CompilerKit::STLString::npos) {
// ignore :UndefinedSymbol: headers, they do not contain code.
continue;
}
- LibCompiler::STLString symbol_name = command_headers[commandHeaderIndex].Name;
+ CompilerKit::STLString symbol_name = command_headers[commandHeaderIndex].Name;
if (!symbol_name.empty()) {
undef_symbols.emplace_back(symbol_name);
@@ -564,13 +564,13 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
command_headers[commandHeaderIndex].Offset += previous_offset;
previous_offset += command_headers[commandHeaderIndex].Size;
- LibCompiler::STLString name = command_headers[commandHeaderIndex].Name;
+ CompilerKit::STLString name = command_headers[commandHeaderIndex].Name;
/// so this is valid when we get to the entrypoint.
/// it is always a code64 container. And should equal to kPefStart as well.
/// this chunk of code updates the pef_container.Start with the updated offset.
- if (name.find(kPefStart) != LibCompiler::STLString::npos &&
- name.find(kPefCode64) != LibCompiler::STLString::npos) {
+ if (name.find(kPefStart) != CompilerKit::STLString::npos &&
+ name.find(kPefCode64) != CompilerKit::STLString::npos) {
pef_container.Start = command_headers[commandHeaderIndex].Offset;
auto tellCurPos = output_fc.tellp();
@@ -592,10 +592,10 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
++sub_command_header_index) {
if (sub_command_header_index == commandHeaderIndex) continue;
- if (LibCompiler::STLString(command_headers[sub_command_header_index].Name)
- .find(kLdDefineSymbol) != LibCompiler::STLString::npos &&
- LibCompiler::STLString(command_headers[sub_command_header_index].Name)
- .find(kLdDynamicSym) == LibCompiler::STLString::npos) {
+ if (CompilerKit::STLString(command_headers[sub_command_header_index].Name)
+ .find(kLdDefineSymbol) != CompilerKit::STLString::npos &&
+ CompilerKit::STLString(command_headers[sub_command_header_index].Name)
+ .find(kLdDynamicSym) == CompilerKit::STLString::npos) {
if (kVerbose) {
kConsoleOut << "Ignoring :UndefinedSymbol: headers...\n";
}
@@ -606,7 +606,7 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
auto& command_hdr = command_headers[sub_command_header_index];
- if (command_hdr.Name == LibCompiler::STLString(command_headers[commandHeaderIndex].Name)) {
+ if (command_hdr.Name == CompilerKit::STLString(command_headers[commandHeaderIndex].Name)) {
if (std::find(dupl_symbols.cbegin(), dupl_symbols.cend(), command_hdr.Name) ==
dupl_symbols.cend()) {
dupl_symbols.emplace_back(command_hdr.Name);
@@ -639,11 +639,11 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
// step 3: check if we have those symbols
- std::vector<LibCompiler::STLString> unreferenced_symbols;
+ std::vector<CompilerKit::STLString> unreferenced_symbols;
for (auto& command_hdr : command_headers) {
if (auto it =
- std::find(not_found.begin(), not_found.end(), LibCompiler::STLString(command_hdr.Name));
+ std::find(not_found.begin(), not_found.end(), CompilerKit::STLString(command_hdr.Name));
it != not_found.end()) {
unreferenced_symbols.emplace_back(command_hdr.Name);
}
diff --git a/dev/LibCompiler/src/Macro/CPlusPlusCompilerPreProcessor.cc b/dev/CompilerKit/src/Macro/CPlusPlusCompilerPreProcessor.cc
index 0aea1c7..12a69c8 100644
--- a/dev/LibCompiler/src/Macro/CPlusPlusCompilerPreProcessor.cc
+++ b/dev/CompilerKit/src/Macro/CPlusPlusCompilerPreProcessor.cc
@@ -9,8 +9,8 @@
/// BUGS: 0
-#include <LibCompiler/ErrorID.h>
-#include <LibCompiler/Frontend.h>
+#include <CompilerKit/ErrorID.h>
+#include <CompilerKit/Frontend.h>
#include <algorithm>
#include <filesystem>
#include <fstream>
@@ -24,7 +24,7 @@
/// @file bpp.cxx
/// @brief Preprocessor.
-typedef Int32 (*bpp_parser_fn_t)(LibCompiler::STLString& line, std::ifstream& hdr_file,
+typedef Int32 (*bpp_parser_fn_t)(CompilerKit::STLString& line, std::ifstream& hdr_file,
std::ofstream& pp_out);
/////////////////////////////////////////////////////////////////////////////////////////
@@ -47,7 +47,7 @@ enum {
struct bpp_macro_condition final {
int32_t fType;
- LibCompiler::STLString fTypeName;
+ CompilerKit::STLString fTypeName;
void Print() {
std::cout << "type: " << fType << "\n";
@@ -56,9 +56,9 @@ struct bpp_macro_condition final {
};
struct bpp_macro final {
- std::vector<LibCompiler::STLString> fArgs;
- LibCompiler::STLString fName;
- LibCompiler::STLString fValue;
+ std::vector<CompilerKit::STLString> fArgs;
+ CompilerKit::STLString fName;
+ CompilerKit::STLString fValue;
void Print() {
std::cout << "name: " << fName << "\n";
@@ -71,11 +71,11 @@ struct bpp_macro final {
};
} // namespace Detail
-static std::vector<LibCompiler::STLString> kFiles;
+static std::vector<CompilerKit::STLString> kFiles;
static std::vector<Detail::bpp_macro> kMacros;
-static std::vector<LibCompiler::STLString> kIncludes;
+static std::vector<CompilerKit::STLString> kIncludes;
-static LibCompiler::STLString kWorkingDir = "";
+static CompilerKit::STLString kWorkingDir = "";
/////////////////////////////////////////////////////////////////////////////////////////
@@ -86,11 +86,11 @@ static LibCompiler::STLString kWorkingDir = "";
int32_t bpp_parse_if_condition(Detail::bpp_macro_condition& cond, Detail::bpp_macro& macro,
bool& inactive_code, bool& defined,
- LibCompiler::STLString& macro_str) {
+ CompilerKit::STLString& macro_str) {
if (cond.fType == Detail::kEqual) {
auto substr_macro = macro_str.substr(macro_str.find(macro.fName) + macro.fName.size());
- if (substr_macro.find(macro.fValue) != LibCompiler::STLString::npos) {
+ if (substr_macro.find(macro.fValue) != CompilerKit::STLString::npos) {
if (macro.fValue == "0") {
defined = false;
inactive_code = true;
@@ -106,8 +106,8 @@ int32_t bpp_parse_if_condition(Detail::bpp_macro_condition& cond, Detail::bpp_ma
} else if (cond.fType == Detail::kNotEqual) {
auto substr_macro = macro_str.substr(macro_str.find(macro.fName) + macro.fName.size());
- if (substr_macro.find(macro.fName) != LibCompiler::STLString::npos) {
- if (substr_macro.find(macro.fValue) != LibCompiler::STLString::npos) {
+ if (substr_macro.find(macro.fName) != CompilerKit::STLString::npos) {
+ if (substr_macro.find(macro.fValue) != CompilerKit::STLString::npos) {
defined = false;
inactive_code = true;
@@ -125,10 +125,10 @@ int32_t bpp_parse_if_condition(Detail::bpp_macro_condition& cond, Detail::bpp_ma
auto substr_macro = macro_str.substr(macro_str.find(macro.fName) + macro.fName.size());
- LibCompiler::STLString number;
+ CompilerKit::STLString number;
for (auto& macro_num : kMacros) {
- if (substr_macro.find(macro_num.fName) != LibCompiler::STLString::npos) {
+ if (substr_macro.find(macro_num.fName) != CompilerKit::STLString::npos) {
for (size_t i = 0; i < macro_num.fName.size(); ++i) {
if (isdigit(macro_num.fValue[i])) {
number += macro_num.fValue[i];
@@ -232,7 +232,7 @@ int32_t bpp_parse_if_condition(Detail::bpp_macro_condition& cond, Detail::bpp_ma
/////////////////////////////////////////////////////////////////////////////////////////
-std::vector<LibCompiler::STLString> kAllIncludes;
+std::vector<CompilerKit::STLString> kAllIncludes;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -242,8 +242,8 @@ std::vector<LibCompiler::STLString> kAllIncludes;
/////////////////////////////////////////////////////////////////////////////////////////
void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
- LibCompiler::STLString hdr_line;
- LibCompiler::STLString line_after_include;
+ CompilerKit::STLString hdr_line;
+ CompilerKit::STLString line_after_include;
bool inactive_code = false;
bool defined = false;
@@ -251,26 +251,26 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
try {
while (std::getline(hdr_file, hdr_line)) {
if (inactive_code) {
- if (hdr_line.find("#endif") == LibCompiler::STLString::npos) {
+ if (hdr_line.find("#endif") == CompilerKit::STLString::npos) {
continue;
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("#endif") != LibCompiler::STLString::npos) {
+ hdr_line.find("#endif") != CompilerKit::STLString::npos) {
inactive_code = false;
}
}
- if (hdr_line.find("*/") != LibCompiler::STLString::npos) {
+ if (hdr_line.find("*/") != CompilerKit::STLString::npos) {
hdr_line.erase(hdr_line.find("*/"), strlen("*/"));
}
- if (hdr_line.find("/*") != LibCompiler::STLString::npos) {
+ if (hdr_line.find("/*") != CompilerKit::STLString::npos) {
inactive_code = true;
// get rid of comment.
hdr_line.erase(hdr_line.find("/*"));
}
- if (hdr_line[0] == kMacroPrefix && hdr_line.find("endif") != LibCompiler::STLString::npos) {
+ if (hdr_line[0] == kMacroPrefix && hdr_line.find("endif") != CompilerKit::STLString::npos) {
if (!defined && inactive_code) {
inactive_code = false;
defined = false;
@@ -290,19 +290,19 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
}
for (auto macro : kMacros) {
- if (LibCompiler::find_word(hdr_line, macro.fName)) {
+ if (CompilerKit::find_word(hdr_line, macro.fName)) {
if (hdr_line.substr(hdr_line.find(macro.fName)).find(macro.fName + '(') !=
- LibCompiler::STLString::npos) {
+ CompilerKit::STLString::npos) {
if (!macro.fArgs.empty()) {
- LibCompiler::STLString symbol_val = macro.fValue;
- std::vector<LibCompiler::STLString> args;
+ CompilerKit::STLString symbol_val = macro.fValue;
+ std::vector<CompilerKit::STLString> args;
size_t x_arg_indx = 0;
- LibCompiler::STLString line_after_define = hdr_line;
- LibCompiler::STLString str_arg;
+ CompilerKit::STLString line_after_define = hdr_line;
+ CompilerKit::STLString str_arg;
- if (line_after_define.find("(") != LibCompiler::STLString::npos) {
+ if (line_after_define.find("(") != CompilerKit::STLString::npos) {
line_after_define.erase(0, line_after_define.find("(") + 1);
for (auto& subc : line_after_define) {
@@ -323,7 +323,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
}
for (auto arg : macro.fArgs) {
- if (symbol_val.find(macro.fArgs[x_arg_indx]) != LibCompiler::STLString::npos) {
+ if (symbol_val.find(macro.fArgs[x_arg_indx]) != CompilerKit::STLString::npos) {
symbol_val.replace(symbol_val.find(macro.fArgs[x_arg_indx]),
macro.fArgs[x_arg_indx].size(), args[x_arg_indx]);
++x_arg_indx;
@@ -349,15 +349,15 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
}
}
- if (hdr_line[0] == kMacroPrefix && hdr_line.find("define ") != LibCompiler::STLString::npos) {
+ if (hdr_line[0] == kMacroPrefix && hdr_line.find("define ") != CompilerKit::STLString::npos) {
auto line_after_define = hdr_line.substr(hdr_line.find("define ") + strlen("define "));
- LibCompiler::STLString macro_value;
- LibCompiler::STLString macro_key;
+ CompilerKit::STLString macro_value;
+ CompilerKit::STLString macro_key;
std::size_t pos = 0UL;
- std::vector<LibCompiler::STLString> args;
+ std::vector<CompilerKit::STLString> args;
bool on_args = false;
for (auto& ch : line_after_define) {
@@ -388,9 +388,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
macro_key += ch;
}
- LibCompiler::STLString str;
+ CompilerKit::STLString str;
- if (line_after_define.find("(") != LibCompiler::STLString::npos) {
+ if (line_after_define.find("(") != CompilerKit::STLString::npos) {
line_after_define.erase(0, line_after_define.find("(") + 1);
for (auto& subc : line_after_define) {
@@ -429,9 +429,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
continue;
}
- if (hdr_line[0] == kMacroPrefix && hdr_line.find("ifndef") != LibCompiler::STLString::npos) {
+ if (hdr_line[0] == kMacroPrefix && hdr_line.find("ifndef") != CompilerKit::STLString::npos) {
auto line_after_ifndef = hdr_line.substr(hdr_line.find("ifndef") + strlen("ifndef") + 1);
- LibCompiler::STLString macro;
+ CompilerKit::STLString macro;
for (auto& ch : line_after_ifndef) {
if (ch == ' ') {
@@ -460,7 +460,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
inactive_code = false;
for (auto& macro_ref : kMacros) {
- if (hdr_line.find(macro_ref.fName) != LibCompiler::STLString::npos) {
+ if (hdr_line.find(macro_ref.fName) != CompilerKit::STLString::npos) {
found = true;
break;
}
@@ -473,7 +473,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
continue;
}
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("else") != LibCompiler::STLString::npos) {
+ hdr_line.find("else") != CompilerKit::STLString::npos) {
if (!defined && inactive_code) {
inactive_code = false;
defined = true;
@@ -486,9 +486,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
continue;
}
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("ifdef") != LibCompiler::STLString::npos) {
+ hdr_line.find("ifdef") != CompilerKit::STLString::npos) {
auto line_after_ifdef = hdr_line.substr(hdr_line.find("ifdef") + strlen("ifdef") + 1);
- LibCompiler::STLString macro;
+ CompilerKit::STLString macro;
for (auto& ch : line_after_ifdef) {
if (ch == ' ') {
@@ -516,7 +516,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
inactive_code = true;
for (auto& macro_ref : kMacros) {
- if (hdr_line.find(macro_ref.fName) != LibCompiler::STLString::npos) {
+ if (hdr_line.find(macro_ref.fName) != CompilerKit::STLString::npos) {
defined = true;
inactive_code = false;
@@ -524,7 +524,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
}
}
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("if") != LibCompiler::STLString::npos) {
+ hdr_line.find("if") != CompilerKit::STLString::npos) {
inactive_code = true;
std::vector<Detail::bpp_macro_condition> bpp_macro_condition_list = {
@@ -557,9 +557,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
int32_t good_to_go = 0;
for (auto& macro_condition : bpp_macro_condition_list) {
- if (hdr_line.find(macro_condition.fTypeName) != LibCompiler::STLString::npos) {
+ if (hdr_line.find(macro_condition.fTypeName) != CompilerKit::STLString::npos) {
for (auto& found_macro : kMacros) {
- if (hdr_line.find(found_macro.fName) != LibCompiler::STLString::npos) {
+ if (hdr_line.find(found_macro.fName) != CompilerKit::STLString::npos) {
good_to_go = bpp_parse_if_condition(macro_condition, found_macro, inactive_code,
defined, hdr_line);
@@ -572,7 +572,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
if (good_to_go) continue;
auto line_after_if = hdr_line.substr(hdr_line.find("if") + strlen("if") + 1);
- LibCompiler::STLString macro;
+ CompilerKit::STLString macro;
for (auto& ch : line_after_if) {
if (ch == ' ') {
@@ -597,7 +597,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
// last try, is it defined to be one?
for (auto& macro_ref : kMacros) {
- if (macro_ref.fName.find(macro) != LibCompiler::STLString::npos &&
+ if (macro_ref.fName.find(macro) != CompilerKit::STLString::npos &&
macro_ref.fValue == "1") {
inactive_code = false;
defined = true;
@@ -606,9 +606,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
}
}
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("warning") != LibCompiler::STLString::npos) {
+ hdr_line.find("warning") != CompilerKit::STLString::npos) {
auto line_after_warning = hdr_line.substr(hdr_line.find("warning") + strlen("warning") + 1);
- LibCompiler::STLString message;
+ CompilerKit::STLString message;
for (auto& ch : line_after_warning) {
if (ch == '\r' || ch == '\n') {
@@ -620,9 +620,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
std::cout << "warn: " << message << std::endl;
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("error") != LibCompiler::STLString::npos) {
+ hdr_line.find("error") != CompilerKit::STLString::npos) {
auto line_after_warning = hdr_line.substr(hdr_line.find("error") + strlen("error") + 1);
- LibCompiler::STLString message;
+ CompilerKit::STLString message;
for (auto& ch : line_after_warning) {
if (ch == '\r' || ch == '\n') {
@@ -634,7 +634,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
throw std::runtime_error("error: " + message);
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("include ") != LibCompiler::STLString::npos) {
+ hdr_line.find("include ") != CompilerKit::STLString::npos) {
line_after_include = hdr_line.substr(hdr_line.find("include ") + strlen("include "));
kIncludeFile:
@@ -644,7 +644,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
continue;
}
- LibCompiler::STLString path;
+ CompilerKit::STLString path;
kAllIncludes.push_back(line_after_include);
@@ -684,7 +684,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
}
for (auto& include : kIncludes) {
- LibCompiler::STLString header_path = include;
+ CompilerKit::STLString header_path = include;
header_path.push_back('/');
header_path += path;
@@ -823,7 +823,7 @@ LIBCOMPILER_MODULE(CPlusPlusPreprocessorMain) {
}
if (strcmp(argv[index], "-cpp-include-dir") == 0) {
- LibCompiler::STLString inc = argv[index + 1];
+ CompilerKit::STLString inc = argv[index + 1];
skip = true;
@@ -831,16 +831,16 @@ LIBCOMPILER_MODULE(CPlusPlusPreprocessorMain) {
}
if (strcmp(argv[index], "-cpp-working-dir") == 0) {
- LibCompiler::STLString inc = argv[index + 1];
+ CompilerKit::STLString inc = argv[index + 1];
skip = true;
kWorkingDir = inc;
}
if (strcmp(argv[index], "-cpp-def") == 0 && argv[index + 1] != nullptr &&
argv[index + 2] != nullptr) {
- LibCompiler::STLString macro_key = argv[index + 1];
+ CompilerKit::STLString macro_key = argv[index + 1];
- LibCompiler::STLString macro_value;
+ CompilerKit::STLString macro_value;
bool is_string = false;
for (int argv_find_len = 0; argv_find_len < strlen(argv[index]); ++argv_find_len) {
diff --git a/dev/LibCompiler/Util/AsmUtils.h b/dev/CompilerKit/utils/AsmUtils.h
index f176eda..f74fb1b 100644
--- a/dev/LibCompiler/Util/AsmUtils.h
+++ b/dev/CompilerKit/utils/AsmUtils.h
@@ -6,12 +6,12 @@
#pragma once
-#include <LibCompiler/CodeGen.h>
-#include <LibCompiler/Frontend.h>
+#include <CompilerKit/CodeGen.h>
+#include <CompilerKit/Frontend.h>
-#include <LibCompiler/Util/CompilerUtils.h>
+#include <CompilerKit/utils/CompilerUtils.h>
-using namespace LibCompiler;
+using namespace CompilerKit;
/// @brief Get Number from lineBuffer.
/// @param lineBuffer the lineBuffer to fetch from.
@@ -28,7 +28,7 @@ static NumberCast32 GetNumber32(std::string lineBuffer, std::string 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, "LibCompiler");
+ Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit");
throw std::runtime_error("invalid_hex");
}
}
@@ -44,7 +44,7 @@ static NumberCast32 GetNumber32(std::string lineBuffer, std::string 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, "LibCompiler");
+ Detail::print_error("invalid binary number:" + lineBuffer, "CompilerKit");
throw std::runtime_error("invalid_bin");
}
}
@@ -60,7 +60,7 @@ static NumberCast32 GetNumber32(std::string lineBuffer, std::string 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, "LibCompiler");
+ Detail::print_error("invalid octal number: " + lineBuffer, "CompilerKit");
throw std::runtime_error("invalid_octal");
}
}
@@ -76,7 +76,7 @@ static NumberCast32 GetNumber32(std::string lineBuffer, std::string numberKey) {
default: {
if (auto res = strtol(lineBuffer.substr(pos).c_str(), nullptr, 10); !res) {
if (errno != 0) {
- Detail::print_error("invalid hex number: " + lineBuffer, "LibCompiler");
+ Detail::print_error("invalid hex number: " + lineBuffer, "CompilerKit");
throw std::runtime_error("invalid_hex");
}
}
diff --git a/dev/LibCompiler/Util/CompilerUtils.h b/dev/CompilerKit/utils/CompilerUtils.h
index 172907a..da35b2b 100644
--- a/dev/LibCompiler/Util/CompilerUtils.h
+++ b/dev/CompilerKit/utils/CompilerUtils.h
@@ -6,11 +6,11 @@
#pragma once
-#include <LibCompiler/CodeGen.h>
-#include <LibCompiler/ErrorID.h>
-#include <LibCompiler/Frontend.h>
-#include <LibCompiler/Version.h>
-#include <Vendor/Dialogs.h>
+#include <CompilerKit/CodeGen.h>
+#include <CompilerKit/ErrorID.h>
+#include <CompilerKit/Frontend.h>
+#include <CompilerKit/Version.h>
+#include <ThirdParty/Dialogs.h>
#include <iostream>
#define kZero64Section ".zero64"
@@ -60,10 +60,10 @@ inline void print_warning(std::string reason, std::string file) noexcept {
/// @internal
/// @brief Handler for SIGSEGV signal.
inline void drvi_crash_handler(std::int32_t id) {
- LibCompiler::STLString verbose_header = "LIBCOMPILER CRASH REPORT - ";
+ CompilerKit::STLString verbose_header = "LIBCOMPILER CRASH REPORT - ";
verbose_header += kDistVersion;
verbose_header += " - ";
- verbose_header += LibCompiler::current_date();
+ verbose_header += CompilerKit::current_date();
for (auto& ch : verbose_header) {
std::cout << '=';
@@ -79,7 +79,7 @@ inline void drvi_crash_handler(std::int32_t id) {
std::cout << std::endl;
- kStdOut << "DATE: " << LibCompiler::current_date() << std::endl;
+ kStdOut << "DATE: " << CompilerKit::current_date() << std::endl;
kStdOut << "VERSION: " << kDistVersion << std::endl;
kStdOut << "ERRNO: " << errno << std::endl;
kStdOut << "ERRNO(STRING): " << strerror(errno) << std::endl;
diff --git a/dev/LibCompiler/Util/DylibHelpers.h b/dev/CompilerKit/utils/DylibHelpers.h
index 901d321..1ae7c03 100644
--- a/dev/LibCompiler/Util/DylibHelpers.h
+++ b/dev/CompilerKit/utils/DylibHelpers.h
@@ -6,8 +6,8 @@
#pragma once
-#include <LibCompiler/Defines.h>
+#include <CompilerKit/Defines.h>
#include <dlfcn.h>
-typedef Int32 (*LibCompilerEntrypoint)(Int32 argc, Char const* argv[]);
-typedef VoidPtr LibCompilerDylib;
+typedef Int32 (*CompilerKitEntrypoint)(Int32 argc, Char const* argv[]);
+typedef VoidPtr CompilerKitDylib;
diff --git a/dev/LibDebugger/CommonCLI.inl b/dev/DebuggerKit/CommonCLI.inl
index 0b07271..325be23 100644
--- a/dev/LibDebugger/CommonCLI.inl
+++ b/dev/DebuggerKit/CommonCLI.inl
@@ -1,10 +1,14 @@
/***
- LibDebugger
+ DebuggerKit
(C) 2025 Amlal El Mahrouss
File: CommonCLI.inl
Purpose: Common Debugger symbols.
*/
+#include <cstdint>
+#include <iostream>
+#include <string>
+
#define kBlank "\e[0;30m"
#define kRed "\e[0;31m"
#define kWhite "\e[0;97m"
@@ -14,11 +18,11 @@
static BOOL kKeepRunning = false;
#ifdef LD_NEKERNEL_DEBUGGER
-static LibDebugger::NeKernel::NeKernelContract kKernelDebugger;
+static DebuggerKit::NeKernel::NeKernelContract kKernelDebugger;
#else
-static LibDebugger::POSIX::POSIXMachContract kDebugger;
+static DebuggerKit::POSIX::POSIXMachContract kDebugger;
#endif
-static LibDebugger::ProcessID kPID = 0L;
-static LibDebugger::CAddress kActiveAddress = nullptr;
+static DebuggerKit::ProcessID kPID = 0L;
+static DebuggerKit::CAddress kActiveAddress = nullptr;
static std::string kPath = "";
diff --git a/dev/LibDebugger/DebuggerContract.h b/dev/DebuggerKit/DebuggerContract.h
index c9b269f..48c3603 100644
--- a/dev/LibDebugger/DebuggerContract.h
+++ b/dev/DebuggerKit/DebuggerContract.h
@@ -8,7 +8,7 @@
#include <string>
#include <unordered_map>
-namespace LibDebugger {
+namespace DebuggerKit {
class DebuggerContract;
/// \brief Process ID
@@ -41,4 +41,4 @@ class DebuggerContract {
ProcessID m_pid;
std::unordered_map<uintptr_t, uintptr_t> m_breakpoints;
};
-} // namespace LibDebugger
+} // namespace DebuggerKit
diff --git a/dev/LibDebugger/NeKernelContract.h b/dev/DebuggerKit/NeKernelContract.h
index 9f816d8..9797639 100644
--- a/dev/LibDebugger/NeKernelContract.h
+++ b/dev/DebuggerKit/NeKernelContract.h
@@ -8,9 +8,9 @@
#ifdef LD_NEKERNEL_DEBUGGER
-#include <LibDebugger/DebuggerContract.h>
+#include <DebuggerKit/DebuggerContract.h>
-namespace LibDebugger::NeKernel {
+namespace DebuggerKit::NeKernel {
class NeKernelContract;
namespace Detail {
@@ -40,7 +40,7 @@ class NeKernelContract : public DebuggerContract {
std::string m_kernel_path;
int64_t m_socket{0};
};
-} // namespace LibDebugger::NeKernel
+} // namespace DebuggerKit::NeKernel
#endif // ifdef LD_NEKERNEL_DEBUGGER
diff --git a/dev/LibDebugger/POSIXMachContract.h b/dev/DebuggerKit/POSIXMachContract.h
index 98085a2..a2c49ce 100644
--- a/dev/LibDebugger/POSIXMachContract.h
+++ b/dev/DebuggerKit/POSIXMachContract.h
@@ -9,8 +9,8 @@
/// @file POSIXMachContract.h
/// @brief POSIX Mach debugger.
-#include <LibCompiler/Defines.h>
-#include <LibDebugger/DebuggerContract.h>
+#include <CompilerKit/Defines.h>
+#include <DebuggerKit/DebuggerContract.h>
#include <stdint.h>
#include <sys/ptrace.h>
@@ -41,7 +41,7 @@ LC_IMPORT_C kern_return_t mach_vm_protect(vm_map_t target_task, mach_vm_address_
#define PTRACE_CONT PT_CONTINUE
#define PTRACE_PEEKTEXT PT_READ_I
-namespace LibDebugger::POSIX {
+namespace DebuggerKit::POSIX {
/// \brief POSIXMachContract engine interface class in C++
/// \author Amlal El Mahrouss
class POSIXMachContract : public DebuggerContract {
@@ -153,6 +153,6 @@ class POSIXMachContract : public DebuggerContract {
ProcessID m_pid{0};
std::string m_path;
};
-} // namespace LibDebugger::POSIX
+} // namespace DebuggerKit::POSIX
#endif
diff --git a/dev/LibDebugger/Version.h b/dev/DebuggerKit/Version.h
index 4159191..4159191 100644
--- a/dev/LibDebugger/Version.h
+++ b/dev/DebuggerKit/Version.h
diff --git a/dev/DebuggerKit/ld-nekernel.json b/dev/DebuggerKit/ld-nekernel.json
new file mode 100644
index 0000000..d2aeb24
--- /dev/null
+++ b/dev/DebuggerKit/ld-nekernel.json
@@ -0,0 +1,17 @@
+{
+ "compiler_path": "g++",
+ "compiler_std": "c++20",
+ "headers_path": [
+ "../DebuggerKit",
+ "../"
+ ],
+ "sources_path": ["src/*.cc"],
+ "output_name": "/usr/local/lib/libDebuggerKit.dylib",
+ "compiler_flags": ["-fPIC", "-shared"],
+ "cpp_macros": [
+ "__LIBCOMPILER__=202505",
+ "LC_USE_STRUCTS=1",
+ "LD_NEKERNEL_DEBUGGER",
+ "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
+ ]
+}
diff --git a/dev/DebuggerKit/ld-osx.json b/dev/DebuggerKit/ld-osx.json
new file mode 100644
index 0000000..75b6cd8
--- /dev/null
+++ b/dev/DebuggerKit/ld-osx.json
@@ -0,0 +1,17 @@
+{
+ "compiler_path": "clang++",
+ "compiler_std": "c++20",
+ "headers_path": [
+ "../DebuggerKit",
+ "../"
+ ],
+ "sources_path": ["src/*.cc"],
+ "output_name": "/usr/local/lib/libDebuggerKit.dylib",
+ "compiler_flags": ["-fPIC", "-shared"],
+ "cpp_macros": [
+ "__LIBCOMPILER__=202505",
+ "LC_USE_STRUCTS=1",
+ "LD_MACH_DEBUGGER",
+ "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
+ ]
+}
diff --git a/dev/LibDebugger/src/NeKernelContract.cc b/dev/DebuggerKit/src/NeKernelContract.cc
index 2c2543e..d7a0393 100644
--- a/dev/LibDebugger/src/NeKernelContract.cc
+++ b/dev/DebuggerKit/src/NeKernelContract.cc
@@ -1,5 +1,5 @@
/***
- LibDebugger
+ DebuggerKit
(C) 2025 Amlal El Mahrouss
File: NeKernelContract.cc
Purpose: NeKernel Debugger
@@ -7,9 +7,9 @@
#ifdef LD_NEKERNEL_DEBUGGER
-#include <LibCompiler/Defines.h>
-#include <LibDebugger/NeKernelContract.h>
-#include <Vendor/Dialogs.h>
+#include <CompilerKit/Defines.h>
+#include <DebuggerKit/NeKernelContract.h>
+#include <ThirdParty/Dialogs.h>
#include <sys/socket.h>
#include <sys/types.h>
@@ -18,18 +18,18 @@
constexpr static UInt16 kDebugPort = 51820;
-using namespace LibDebugger::NeKernel;
+using namespace DebuggerKit::NeKernel;
NeKernelContract::NeKernelContract() = default;
NeKernelContract::~NeKernelContract() = default;
-BOOL NeKernelContract::Attach(LibCompiler::STLString path, LibCompiler::STLString argv,
+BOOL NeKernelContract::Attach(CompilerKit::STLString path, CompilerKit::STLString argv,
ProcessID& pid) noexcept {
return NO;
}
-BOOL NeKernelContract::BreakAt(LibCompiler::STLString symbol) noexcept {
+BOOL NeKernelContract::BreakAt(CompilerKit::STLString symbol) noexcept {
return NO;
}
diff --git a/dev/LibDebugger/src/NeKernelContractCLI.cc b/dev/DebuggerKit/src/NeKernelContractCLI.cc
index 25e9c13..9d078c8 100644
--- a/dev/LibDebugger/src/NeKernelContractCLI.cc
+++ b/dev/DebuggerKit/src/NeKernelContractCLI.cc
@@ -1,5 +1,5 @@
/***
- LibDebugger
+ DebuggerKit
(C) 2025 Amlal El Mahrouss
File: NeKernelContract.cc
Purpose: NeKernel Debugger CLI.
@@ -7,14 +7,14 @@
#ifdef LD_NEKERNEL_DEBUGGER
-#include <LibCompiler/Defines.h>
-#include <LibDebugger/NeKernelContract.h>
-#include <Vendor/Dialogs.h>
+#include <CompilerKit/Defines.h>
+#include <DebuggerKit/NeKernelContract.h>
+#include <ThirdParty/Dialogs.h>
#include <string>
-#include <LibDebugger/CommonCLI.inl>
+#include <DebuggerKit/CommonCLI.inl>
-using namespace LibDebugger::NeKernel;
+using namespace DebuggerKit::NeKernel;
static void dbgi_ctrlc_handler(std::int32_t _) {
if (!kPID || kPath.empty()) {
@@ -23,14 +23,14 @@ static void dbgi_ctrlc_handler(std::int32_t _) {
kKernelDebugger.Break();
- pfd::notify("Debugger Event", "BreakAt hit!");
+ pfd::notify("Debugger Event", "Breakpoint hit!");
kKeepRunning = false;
}
LIBCOMPILER_MODULE(DebuggerNeKernel) {
pfd::notify("Debugger Event",
- "Kernel Debugger\n(C) 2025 Amlal El Mahrouss, all rights reserved.");
+ "NeKernel Debugger\n(C) 2025 Amlal El Mahrouss and NeKernel.org contributors, all rights reserved.");
if (argc >= 5 && std::string(argv[1]) == "-k" && argv[2] != nullptr &&
std::string(argv[3]) == "-ip" && argv[4] != nullptr) {
@@ -40,7 +40,7 @@ LIBCOMPILER_MODULE(DebuggerNeKernel) {
kStdOut << "[+] KIP (Kernel:IP) set to: " << kPath << "\n";
- LibCompiler::install_signal(SIGINT, dbgi_ctrlc_handler);
+ CompilerKit::install_signal(SIGINT, dbgi_ctrlc_handler);
kKernelDebugger.Attach(kPath, "", kPID);
kKernelDebugger.BreakAt("$HANDOVER_START");
@@ -92,8 +92,8 @@ LIBCOMPILER_MODULE(DebuggerNeKernel) {
return EXIT_SUCCESS;
}
- kStdOut << "Usage: " << argv[0] << " -k <kernel_path> -ip <ip4>\n";
- kStdOut << "Example: " << argv[0] << " -k /path/to/ne_kernel -ip 127.0.0.1\n";
+ kStdOut << "usage: " << argv[0] << " -k <kernel_path> -ip <ip4>\n";
+ kStdOut << "example: " << argv[0] << " -k /path/to/ne_kernel -ip 127.0.0.1\n";
return EXIT_FAILURE;
}
diff --git a/dev/LibDebugger/src/POSIXMachContractCLI.cc b/dev/DebuggerKit/src/POSIXMachContractCLI.cc
index 0962ba6..11c05f8 100644
--- a/dev/LibDebugger/src/POSIXMachContractCLI.cc
+++ b/dev/DebuggerKit/src/POSIXMachContractCLI.cc
@@ -1,5 +1,5 @@
/***
- LibDebugger
+ DebuggerKit
(C) 2025 Amlal El Mahrouss
File: POSIXMachContract.cc
Purpose: OS X/Darwin Debugger
@@ -7,14 +7,10 @@
#ifdef LD_MACH_DEBUGGER
-#include <LibCompiler/Defines.h>
-#include <LibDebugger/POSIXMachContract.h>
-#include <Vendor/Dialogs.h>
-#include <cstdint>
-#include <iostream>
-#include <string>
-
-#include <LibDebugger/CommonCLI.inl>
+#include <CompilerKit/Defines.h>
+#include <DebuggerKit/POSIXMachContract.h>
+#include <ThirdParty/Dialogs.h>
+#include <DebuggerKit/CommonCLI.inl>
/// @internal
/// @brief Handles CTRL-C signal on debugger.
@@ -25,7 +21,7 @@ static void dbgi_ctrlc_handler(std::int32_t _) {
kDebugger.Break();
- pfd::notify("Debugger Event", "BreakAt hit!");
+ pfd::notify("Debugger Event", "Breakpoint hit!");
kKeepRunning = false;
}
@@ -39,9 +35,14 @@ LIBCOMPILER_MODULE(DebuggerMachPOSIX) {
kDebugger.SetPath(kPath);
kStdOut << "[+] Image set to: " << kPath << "\n";
+ } else {
+ kStdOut << "usage: " << argv[0] << " -p <path>\n";
+ kStdOut << "example: " << argv[0] << " -p /path/to/program\n";
+
+ return EXIT_FAILURE;
}
- LibCompiler::install_signal(SIGINT, dbgi_ctrlc_handler);
+ CompilerKit::install_signal(SIGINT, dbgi_ctrlc_handler);
while (YES) {
if (kKeepRunning) {
diff --git a/dev/LibC++/__power64.inc b/dev/LibC++/__power64.inc
index fbda659..b09bdcc 100644
--- a/dev/LibC++/__power64.inc
+++ b/dev/LibC++/__power64.inc
@@ -1,5 +1,5 @@
# Path: LibC++/__power64.inc
-# Language: LibCompiler POWER Assembly support for GNU.
+# Language: CompilerKit POWER Assembly support for GNU.
# Build Date: 2024-6-4
#ifdef __LIBCOMPILER__
diff --git a/dev/Vendor/Dialogs.h b/dev/ThirdParty/Dialogs.h
index 84e239f..84e239f 100644
--- a/dev/Vendor/Dialogs.h
+++ b/dev/ThirdParty/Dialogs.h