diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-06 09:27:02 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-06 09:27:02 +0200 |
| commit | ffcc3756464dcd2a3384ccb0c3b7506196ae4744 (patch) | |
| tree | f0e2c10a141dcfda5309b527fd906a376c1492aa | |
| parent | 8ca205395dc7d76fecd2baf8d6b59d7df01825fd (diff) | |
MHR-24: Add new __mpcc headers.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
| -rw-r--r-- | Documentation/TODO.txt | 11 | ||||
| -rw-r--r-- | SDK/__mpcc_alloca.hxx | 15 | ||||
| -rw-r--r-- | SDK/__mpcc_exception.hxx | 27 | ||||
| -rw-r--r-- | SDK/__mpcc_malloc.hxx | 29 | ||||
| -rw-r--r-- | Sources/amd64-cplusplus.cc | 4 |
5 files changed, 73 insertions, 13 deletions
diff --git a/Documentation/TODO.txt b/Documentation/TODO.txt deleted file mode 100644 index 1ae42b3..0000000 --- a/Documentation/TODO.txt +++ /dev/null @@ -1,11 +0,0 @@ -- POWER assembler - - Add offsets support to instructions which loads data from memory, POWER is a load/store architecture like 64k, SPARC and so... - -- AMD64 assembler - - Add support 'mov' which encodes a,b,c,d,e and 8,15 registers. - -- C compilers - - Fix code generation (ppc done) - - Add structs/enums, and a preprocessing program (ppc todo) - -- Extended Syntax Checker (esc.exe -c-asm foo.s) diff --git a/SDK/__mpcc_alloca.hxx b/SDK/__mpcc_alloca.hxx new file mode 100644 index 0000000..f56da9f --- /dev/null +++ b/SDK/__mpcc_alloca.hxx @@ -0,0 +1,15 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +typedef void* ptr_type; +typedef __SIZE_TYPE__ size_type; + +inline void* __mpcc_alloca_gcc(size_type sz) +{ + return __builtin_alloca(sz); +} diff --git a/SDK/__mpcc_exception.hxx b/SDK/__mpcc_exception.hxx new file mode 100644 index 0000000..0cd439d --- /dev/null +++ b/SDK/__mpcc_exception.hxx @@ -0,0 +1,27 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +/// This file is an implementation of __throw* family of functions. + +#include <exception> +#include <iostream> +#include <stdexcept> + +namespace std +{ + inline void __throw_general(void) + { + throw std::runtime_error("MPCC C++ Runtime error."); + } + + inline void __throw_domain_error(const char* error) + { + std::cout << "MPCC C++: Domain error: " << error << "\r"; + __throw_general(); + } +} diff --git a/SDK/__mpcc_malloc.hxx b/SDK/__mpcc_malloc.hxx new file mode 100644 index 0000000..b1ee2a7 --- /dev/null +++ b/SDK/__mpcc_malloc.hxx @@ -0,0 +1,29 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <algorithm> + +namespace stdx +{ +/// @brief allocate a new class. +/// @tparam KindClass the class type to allocate. +template <typename KindClass, typename... Args> +inline void* allocate(Args&&... args) +{ + return new KindClass(std::forward(args)...); +} + +/// @brief free a class. +/// @tparam KindClass the class type to allocate. +template <typename KindClass> +inline void release(KindClass ptr) +{ + if (!ptr) return; + delete ptr; +} +} // namespace stdx diff --git a/Sources/amd64-cplusplus.cc b/Sources/amd64-cplusplus.cc index edff0c5..60e6435 100644 --- a/Sources/amd64-cplusplus.cc +++ b/Sources/amd64-cplusplus.cc @@ -30,7 +30,7 @@ #define kOk 0 /* Mahrouss Logic C++ driver */ -/* This is part of MultiProcessor C++ SDK. */ +/* This is part of CodeTools C++ compiler. */ /* (c) Mahrouss Logic */ // @author Amlal El Mahrouss (amlel) @@ -344,7 +344,7 @@ MPCC_MODULE(CompilerCPlusPlus) { return kOk; } - if (strcmp(argv[index], "-fmax-exceptions") == 0) { + if (strcmp(argv[index], "-max-errors") == 0) { try { kErrorLimit = std::strtol(argv[index + 1], nullptr, 10); } |
