summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-04-26 08:56:59 +0200
committerAmlal <amlal@nekernel.org>2025-04-26 08:56:59 +0200
commitc791c2de8bdcd89035dd004b73d05217e40e179c (patch)
treeacfb69b173218dbc42f69ef0c0ab9070f88a3411 /dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
parent7258fbf7c8785a3390441bbbac44d78b2e4facbf (diff)
dev: codebase has been improved in terms of cli and consistency.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc')
-rw-r--r--dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc40
1 files changed, 11 insertions, 29 deletions
diff --git a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
index a227f75..e58e4f6 100644
--- a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
+++ b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
@@ -14,11 +14,6 @@
#define kExitOK (EXIT_SUCCESS)
#define kExitNO (EXIT_FAILURE)
-#define kSplashCxx() \
- kPrintF(kWhite "%s\n", \
- "NeKernel Optimized C++ Compiler Driver, (c) 2024-2025 Amlal El Mahrouss, All rights " \
- "reserved.")
-
// extern_segment, @autodelete { ... }, fn foo() -> auto { ... }
#include <LibCompiler/Backend/Amd64.h>
@@ -392,14 +387,15 @@ Boolean CompilerFrontendCPlusPlus::Compile(std::string text, const std::string f
if (ch == ' ' || ch == '\t') {
if (fnName[indexFnName - 1] != ')')
Detail::print_error("Invalid function name: " + fnName, file);
-
- if ((indexFnName + 1) != fnName.size())
- Detail::print_error("Extra characters after function name: " + fnName, file);
}
++indexFnName;
}
+ if (fnName.find("(") != LibCompiler::String::npos) {
+ fnName.erase(fnName.find("("));
+ }
+
syntax_tree.fUserValue = "public_segment .code64 __LIBCOMPILER_" + fnName + "\n";
++kFunctionEmbedLevel;
@@ -760,7 +756,7 @@ class AssemblyCPlusPlusInterface final ASSEMBLY_INTERFACE {
[[maybe_unused]] static Int32 Arch() noexcept { return LibCompiler::AssemblyFactory::kArchAMD64; }
- Int32 CompileToFormat(std::string& src, Int32 arch) override {
+ Int32 CompileToFormat(std::string src, Int32 arch) override {
if (arch != AssemblyCPlusPlusInterface::Arch()) return 1;
if (kCompilerFrontend == nullptr) return 1;
@@ -850,12 +846,6 @@ class AssemblyCPlusPlusInterface final ASSEMBLY_INTERFACE {
/////////////////////////////////////////////////////////////////////////////////////////
-static void cxx_print_help() {
- kSplashCxx();
- kPrintF("%s", "No help available, see:\n");
- kPrintF("%s", "nekernel.org/docs/cxxdrv\n");
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
#define kExtListCxx \
@@ -949,30 +939,19 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
continue;
}
- if (strcmp(argv[index], "-version") == 0) {
- kSplashCxx();
- return kExitOK;
- }
-
if (strcmp(argv[index], "-cxx-verbose") == 0) {
kState.fVerbose = true;
continue;
}
- if (strcmp(argv[index], "-h") == 0) {
- cxx_print_help();
-
- return kExitOK;
- }
-
if (strcmp(argv[index], "-cxx-dialect") == 0) {
if (kCompilerFrontend) std::cout << kCompilerFrontend->Language() << "\n";
return kExitOK;
}
- if (strcmp(argv[index], "-max-err") == 0) {
+ if (strcmp(argv[index], "-cxx-max-err") == 0) {
try {
kErrorLimit = std::strtol(argv[index + 1], nullptr, 10);
}
@@ -1016,9 +995,12 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
return 1;
}
- std::cout << "CPlusPlusCompilerAMD64: Building: " << argv[index] << std::endl;
+ kStdOut << "CPlusPlusCompilerAMD64: Building: " << argv[index] << std::endl;
- if (kFactory.Compile(argv_i, kMachine) != kExitOK) return 1;
+ if (kFactory.Compile(argv_i, kMachine) != kExitOK) {
+ kStdOut << "CPlusPlusCompilerAMD64: Failed to build: " << argv[index] << std::endl;
+ return kExitNO;
+ }
}
return kExitOK;