From 1e4aa5a4f4a1e9c2b9fed58d569fe50fd45da04e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 20 Nov 2025 03:05:31 -0500 Subject: feat: new.cc file Signed-off-by: Amlal El Mahrouss --- dev/LibC++/new.cc | 8 ++++++++ dev/LibC++/new.h | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 dev/LibC++/new.cc (limited to 'dev') diff --git a/dev/LibC++/new.cc b/dev/LibC++/new.cc new file mode 100644 index 0000000..4882652 --- /dev/null +++ b/dev/LibC++/new.cc @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +------------------------------------------- */ + +#include + diff --git a/dev/LibC++/new.h b/dev/LibC++/new.h index 8b09328..f20dc3f 100644 --- a/dev/LibC++/new.h +++ b/dev/LibC++/new.h @@ -1,4 +1,3 @@ - /* ------------------------------------------- Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. -- cgit v1.2.3 From d73d1d2880d742a46602a94d0a888c981054feb4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 20 Nov 2025 03:13:07 -0500 Subject: feat: LibC++: work in progress placement new system. Signed-off-by: Amlal El Mahrouss --- dev/LibC++/filesystem.h | 2 ++ dev/LibC++/new.h | 38 +++++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) (limited to 'dev') diff --git a/dev/LibC++/filesystem.h b/dev/LibC++/filesystem.h index 59e73a0..0a1a39a 100644 --- a/dev/LibC++/filesystem.h +++ b/dev/LibC++/filesystem.h @@ -9,6 +9,8 @@ #include +/// @brief Filesystem module for LibC++ + namespace std { class path; class filesystem_error; diff --git a/dev/LibC++/new.h b/dev/LibC++/new.h index f20dc3f..3ac60d7 100644 --- a/dev/LibC++/new.h +++ b/dev/LibC++/new.h @@ -8,21 +8,37 @@ #include -struct __placement_new_info; +namespace std { +struct placement_new; + +/// ========================================================= +/// @brief Disambugate non-throwing allocation functions. +/// ========================================================= +struct nothrow_t { + explicit nothrow_t() = default; +}; + +/// ========================================================= +/// @brief Placement new metadata. +/// ========================================================= +struct placement_new { + void* __base; + int __align; + long long __size; +}; + +using placement_new_t = placement_new; +} // namespace std void* operator new(size_t); void* operator new[](size_t); +void* operator new(size_t, const std::nothrow_t&) noexcept; +void* operator new(size_t, void*) noexcept; +void* operator new[](size_t, const std::nothrow_t&) noexcept; +void* operator new[](size_t, void*) noexcept; + void operator delete(void*) noexcept; -void operator delete(void*, unsigned long) noexcept; +void operator delete(void*, size_t) noexcept; void operator delete[](void*) noexcept; - -/// ========================================================= -/// @brief Placement new information structure -/// ========================================================= -struct __placement_new_info { - void* __base; - int __align; - long long __size; -}; \ No newline at end of file -- cgit v1.2.3 From f1177e376ee62a1663961087231386a79b46fced Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 20 Nov 2025 03:27:03 -0500 Subject: fix: CPlusPlusCompilerAMD.cc: cleanup module. Signed-off-by: Amlal El Mahrouss --- dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc | 8 -------- 1 file changed, 8 deletions(-) (limited to 'dev') diff --git a/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc b/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc index 7c761f4..e44f4f2 100644 --- a/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc +++ b/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc @@ -90,14 +90,6 @@ struct CompilerState final { CompilerKit::STLString fLastError{}; }; -/// @brief prints an error into stdout. -/// @param reason the reason of the error. -/// @param file where does it originate from? -void print_error(const CompilerKit::STLString& reason, - const CompilerKit::STLString& file) noexcept { - kPrintErr << kRed << "Error in " << file << ": " << reason << kWhite << std::endl; -} - static CompilerState kState; static Int32 kOnClassScope = 0; -- cgit v1.2.3 From 56db5137ddd10f476b9820944b47ab72c6f8e019 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 20 Nov 2025 09:18:57 -0500 Subject: feat! breaking ABI changes, breaking codegen changes. Signed-off-by: Amlal El Mahrouss --- dev/CompilerKit/AE.h | 6 +++--- dev/CompilerKit/Frontend.h | 6 +++--- dev/CompilerKit/PEF.h | 2 +- dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'dev') diff --git a/dev/CompilerKit/AE.h b/dev/CompilerKit/AE.h index b8e076d..3ca14e6 100644 --- a/dev/CompilerKit/AE.h +++ b/dev/CompilerKit/AE.h @@ -12,10 +12,10 @@ #include -#define kAEVer (0x0120) +#define kAEVer (0x0121) -#define kAEMag0 'O' -#define kAEMag1 'B' +#define kAEMag0 'A' +#define kAEMag1 'E' #define kAESymbolLen (255) #define kAEPad (8) diff --git a/dev/CompilerKit/Frontend.h b/dev/CompilerKit/Frontend.h index 225de96..500f952 100644 --- a/dev/CompilerKit/Frontend.h +++ b/dev/CompilerKit/Frontend.h @@ -18,7 +18,7 @@ struct SyntaxLeafList; struct CompilerKeyword; /// =========================================================== /// -/// we want to do that because to separate keywords. +/// @note we want to do that to separate keywords. /// =========================================================== /// enum KeywordKind { @@ -79,7 +79,7 @@ struct SyntaxLeafList final { }; std::vector fLeafList; - SizeType fNumLeafs; + SizeType fNumLeafs{0}; SizeType SizeOf() { return fNumLeafs; } std::vector& Get() { return fLeafList; } @@ -116,7 +116,7 @@ class CompilerFrontendInterface { /// =========================================================== /// // NOTE: cast this to your user defined ast. /// =========================================================== /// - typedef void* AstType; + typedef VoidPtr AstType; /// =========================================================== /// //! @brief Compile a syntax tree ouf of the text. diff --git a/dev/CompilerKit/PEF.h b/dev/CompilerKit/PEF.h index dd2e03a..fc36fd7 100644 --- a/dev/CompilerKit/PEF.h +++ b/dev/CompilerKit/PEF.h @@ -46,7 +46,7 @@ enum { kPefArchIntel86S, kPefArchAMD64, kPefArchRISCV, - kPefArch64000, /* 64x0 RISC architecture. */ + kPefArch64000, /* Open64x0 RISC architecture. */ kPefArch32000, kPefArchPowerPC, /* 64-bit POWER architecture. */ kPefArchARM64, diff --git a/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc b/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc index e44f4f2..a13aa0e 100644 --- a/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc +++ b/dev/CompilerKit/src/Frontend/CPlusPlusCompilerAMD64.cc @@ -172,7 +172,7 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendCPlusPlusAMD64::Compile( CompilerKit::STLString text, CompilerKit::STLString file) { CompilerKit::SyntaxLeafList::SyntaxLeaf syntax_tree; - if (text.length() < 1) return syntax_tree; + if (text.empty()) return syntax_tree; std::size_t index = 0UL; std::vector> keywords_list; @@ -747,8 +747,8 @@ class AssemblyCPlusPlusInterfaceAMD64 final CK_ASSEMBLY_INTERFACE { CompilerKit::STLString line_source; - out_fp << "#bits 64\n"; - out_fp << "#org " << kOrigin << "\n\n"; + out_fp << "%bits 64\n"; + out_fp << "%org " << kOrigin << "\n\n"; while (std::getline(src_fp, line_source)) { out_fp << kFrontend->Compile(line_source, src).fUserValue; -- cgit v1.2.3