summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler/src
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-22 08:25:35 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-05-22 08:26:57 +0200
commit96ea259e3e3a3b1be7d0e3b589063340fc48cd2e (patch)
treeeee3788889ee7c9f7e5d538604920acef05a8bba /dev/LibCompiler/src
parent385178a1ecb41a7a529d219d80e2ed1232831abd (diff)
feat(LibCompiler): Update AssemblyInterface's Arch method.
also: - Figured out the segfault, currently working on a patch. - Better CLI output, with each library having it's prefix. - LibCompiler: `drv` - LibDebugger: `dbg` Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler/src')
-rw-r--r--dev/LibCompiler/src/AssemblerAMD64.cc3
-rw-r--r--dev/LibCompiler/src/AssemblerARM64.cc3
-rw-r--r--dev/LibCompiler/src/AssemblerPowerPC.cc3
-rw-r--r--dev/LibCompiler/src/CCompiler64x0.cc4
-rw-r--r--dev/LibCompiler/src/CCompilerARM64.cc4
-rw-r--r--dev/LibCompiler/src/CCompilerPower64.cc4
-rw-r--r--dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc29
7 files changed, 18 insertions, 32 deletions
diff --git a/dev/LibCompiler/src/AssemblerAMD64.cc b/dev/LibCompiler/src/AssemblerAMD64.cc
index eb767cc..f017f0d 100644
--- a/dev/LibCompiler/src/AssemblerAMD64.cc
+++ b/dev/LibCompiler/src/AssemblerAMD64.cc
@@ -48,9 +48,6 @@
#define kWhite "\e[0;97m"
#define kYellow "\e[0;33m"
-#define kStdOut (std::cout << kWhite)
-#define kStdErr (std::cout << kRed)
-
static char kOutputArch = LibCompiler::kPefArchAMD64;
constexpr auto kIPAlignement = 0x1U;
diff --git a/dev/LibCompiler/src/AssemblerARM64.cc b/dev/LibCompiler/src/AssemblerARM64.cc
index 19c7401..bad974e 100644
--- a/dev/LibCompiler/src/AssemblerARM64.cc
+++ b/dev/LibCompiler/src/AssemblerARM64.cc
@@ -41,9 +41,6 @@
#define kWhite "\e[0;97m"
#define kYellow "\e[0;33m"
-#define kStdOut (std::cout << kWhite)
-#define kStdErr (std::cout << kRed)
-
constexpr auto cPowerIPAlignment = 0x1U;
static CharType kOutputArch = LibCompiler::kPefArchARM64;
diff --git a/dev/LibCompiler/src/AssemblerPowerPC.cc b/dev/LibCompiler/src/AssemblerPowerPC.cc
index ddd0b4e..c0a7172 100644
--- a/dev/LibCompiler/src/AssemblerPowerPC.cc
+++ b/dev/LibCompiler/src/AssemblerPowerPC.cc
@@ -41,9 +41,6 @@
#define kWhite "\e[0;97m"
#define kYellow "\e[0;33m"
-#define kStdOut (std::cout << kWhite)
-#define kStdErr (std::cout << kRed)
-
constexpr auto cPowerIPAlignment = 0x4U;
static CharType kOutputArch = LibCompiler::kPefArchPowerPC;
diff --git a/dev/LibCompiler/src/CCompiler64x0.cc b/dev/LibCompiler/src/CCompiler64x0.cc
index 7bd8e8b..17de065 100644
--- a/dev/LibCompiler/src/CCompiler64x0.cc
+++ b/dev/LibCompiler/src/CCompiler64x0.cc
@@ -1051,9 +1051,7 @@ class AssemblyCCInterface final ASSEMBLY_INTERFACE {
LIBCOMPILER_COPY_DEFAULT(AssemblyCCInterface);
- [[maybe_unused]] Int32 Arch() noexcept override {
- return LibCompiler::AssemblyFactory::kArch64x0;
- }
+ UInt32 Arch() noexcept override { return LibCompiler::AssemblyFactory::kArch64x0; }
Int32 CompileToFormat(std::string src, Int32 arch) override {
if (kCompilerFrontend == nullptr) return 1;
diff --git a/dev/LibCompiler/src/CCompilerARM64.cc b/dev/LibCompiler/src/CCompilerARM64.cc
index 542f45f..3aaab5f 100644
--- a/dev/LibCompiler/src/CCompilerARM64.cc
+++ b/dev/LibCompiler/src/CCompilerARM64.cc
@@ -1049,9 +1049,7 @@ class AssemblyCCInterface final ASSEMBLY_INTERFACE {
LIBCOMPILER_COPY_DEFAULT(AssemblyCCInterface);
- [[maybe_unused]] Int32 Arch() noexcept override {
- return LibCompiler::AssemblyFactory::kArchAARCH64;
- }
+ UInt32 Arch() noexcept override { return LibCompiler::AssemblyFactory::kArchAARCH64; }
Int32 CompileToFormat(std::string src, Int32 arch) override {
if (kCompilerFrontend == nullptr) return 1;
diff --git a/dev/LibCompiler/src/CCompilerPower64.cc b/dev/LibCompiler/src/CCompilerPower64.cc
index e5b25a5..aa49768 100644
--- a/dev/LibCompiler/src/CCompilerPower64.cc
+++ b/dev/LibCompiler/src/CCompilerPower64.cc
@@ -1069,9 +1069,7 @@ class AssemblyMountpointCLang final ASSEMBLY_INTERFACE {
LIBCOMPILER_COPY_DEFAULT(AssemblyMountpointCLang);
- [[maybe_unused]] Int32 Arch() noexcept override {
- return LibCompiler::AssemblyFactory::kArchPowerPC;
- }
+ UInt32 Arch() noexcept override { return LibCompiler::AssemblyFactory::kArchPowerPC; }
Int32 CompileToFormat(std::string src, Int32 arch) override {
if (kCompilerFrontend == nullptr) return 1;
diff --git a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
index 29cdee7..517a2f2 100644
--- a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
+++ b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
@@ -21,8 +21,6 @@
#include <LibCompiler/Detail/ClUtils.h>
#include <LibCompiler/UUID.h>
-#include <cstdio>
-
/* NeKernel C++ Compiler Driver */
/* This is part of the LibCompiler. */
/* (c) Amlal El Mahrouss */
@@ -188,7 +186,7 @@ static std::vector<std::pair<std::string, std::uintptr_t>> kOriginMap;
/////////////////////////////////////////////////////////////////////////////////////////
Boolean CompilerFrontendCPlusPlus::Compile(std::string text, std::string file) {
- if (text.empty()) return false;
+ if (text.length() < 1) return false;
std::size_t index = 0UL;
std::vector<std::pair<LibCompiler::CompilerKeyword, std::size_t>> keywords_list;
@@ -717,9 +715,7 @@ class AssemblyCPlusPlusInterface final ASSEMBLY_INTERFACE {
LIBCOMPILER_COPY_DEFAULT(AssemblyCPlusPlusInterface);
- [[maybe_unused]] Int32 Arch() noexcept override {
- return LibCompiler::AssemblyFactory::kArchAMD64;
- }
+ UInt32 Arch() noexcept override { return LibCompiler::AssemblyFactory::kArchAMD64; }
Int32 CompileToFormat(std::string src, Int32 arch) override {
if (kCompilerFrontend == nullptr) return kExitNO;
@@ -727,21 +723,26 @@ class AssemblyCPlusPlusInterface final ASSEMBLY_INTERFACE {
std::string dest = src;
dest += ".masm";
- std::string line_source;
-
std::ofstream out_fp(dest);
std::ifstream src_fp = std::ifstream(src);
+ std::string line_source;
+
while (std::getline(src_fp, line_source)) {
if (kVerbose) {
- std::cout << kWhite << line_source << std::endl;
+ kStdOut << line_source << std::endl;
+ kStdOut << line_source.length() << " bytes\n";
}
kCompilerFrontend->Compile(line_source, src);
out_fp << kState.fOutputValue;
}
+ if (kVerbose) {
+ kStdOut << "Done compiling " << src << " to " << dest << "\n";
+ }
+
return kExitOK;
}
};
@@ -851,7 +852,7 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
if (strcmp(argv[index], "-cxx-dialect") == 0) {
if (kCompilerFrontend) std::cout << kCompilerFrontend->Language() << "\n";
- return kExitOK;
+ return LIBCOMPILER_SUCCESS;
}
if (strcmp(argv[index], "-cxx-max-err") == 0) {
@@ -879,14 +880,14 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
std::string argv_i = argv[index];
std::vector exts = kExtListCxx;
- Boolean found = false;
+ BOOL found = false;
for (std::string ext : exts) {
if (argv_i.find(ext) != std::string::npos) {
found = true;
if (kFactory.Compile(argv_i, kMachine) != kExitOK) {
- return kExitNO;
+ return LIBCOMPILER_INVALID_DATA;
}
}
}
@@ -896,13 +897,13 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
Detail::print_error(argv_i + " is not a valid C++ source.\n", "cxxdrv");
}
- return kExitNO;
+ return LIBCOMPILER_INVALID_DATA;
}
}
kFactory.Unmount();
- return kExitOK;
+ return LIBCOMPILER_SUCCESS;
}
// Last rev 8-1-24