diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-12-27 07:39:05 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-12-27 07:39:05 +0100 |
| commit | f61c814a0a95e98529c96361c992f1a8ea24688a (patch) | |
| tree | 0c5fcb7976f5753149e0b8cc3b974a318e013f61 /dev | |
| parent | c2046f25120d8c39b36cb81459f3370c8a5f1fa3 (diff) | |
META: Refactor source code.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/LibC++/power64.inc | 2 | ||||
| -rw-r--r-- | dev/LibCompiler/AAL/AssemblyInterface.h (renamed from dev/ToolchainKit/AAL/AssemblyInterface.h) | 12 | ||||
| -rw-r--r-- | dev/LibCompiler/AAL/CPU/32x0.h (renamed from dev/ToolchainKit/AAL/CPU/32x0.h) | 2 | ||||
| -rw-r--r-- | dev/LibCompiler/AAL/CPU/64x0.h (renamed from dev/ToolchainKit/AAL/CPU/64x0.h) | 2 | ||||
| -rw-r--r-- | dev/LibCompiler/AAL/CPU/amd64.h (renamed from dev/ToolchainKit/AAL/CPU/amd64.h) | 2 | ||||
| -rw-r--r-- | dev/LibCompiler/AAL/CPU/arm64.h (renamed from dev/ToolchainKit/AAL/CPU/arm64.h) | 2 | ||||
| -rw-r--r-- | dev/LibCompiler/AAL/CPU/power64.h (renamed from dev/ToolchainKit/AAL/CPU/power64.h) | 0 | ||||
| -rw-r--r-- | dev/LibCompiler/Defines.h (renamed from dev/ToolchainKit/Defines.h) | 4 | ||||
| -rw-r--r-- | dev/LibCompiler/Macros.h (renamed from dev/ToolchainKit/Macros.h) | 0 | ||||
| -rw-r--r-- | dev/LibCompiler/NFC/AE.h (renamed from dev/ToolchainKit/NFC/AE.h) | 28 | ||||
| -rw-r--r-- | dev/LibCompiler/NFC/ErrorID.h (renamed from dev/ToolchainKit/NFC/ErrorID.h) | 6 | ||||
| -rw-r--r-- | dev/LibCompiler/NFC/ErrorOr.h (renamed from dev/ToolchainKit/NFC/ErrorOr.h) | 10 | ||||
| -rw-r--r-- | dev/LibCompiler/NFC/PEF.h (renamed from dev/ToolchainKit/NFC/PEF.h) | 22 | ||||
| -rw-r--r-- | dev/LibCompiler/NFC/Ref.h (renamed from dev/ToolchainKit/NFC/Ref.h) | 8 | ||||
| -rw-r--r-- | dev/LibCompiler/NFC/String.h (renamed from dev/ToolchainKit/NFC/String.h) | 10 | ||||
| -rw-r--r-- | dev/LibCompiler/NFC/XCOFF.h (renamed from dev/ToolchainKit/NFC/XCOFF.h) | 6 | ||||
| -rw-r--r-- | dev/LibCompiler/Parser.h (renamed from dev/ToolchainKit/Parser.h) | 6 | ||||
| -rw-r--r-- | dev/LibCompiler/ReadMe.md (renamed from dev/ToolchainKit/ReadMe.md) | 0 | ||||
| -rw-r--r-- | dev/LibCompiler/UUID.h (renamed from dev/ToolchainKit/UUID.h) | 0 | ||||
| -rw-r--r-- | dev/LibCompiler/Version.h (renamed from dev/ToolchainKit/Version.h) | 0 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Assembler32x0.cc (renamed from dev/ToolchainKit/src/Assembler32x0.cc) | 8 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Assembler64x0.cc (renamed from dev/ToolchainKit/src/Assembler64x0.cc) | 90 | ||||
| -rw-r--r-- | dev/LibCompiler/src/AssemblerAMD64.cc (renamed from dev/ToolchainKit/src/AssemblerAMD64.cc) | 148 | ||||
| -rw-r--r-- | dev/LibCompiler/src/AssemblerPower.cc (renamed from dev/ToolchainKit/src/AssemblerPower.cc) | 92 | ||||
| -rw-r--r-- | dev/LibCompiler/src/AssemblyFactory.cc (renamed from dev/ToolchainKit/src/AssemblyFactory.cc) | 8 | ||||
| -rw-r--r-- | dev/LibCompiler/src/CCompiler64x0.cc (renamed from dev/ToolchainKit/src/CCompiler64x0.cc) | 44 | ||||
| -rw-r--r-- | dev/LibCompiler/src/CCompilerPower64.cc (renamed from dev/ToolchainKit/src/CCompilerPower64.cc) | 42 | ||||
| -rw-r--r-- | dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc (renamed from dev/ToolchainKit/src/CPlusPlusCompilerAMD64.cc) | 210 | ||||
| -rw-r--r-- | dev/LibCompiler/src/CPlusPlusCompilerPreProcessor.cc (renamed from dev/ToolchainKit/src/CPlusPlusCompilerPreProcessor.cc) | 22 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Detail/AsmUtils.h (renamed from dev/ToolchainKit/src/Detail/AsmUtils.h) | 14 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Detail/ClUtils.h (renamed from dev/ToolchainKit/src/Detail/ClUtils.h) | 4 | ||||
| -rw-r--r-- | dev/LibCompiler/src/Detail/ReadMe.md (renamed from dev/ToolchainKit/src/Detail/ReadMe.md) | 0 | ||||
| -rw-r--r-- | dev/LibCompiler/src/DynamicLinker64PEF.cc (renamed from dev/ToolchainKit/src/DynamicLinker64PEF.cc) | 166 | ||||
| -rw-r--r-- | dev/LibCompiler/src/String.cc (renamed from dev/ToolchainKit/src/String.cc) | 8 | ||||
| -rw-r--r-- | dev/LibIDE/TerminalEmulator.h (renamed from dev/CodeKit/TerminalEmulator.h) | 0 |
35 files changed, 489 insertions, 489 deletions
diff --git a/dev/LibC++/power64.inc b/dev/LibC++/power64.inc index 99d0b6b..060bfa1 100644 --- a/dev/LibC++/power64.inc +++ b/dev/LibC++/power64.inc @@ -1,5 +1,5 @@ # Path: LibC++/power.inc -# Language: ToolchainKit POWER Assembly support for GNU. +# Language: LibCompiler POWER Assembly support for GNU. # Build Date: 2024-6-4 %ifdef __TOOLCHAINKIT__ diff --git a/dev/ToolchainKit/AAL/AssemblyInterface.h b/dev/LibCompiler/AAL/AssemblyInterface.h index 7c5b4c4..245aee9 100644 --- a/dev/ToolchainKit/AAL/AssemblyInterface.h +++ b/dev/LibCompiler/AAL/AssemblyInterface.h @@ -6,13 +6,13 @@ #pragma once -#include <ToolchainKit/Macros.h> -#include <ToolchainKit/Defines.h> -#include <ToolchainKit/NFC/String.h> +#include <LibCompiler/Macros.h> +#include <LibCompiler/Defines.h> +#include <LibCompiler/NFC/String.h> -#define ASSEMBLY_INTERFACE : public ToolchainKit::AssemblyInterface +#define ASSEMBLY_INTERFACE : public LibCompiler::AssemblyInterface -namespace ToolchainKit +namespace LibCompiler { /// @brief Assembly to binary generator class. /// @note This interface creates according to the CPU target of the child class. @@ -224,4 +224,4 @@ namespace ToolchainKit }; #endif // __ASM_NEED_32x0__ -} // namespace ToolchainKit +} // namespace LibCompiler diff --git a/dev/ToolchainKit/AAL/CPU/32x0.h b/dev/LibCompiler/AAL/CPU/32x0.h index f7a4fc4..828ef8d 100644 --- a/dev/ToolchainKit/AAL/CPU/32x0.h +++ b/dev/LibCompiler/AAL/CPU/32x0.h @@ -6,7 +6,7 @@ #pragma once -#include <ToolchainKit/Defines.h> +#include <LibCompiler/Defines.h> // @brief 32x0 support. // @file CPU/32x0.hpp diff --git a/dev/ToolchainKit/AAL/CPU/64x0.h b/dev/LibCompiler/AAL/CPU/64x0.h index f2450c6..a057805 100644 --- a/dev/ToolchainKit/AAL/CPU/64x0.h +++ b/dev/LibCompiler/AAL/CPU/64x0.h @@ -6,7 +6,7 @@ #pragma once -#include <ToolchainKit/Defines.h> +#include <LibCompiler/Defines.h> #include <vector> // @brief 64x0 support. diff --git a/dev/ToolchainKit/AAL/CPU/amd64.h b/dev/LibCompiler/AAL/CPU/amd64.h index 6af29e8..219968a 100644 --- a/dev/ToolchainKit/AAL/CPU/amd64.h +++ b/dev/LibCompiler/AAL/CPU/amd64.h @@ -6,7 +6,7 @@ #pragma once -#include <ToolchainKit/Defines.h> +#include <LibCompiler/Defines.h> // @brief AMD64 support. // @file CPU/amd64.hpp diff --git a/dev/ToolchainKit/AAL/CPU/arm64.h b/dev/LibCompiler/AAL/CPU/arm64.h index 747d235..f2a14ce 100644 --- a/dev/ToolchainKit/AAL/CPU/arm64.h +++ b/dev/LibCompiler/AAL/CPU/arm64.h @@ -6,7 +6,7 @@ Copyright (C) 2024 Theater Quality Inc, all rights reserved #pragma once -#include <ToolchainKit/Defines.h> +#include <LibCompiler/Defines.h> /// @brief ARM64 encoding support. /// @file CPU/arm64.hpp diff --git a/dev/ToolchainKit/AAL/CPU/power64.h b/dev/LibCompiler/AAL/CPU/power64.h index 74e0966..74e0966 100644 --- a/dev/ToolchainKit/AAL/CPU/power64.h +++ b/dev/LibCompiler/AAL/CPU/power64.h diff --git a/dev/ToolchainKit/Defines.h b/dev/LibCompiler/Defines.h index a8d735d..ceb6c45 100644 --- a/dev/ToolchainKit/Defines.h +++ b/dev/LibCompiler/Defines.h @@ -102,7 +102,7 @@ #include <string> #include <vector> -namespace ToolchainKit +namespace LibCompiler { inline constexpr int kBaseYear = 1900; @@ -147,7 +147,7 @@ namespace ToolchainKit } using String = std::basic_string<CharType>; -} // namespace ToolchainKit +} // namespace LibCompiler #define PACKED __attribute__((packed)) diff --git a/dev/ToolchainKit/Macros.h b/dev/LibCompiler/Macros.h index 91ad8de..91ad8de 100644 --- a/dev/ToolchainKit/Macros.h +++ b/dev/LibCompiler/Macros.h diff --git a/dev/ToolchainKit/NFC/AE.h b/dev/LibCompiler/NFC/AE.h index edd51f6..962a7c3 100644 --- a/dev/ToolchainKit/NFC/AE.h +++ b/dev/LibCompiler/NFC/AE.h @@ -1,7 +1,7 @@ /* * ======================================================== * - * ToolchainKit + * LibCompiler * Copyright (C) 2024 Theater Quality Inc, all rights reserved. * * ======================================================== @@ -9,7 +9,7 @@ #pragma once -#include <ToolchainKit/Defines.h> +#include <LibCompiler/Defines.h> #define kAEMag0 'A' #define kAEMag1 'E' @@ -24,7 +24,7 @@ // You can also relocate at runtime but that's up to the operating system // loader. -namespace ToolchainKit +namespace LibCompiler { // @brief Advanced Executable Header // One thing to keep in mind. @@ -60,39 +60,39 @@ namespace ToolchainKit kKindRelocationByOffset = 0x23f, kKindRelocationAtRuntime = 0x34f, }; -} // namespace ToolchainKit +} // namespace LibCompiler // provide operator<< for AE -inline std::ofstream& operator<<(std::ofstream& fp, ToolchainKit::AEHeader& container) +inline std::ofstream& operator<<(std::ofstream& fp, LibCompiler::AEHeader& container) { - fp.write((char*)&container, sizeof(ToolchainKit::AEHeader)); + fp.write((char*)&container, sizeof(LibCompiler::AEHeader)); return fp; } inline std::ofstream& operator<<(std::ofstream& fp, - ToolchainKit::AERecordHeader& container) + LibCompiler::AERecordHeader& container) { - fp.write((char*)&container, sizeof(ToolchainKit::AERecordHeader)); + fp.write((char*)&container, sizeof(LibCompiler::AERecordHeader)); return fp; } -inline std::ifstream& operator>>(std::ifstream& fp, ToolchainKit::AEHeader& container) +inline std::ifstream& operator>>(std::ifstream& fp, LibCompiler::AEHeader& container) { - fp.read((char*)&container, sizeof(ToolchainKit::AEHeader)); + fp.read((char*)&container, sizeof(LibCompiler::AEHeader)); return fp; } inline std::ifstream& operator>>(std::ifstream& fp, - ToolchainKit::AERecordHeader& container) + LibCompiler::AERecordHeader& container) { - fp.read((char*)&container, sizeof(ToolchainKit::AERecordHeader)); + fp.read((char*)&container, sizeof(LibCompiler::AERecordHeader)); return fp; } -namespace ToolchainKit::Utils +namespace LibCompiler::Utils { /** * @brief AE Reader protocol @@ -140,4 +140,4 @@ namespace ToolchainKit::Utils return reinterpret_cast<TypeClass*>(raw); } }; -} // namespace ToolchainKit::Utils +} // namespace LibCompiler::Utils diff --git a/dev/ToolchainKit/NFC/ErrorID.h b/dev/LibCompiler/NFC/ErrorID.h index 2dcb527..e41410e 100644 --- a/dev/ToolchainKit/NFC/ErrorID.h +++ b/dev/LibCompiler/NFC/ErrorID.h @@ -1,7 +1,7 @@ /* * ======================================================== * - * ToolchainKit + * LibCompiler * Copyright (C) 2024 Theater Quality Inc, all rights reserved. * * ======================================================== @@ -9,8 +9,8 @@ #pragma once -#include <ToolchainKit/Defines.h> -#include <ToolchainKit/NFC/ErrorOr.h> +#include <LibCompiler/Defines.h> +#include <LibCompiler/NFC/ErrorOr.h> #define TOOLCHAINKIT_EXEC_ERROR -30 #define TOOLCHAINKIT_FILE_NOT_FOUND -31 diff --git a/dev/ToolchainKit/NFC/ErrorOr.h b/dev/LibCompiler/NFC/ErrorOr.h index e753ab2..18bac3f 100644 --- a/dev/ToolchainKit/NFC/ErrorOr.h +++ b/dev/LibCompiler/NFC/ErrorOr.h @@ -1,7 +1,7 @@ /* * ======================================================== * - * ToolchainKit + * LibCompiler * Copyright (C) 2024 Theater Quality Inc, all rights reserved. * * ======================================================== @@ -9,10 +9,10 @@ #pragma once -#include <ToolchainKit/Defines.h> -#include <ToolchainKit/NFC/Ref.h> +#include <LibCompiler/Defines.h> +#include <LibCompiler/NFC/Ref.h> -namespace ToolchainKit +namespace LibCompiler { using ErrorT = UInt32; @@ -58,4 +58,4 @@ namespace ToolchainKit using ErrorOrAny = ErrorOr<voidPtr>; -} // namespace ToolchainKit +} // namespace LibCompiler diff --git a/dev/ToolchainKit/NFC/PEF.h b/dev/LibCompiler/NFC/PEF.h index aeef459..aec3c64 100644 --- a/dev/ToolchainKit/NFC/PEF.h +++ b/dev/LibCompiler/NFC/PEF.h @@ -6,7 +6,7 @@ #pragma once -#include <ToolchainKit/Defines.h> +#include <LibCompiler/Defines.h> // @file PEF.hpp // @brief Preferred Executable Format @@ -38,7 +38,7 @@ #define kPefStart "__ImageStart" -namespace ToolchainKit +namespace LibCompiler { enum { @@ -113,32 +113,32 @@ namespace ToolchainKit kPefCount = 4, kPefInvalid = 0xFF, }; -} // namespace ToolchainKit +} // namespace LibCompiler inline std::ofstream& operator<<(std::ofstream& fp, - ToolchainKit::PEFContainer& container) + LibCompiler::PEFContainer& container) { - fp.write((char*)&container, sizeof(ToolchainKit::PEFContainer)); + fp.write((char*)&container, sizeof(LibCompiler::PEFContainer)); return fp; } inline std::ofstream& operator<<(std::ofstream& fp, - ToolchainKit::PEFCommandHeader& container) + LibCompiler::PEFCommandHeader& container) { - fp.write((char*)&container, sizeof(ToolchainKit::PEFCommandHeader)); + fp.write((char*)&container, sizeof(LibCompiler::PEFCommandHeader)); return fp; } inline std::ifstream& operator>>(std::ifstream& fp, - ToolchainKit::PEFContainer& container) + LibCompiler::PEFContainer& container) { - fp.read((char*)&container, sizeof(ToolchainKit::PEFContainer)); + fp.read((char*)&container, sizeof(LibCompiler::PEFContainer)); return fp; } inline std::ifstream& operator>>(std::ifstream& fp, - ToolchainKit::PEFCommandHeader& container) + LibCompiler::PEFCommandHeader& container) { - fp.read((char*)&container, sizeof(ToolchainKit::PEFCommandHeader)); + fp.read((char*)&container, sizeof(LibCompiler::PEFCommandHeader)); return fp; } diff --git a/dev/ToolchainKit/NFC/Ref.h b/dev/LibCompiler/NFC/Ref.h index a954ec2..f76f676 100644 --- a/dev/ToolchainKit/NFC/Ref.h +++ b/dev/LibCompiler/NFC/Ref.h @@ -2,7 +2,7 @@ /* * ======================================================== * - * ToolchainKit + * LibCompiler * Copyright (C) 2024 Theater Quality Inc, all rights reserved. * * ======================================================== @@ -10,9 +10,9 @@ #pragma once -#include <ToolchainKit/Defines.h> +#include <LibCompiler/Defines.h> -namespace ToolchainKit +namespace LibCompiler { // @author EL Mahrouss Amlal // @brief Reference holder class, refers to a pointer of data in static memory. @@ -100,4 +100,4 @@ namespace ToolchainKit private: Ref<T> m_Ref{nullptr}; }; -} // namespace ToolchainKit +} // namespace LibCompiler diff --git a/dev/ToolchainKit/NFC/String.h b/dev/LibCompiler/NFC/String.h index fa42a97..958da8e 100644 --- a/dev/ToolchainKit/NFC/String.h +++ b/dev/LibCompiler/NFC/String.h @@ -1,7 +1,7 @@ /* * ======================================================== * - * ToolchainKit + * LibCompiler * Copyright (C) 2024 Theater Quality Inc, all rights reserved. * * ======================================================== @@ -9,10 +9,10 @@ #pragma once -#include <ToolchainKit/Defines.h> -#include <ToolchainKit/NFC/ErrorOr.h> +#include <LibCompiler/Defines.h> +#include <LibCompiler/NFC/ErrorOr.h> -namespace ToolchainKit +namespace LibCompiler { /** * @brief StringView class, contains a C string and manages it. @@ -87,4 +87,4 @@ namespace ToolchainKit static const char* Format(const char* fmt, const char* from); static bool Equals(const char* lhs, const char* rhs); }; -} // namespace ToolchainKit +} // namespace LibCompiler diff --git a/dev/ToolchainKit/NFC/XCOFF.h b/dev/LibCompiler/NFC/XCOFF.h index 58a9eeb..0594855 100644 --- a/dev/ToolchainKit/NFC/XCOFF.h +++ b/dev/LibCompiler/NFC/XCOFF.h @@ -14,7 +14,7 @@ #ifndef __XCOFF__ #define __XCOFF__ -#include <ToolchainKit/Defines.h> +#include <LibCompiler/Defines.h> #define kXCOFF64Magic 0x01F7 @@ -23,7 +23,7 @@ #define kXCOFFLnno 0x0004 #define kXCOFFLSyms 0x0008 -namespace ToolchainKit +namespace LibCompiler { /// @brief XCoff identification header. typedef struct XCoffFileHeader @@ -36,6 +36,6 @@ namespace ToolchainKit UInt32 fNumSyms; UInt16 fOptHdr; // ?: Number of bytes in optional header } XCoffFileHeader; -} // namespace ToolchainKit +} // namespace LibCompiler #endif // ifndef __XCOFF__ diff --git a/dev/ToolchainKit/Parser.h b/dev/LibCompiler/Parser.h index cca6348..35e0c45 100644 --- a/dev/ToolchainKit/Parser.h +++ b/dev/LibCompiler/Parser.h @@ -6,9 +6,9 @@ #pragma once -#include <ToolchainKit/AAL/AssemblyInterface.h> +#include <LibCompiler/AAL/AssemblyInterface.h> -namespace ToolchainKit +namespace LibCompiler { inline auto kInvalidFrontend = "NoLang"; @@ -174,4 +174,4 @@ namespace ToolchainKit return false; } -} // namespace ToolchainKit +} // namespace LibCompiler diff --git a/dev/ToolchainKit/ReadMe.md b/dev/LibCompiler/ReadMe.md index 4bc01b8..4bc01b8 100644 --- a/dev/ToolchainKit/ReadMe.md +++ b/dev/LibCompiler/ReadMe.md diff --git a/dev/ToolchainKit/UUID.h b/dev/LibCompiler/UUID.h index 74584b4..74584b4 100644 --- a/dev/ToolchainKit/UUID.h +++ b/dev/LibCompiler/UUID.h diff --git a/dev/ToolchainKit/Version.h b/dev/LibCompiler/Version.h index 7fd0ffe..7fd0ffe 100644 --- a/dev/ToolchainKit/Version.h +++ b/dev/LibCompiler/Version.h diff --git a/dev/ToolchainKit/src/Assembler32x0.cc b/dev/LibCompiler/src/Assembler32x0.cc index c6825d3..3a5e030 100644 --- a/dev/ToolchainKit/src/Assembler32x0.cc +++ b/dev/LibCompiler/src/Assembler32x0.cc @@ -19,10 +19,10 @@ #define __ASM_NEED_32x0__ 1 -#include <ToolchainKit/AAL/CPU/32x0.h> -#include <ToolchainKit/Parser.h> -#include <ToolchainKit/NFC/AE.h> -#include <ToolchainKit/NFC/PEF.h> +#include <LibCompiler/AAL/CPU/32x0.h> +#include <LibCompiler/Parser.h> +#include <LibCompiler/NFC/AE.h> +#include <LibCompiler/NFC/PEF.h> ///////////////////// diff --git a/dev/ToolchainKit/src/Assembler64x0.cc b/dev/LibCompiler/src/Assembler64x0.cc index fe97e09..968b6a5 100644 --- a/dev/ToolchainKit/src/Assembler64x0.cc +++ b/dev/LibCompiler/src/Assembler64x0.cc @@ -19,10 +19,10 @@ #define __ASM_NEED_64x0__ 1 -#include <ToolchainKit/AAL/CPU/64x0.h> -#include <ToolchainKit/Parser.h> -#include <ToolchainKit/NFC/AE.h> -#include <ToolchainKit/NFC/PEF.h> +#include <LibCompiler/AAL/CPU/64x0.h> +#include <LibCompiler/Parser.h> +#include <LibCompiler/NFC/AE.h> +#include <LibCompiler/NFC/PEF.h> #include <algorithm> #include <filesystem> #include <fstream> @@ -43,7 +43,7 @@ #define kStdOut (std::cout << kWhite) #define kStdErr (std::cout << kRed) -static char kOutputArch = ToolchainKit::kPefArch64000; +static char kOutputArch = LibCompiler::kPefArch64000; static Boolean kOutputAsBinary = false; static UInt32 kErrorLimit = 10; @@ -60,10 +60,10 @@ static bool kVerbose = false; static std::vector<e64k_num_t> kBytes; -static ToolchainKit::AERecordHeader kCurrentRecord{ - .fName = "", .fKind = ToolchainKit::kPefCode, .fSize = 0, .fOffset = 0}; +static LibCompiler::AERecordHeader kCurrentRecord{ + .fName = "", .fKind = LibCompiler::kPefCode, .fSize = 0, .fOffset = 0}; -static std::vector<ToolchainKit::AERecordHeader> kRecords; +static std::vector<LibCompiler::AERecordHeader> kRecords; static std::vector<std::string> kUndefinedSymbols; static const std::string kUndefinedSymbol = ":UndefinedSymbol:"; @@ -80,7 +80,7 @@ namespace Details reason.erase(0, 1); kStdErr << kRed << "[ TQC++ ] " << kWhite - << ((file == "ToolchainKit") ? "InternalErrorException: " + << ((file == "LibCompiler") ? "InternalErrorException: " : ("FileException{ " + file + " }: ")) << kBlank << std::endl; kStdErr << kRed << "[ TQC++ ] " << kWhite << reason << kBlank << std::endl; @@ -180,13 +180,13 @@ TOOLCHAINKIT_MODULE(AssemblerMain64x0) std::string line; - ToolchainKit::AEHeader hdr{0}; + LibCompiler::AEHeader hdr{0}; memset(hdr.fPad, kAENullType, kAEPad); hdr.fMagic[0] = kAEMag0; hdr.fMagic[1] = kAEMag1; - hdr.fSize = sizeof(ToolchainKit::AEHeader); + hdr.fSize = sizeof(LibCompiler::AEHeader); hdr.fArch = kOutputArch; ///////////////////////////////////////////////////////////////////////////////////////// @@ -195,7 +195,7 @@ TOOLCHAINKIT_MODULE(AssemblerMain64x0) ///////////////////////////////////////////////////////////////////////////////////////// - ToolchainKit::Encoder64x0 asm64; + LibCompiler::Encoder64x0 asm64; while (std::getline(file_ptr, line)) { @@ -215,7 +215,7 @@ TOOLCHAINKIT_MODULE(AssemblerMain64x0) if (kVerbose) { std::string what = e.what(); - Details::print_warning("exit because of: " + what, "ToolchainKit"); + Details::print_warning("exit because of: " + what, "LibCompiler"); } std::filesystem::remove(object_output); @@ -256,7 +256,7 @@ TOOLCHAINKIT_MODULE(AssemblerMain64x0) if (kVerbose) kStdOut << "Assembler64x0: Wrote record " << rec.fName << " to file...\n"; - rec.fFlags |= ToolchainKit::kKindRelocationAtRuntime; + rec.fFlags |= LibCompiler::kKindRelocationAtRuntime; rec.fOffset = record_count; ++record_count; @@ -268,7 +268,7 @@ TOOLCHAINKIT_MODULE(AssemblerMain64x0) for (auto& sym : kUndefinedSymbols) { - ToolchainKit::AERecordHeader _record_hdr{0}; + LibCompiler::AERecordHeader _record_hdr{0}; if (kVerbose) kStdOut << "Assembler64x0: Wrote symbol " << sym << " to file...\n"; @@ -343,12 +343,12 @@ 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 (ToolchainKit::find_word(line, "extern_segment")) + if (LibCompiler::find_word(line, "extern_segment")) { if (kOutputAsBinary) { Details::print_error("Invalid extern_segment directive in flat binary mode.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("invalid_extern_segment_bin"); } @@ -376,17 +376,17 @@ static bool asm_read_attributes(std::string& line) if (name.find(".code64") != std::string::npos) { // data is treated as code. - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::kPefCode; } else if (name.find(".data64") != std::string::npos) { // no code will be executed from here. - kCurrentRecord.fKind = ToolchainKit::kPefData; + kCurrentRecord.fKind = LibCompiler::kPefData; } else if (name.find(".zero64") != std::string::npos) { // this is a bss section. - kCurrentRecord.fKind = ToolchainKit::kPefZero; + kCurrentRecord.fKind = LibCompiler::kPefZero; } // this is a special case for the start stub. @@ -394,7 +394,7 @@ static bool asm_read_attributes(std::string& line) if (name == kPefStart) { - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::kPefCode; } // now we can tell the code size of the previous kCurrentRecord. @@ -416,12 +416,12 @@ 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 (ToolchainKit::find_word(line, "public_segment")) + else if (LibCompiler::find_word(line, "public_segment")) { if (kOutputAsBinary) { Details::print_error("Invalid public_segment directive in flat binary mode.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("invalid_public_segment_bin"); } @@ -440,21 +440,21 @@ static bool asm_read_attributes(std::string& line) // data is treated as code. name_copy.erase(name_copy.find(".code64"), strlen(".code64")); - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::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 = ToolchainKit::kPefData; + kCurrentRecord.fKind = LibCompiler::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 = ToolchainKit::kPefZero; + kCurrentRecord.fKind = LibCompiler::kPefZero; } // this is a special case for the start stub. @@ -462,7 +462,7 @@ static bool asm_read_attributes(std::string& line) if (name == kPefStart) { - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::kPefCode; } while (name_copy.find(" ") != std::string::npos) @@ -516,14 +516,14 @@ namespace Details::algorithm ///////////////////////////////////////////////////////////////////////////////////////// -std::string ToolchainKit::Encoder64x0::CheckLine(std::string& line, +std::string LibCompiler::Encoder64x0::CheckLine(std::string& line, const std::string& file) { std::string err_str; - if (line.empty() || ToolchainKit::find_word(line, "extern_segment") || - ToolchainKit::find_word(line, "public_segment") || - line.find('#') != std::string::npos || ToolchainKit::find_word(line, ";")) + 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.find('#') != std::string::npos) { @@ -628,7 +628,7 @@ std::string ToolchainKit::Encoder64x0::CheckLine(std::string& line, opcode64x0.fName); it == filter_inst.cend()) { - if (ToolchainKit::find_word(line, opcode64x0.fName)) + if (LibCompiler::find_word(line, opcode64x0.fName)) { if (!isspace(line[line.find(opcode64x0.fName) + strlen(opcode64x0.fName)])) @@ -650,7 +650,7 @@ std::string ToolchainKit::Encoder64x0::CheckLine(std::string& line, return err_str; } -bool ToolchainKit::Encoder64x0::WriteNumber(const std::size_t& pos, +bool LibCompiler::Encoder64x0::WriteNumber(const std::size_t& pos, std::string& jump_label) { if (!isdigit(jump_label[pos])) @@ -664,12 +664,12 @@ bool ToolchainKit::Encoder64x0::WriteNumber(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid hex number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid hex number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_hex_number"); } } - ToolchainKit::NumberCast64 num( + LibCompiler::NumberCast64 num( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16)); for (char& i : num.number) @@ -691,12 +691,12 @@ bool ToolchainKit::Encoder64x0::WriteNumber(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid binary number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid binary number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_bin"); } } - ToolchainKit::NumberCast64 num( + LibCompiler::NumberCast64 num( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2)); if (kVerbose) @@ -718,12 +718,12 @@ bool ToolchainKit::Encoder64x0::WriteNumber(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid octal number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid octal number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_octal"); } } - ToolchainKit::NumberCast64 num( + LibCompiler::NumberCast64 num( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7)); if (kVerbose) @@ -753,7 +753,7 @@ bool ToolchainKit::Encoder64x0::WriteNumber(const std::size_t& pos, } } - ToolchainKit::NumberCast64 num( + LibCompiler::NumberCast64 num( strtol(jump_label.substr(pos).c_str(), nullptr, 10)); for (char& i : num.number) @@ -776,16 +776,16 @@ bool ToolchainKit::Encoder64x0::WriteNumber(const std::size_t& pos, ///////////////////////////////////////////////////////////////////////////////////////// -bool ToolchainKit::Encoder64x0::WriteLine(std::string& line, +bool LibCompiler::Encoder64x0::WriteLine(std::string& line, const std::string& file) { - if (ToolchainKit::find_word(line, "public_segment ")) + if (LibCompiler::find_word(line, "public_segment ")) return true; for (auto& opcode64x0 : kOpcodes64x0) { // strict check here - if (ToolchainKit::find_word(line, opcode64x0.fName) && + if (LibCompiler::find_word(line, opcode64x0.fName) && Details::algorithm::is_valid_64x0(line)) { std::string name(opcode64x0.fName); @@ -824,7 +824,7 @@ bool ToolchainKit::Encoder64x0::WriteLine(std::string& line, // it ranges from r0 to r19 // something like r190 doesn't exist in the instruction set. - if (kOutputArch == ToolchainKit::kPefArch64000) + if (kOutputArch == LibCompiler::kPefArch64000) { if (isdigit(line[line_index + 3]) && isdigit(line[line_index + 2])) @@ -1029,7 +1029,7 @@ bool ToolchainKit::Encoder64x0::WriteLine(std::string& line, << " to address: " << label.second << std::endl; } - ToolchainKit::NumberCast64 num(label.second); + LibCompiler::NumberCast64 num(label.second); for (auto& num : num.number) { diff --git a/dev/ToolchainKit/src/AssemblerAMD64.cc b/dev/LibCompiler/src/AssemblerAMD64.cc index ea2fea5..365163d 100644 --- a/dev/ToolchainKit/src/AssemblerAMD64.cc +++ b/dev/LibCompiler/src/AssemblerAMD64.cc @@ -26,10 +26,10 @@ #define kAssemblerPragmaSymStr "#" #define kAssemblerPragmaSym '#' -#include <ToolchainKit/AAL/CPU/amd64.h> -#include <ToolchainKit/Parser.h> -#include <ToolchainKit/NFC/AE.h> -#include <ToolchainKit/NFC/PEF.h> +#include <LibCompiler/AAL/CPU/amd64.h> +#include <LibCompiler/Parser.h> +#include <LibCompiler/NFC/AE.h> +#include <LibCompiler/NFC/PEF.h> #include <algorithm> #include <cstdlib> #include <filesystem> @@ -51,7 +51,7 @@ #define kStdOut (std::cout << kWhite) #define kStdErr (std::cout << kRed) -static char kOutputArch = ToolchainKit::kPefArchAMD64; +static char kOutputArch = LibCompiler::kPefArchAMD64; static Boolean kOutputAsBinary = false; static UInt32 kErrorLimit = 10; @@ -71,10 +71,10 @@ static bool kVerbose = false; static std::vector<i64_byte_t> kAppBytes; -static ToolchainKit::AERecordHeader kCurrentRecord{ - .fName = "", .fKind = ToolchainKit::kPefCode, .fSize = 0, .fOffset = 0}; +static LibCompiler::AERecordHeader kCurrentRecord{ + .fName = "", .fKind = LibCompiler::kPefCode, .fSize = 0, .fOffset = 0}; -static std::vector<ToolchainKit::AERecordHeader> kRecords; +static std::vector<LibCompiler::AERecordHeader> kRecords; static std::vector<std::string> kDefinedSymbols; static std::vector<std::string> kUndefinedSymbols; @@ -203,13 +203,13 @@ TOOLCHAINKIT_MODULE(AssemblerAMD64) std::string line; - ToolchainKit::AEHeader hdr{0}; + LibCompiler::AEHeader hdr{0}; memset(hdr.fPad, kAENullType, kAEPad); hdr.fMagic[0] = kAEMag0; hdr.fMagic[1] = kAEMag1; - hdr.fSize = sizeof(ToolchainKit::AEHeader); + hdr.fSize = sizeof(LibCompiler::AEHeader); hdr.fArch = kOutputArch; ///////////////////////////////////////////////////////////////////////////////////////// @@ -218,7 +218,7 @@ TOOLCHAINKIT_MODULE(AssemblerAMD64) ///////////////////////////////////////////////////////////////////////////////////////// - ToolchainKit::EncoderAMD64 asm64; + LibCompiler::EncoderAMD64 asm64; if (kVerbose) { @@ -244,7 +244,7 @@ TOOLCHAINKIT_MODULE(AssemblerAMD64) if (kVerbose) { std::string what = e.what(); - Details::print_warning("exit because of: " + what, "ToolchainKit"); + Details::print_warning("exit because of: " + what, "LibCompiler"); } try @@ -292,7 +292,7 @@ TOOLCHAINKIT_MODULE(AssemblerAMD64) if (kVerbose) kStdOut << "AssemblerAMD64: Wrote record " << rec.fName << " to file...\n"; - rec.fFlags |= ToolchainKit::kKindRelocationAtRuntime; + rec.fFlags |= LibCompiler::kKindRelocationAtRuntime; rec.fOffset = record_count; ++record_count; @@ -304,7 +304,7 @@ TOOLCHAINKIT_MODULE(AssemblerAMD64) for (auto& sym : kUndefinedSymbols) { - ToolchainKit::AERecordHeader _record_hdr{0}; + LibCompiler::AERecordHeader _record_hdr{0}; if (kVerbose) kStdOut << "AssemblerAMD64: Wrote symbol " << sym << " to file...\n"; @@ -387,11 +387,11 @@ 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 (ToolchainKit::find_word(line, "extern_segment")) + if (LibCompiler::find_word(line, "extern_segment")) { if (kOutputAsBinary) { - Details::print_error("Invalid directive in flat binary mode.", "ToolchainKit"); + Details::print_error("Invalid directive in flat binary mode.", "LibCompiler"); throw std::runtime_error("invalid_extern_segment_bin"); } @@ -418,17 +418,17 @@ static bool asm_read_attributes(std::string& line) if (name.find(kPefCode64) != std::string::npos) { // data is treated as code. - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::kPefCode; } else if (name.find(kPefData64) != std::string::npos) { // no code will be executed from here. - kCurrentRecord.fKind = ToolchainKit::kPefData; + kCurrentRecord.fKind = LibCompiler::kPefData; } else if (name.find(kPefZero64) != std::string::npos) { // this is a bss section. - kCurrentRecord.fKind = ToolchainKit::kPefZero; + kCurrentRecord.fKind = LibCompiler::kPefZero; } // this is a special case for the start stub. @@ -436,7 +436,7 @@ static bool asm_read_attributes(std::string& line) if (name == kPefStart) { - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::kPefCode; } // now we can tell the code size of the previous kCurrentRecord. @@ -458,11 +458,11 @@ 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 (ToolchainKit::find_word(line, "public_segment")) + else if (LibCompiler::find_word(line, "public_segment")) { if (kOutputAsBinary) { - Details::print_error("Invalid directive in flat binary mode.", "ToolchainKit"); + Details::print_error("Invalid directive in flat binary mode.", "LibCompiler"); throw std::runtime_error("invalid_public_segment_bin"); } @@ -479,7 +479,7 @@ static bool asm_read_attributes(std::string& line) if (std::find(kDefinedSymbols.begin(), kDefinedSymbols.end(), name) != kDefinedSymbols.end()) { - Details::print_error("Symbol already defined.", "ToolchainKit"); + Details::print_error("Symbol already defined.", "LibCompiler"); throw std::runtime_error("invalid_public_segment_bin"); } @@ -490,21 +490,21 @@ static bool asm_read_attributes(std::string& line) // data is treated as code. name_copy.erase(name_copy.find(".code64"), strlen(".code64")); - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::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 = ToolchainKit::kPefData; + kCurrentRecord.fKind = LibCompiler::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 = ToolchainKit::kPefZero; + kCurrentRecord.fKind = LibCompiler::kPefZero; } // this is a special case for the start stub. @@ -512,7 +512,7 @@ static bool asm_read_attributes(std::string& line) if (name == kPefStart) { - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::kPefCode; } while (name_copy.find(" ") != std::string::npos) @@ -569,15 +569,15 @@ namespace Details::algorithm ///////////////////////////////////////////////////////////////////////////////////////// -std::string ToolchainKit::EncoderAMD64::CheckLine(std::string& line, +std::string LibCompiler::EncoderAMD64::CheckLine(std::string& line, const std::string& file) { std::string err_str; - if (line.empty() || ToolchainKit::find_word(line, "extern_segment") || - ToolchainKit::find_word(line, "public_segment") || - ToolchainKit::find_word(line, kAssemblerPragmaSymStr) || - ToolchainKit::find_word(line, ";") || line[0] == kAssemblerPragmaSym) + if (line.empty() || LibCompiler::find_word(line, "extern_segment") || + LibCompiler::find_word(line, "public_segment") || + LibCompiler::find_word(line, kAssemblerPragmaSymStr) || + LibCompiler::find_word(line, ";") || line[0] == kAssemblerPragmaSym) { if (line.find(';') != std::string::npos) { @@ -641,7 +641,7 @@ std::string ToolchainKit::EncoderAMD64::CheckLine(std::string& line, } for (auto& opcodeAMD64 : kOpcodesAMD64) { - if (ToolchainKit::find_word(line, opcodeAMD64.fName)) + if (LibCompiler::find_word(line, opcodeAMD64.fName)) { return err_str; } @@ -652,7 +652,7 @@ std::string ToolchainKit::EncoderAMD64::CheckLine(std::string& line, return err_str; } -bool ToolchainKit::EncoderAMD64::WriteNumber(const std::size_t& pos, +bool LibCompiler::EncoderAMD64::WriteNumber(const std::size_t& pos, std::string& jump_label) { if (!isdigit(jump_label[pos])) @@ -666,12 +666,12 @@ bool ToolchainKit::EncoderAMD64::WriteNumber(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid hex number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid hex number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_hex"); } } - ToolchainKit::NumberCast64 num = ToolchainKit::NumberCast64( + LibCompiler::NumberCast64 num = LibCompiler::NumberCast64( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16)); for (char& i : num.number) @@ -696,12 +696,12 @@ bool ToolchainKit::EncoderAMD64::WriteNumber(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid binary number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid binary number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_bin"); } } - ToolchainKit::NumberCast64 num = ToolchainKit::NumberCast64( + LibCompiler::NumberCast64 num = LibCompiler::NumberCast64( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2)); if (kVerbose) @@ -726,12 +726,12 @@ bool ToolchainKit::EncoderAMD64::WriteNumber(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid octal number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid octal number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_octal"); } } - ToolchainKit::NumberCast64 num = ToolchainKit::NumberCast64( + LibCompiler::NumberCast64 num = LibCompiler::NumberCast64( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7)); if (kVerbose) @@ -764,7 +764,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber(const std::size_t& pos, } } - ToolchainKit::NumberCast64 num = ToolchainKit::NumberCast64( + LibCompiler::NumberCast64 num = LibCompiler::NumberCast64( strtol(jump_label.substr(pos).c_str(), nullptr, 10)); for (char& i : num.number) @@ -784,7 +784,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber(const std::size_t& pos, return true; } -bool ToolchainKit::EncoderAMD64::WriteNumber32(const std::size_t& pos, +bool LibCompiler::EncoderAMD64::WriteNumber32(const std::size_t& pos, std::string& jump_label) { if (!isdigit(jump_label[pos])) @@ -801,7 +801,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber32(const std::size_t& pos, return false; } - ToolchainKit::NumberCast32 num = ToolchainKit::NumberCast32(res); + LibCompiler::NumberCast32 num = LibCompiler::NumberCast32(res); for (char& i : num.number) { @@ -828,7 +828,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber32(const std::size_t& pos, return false; } - ToolchainKit::NumberCast32 num = ToolchainKit::NumberCast32(res); + LibCompiler::NumberCast32 num = LibCompiler::NumberCast32(res); if (kVerbose) { @@ -855,7 +855,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber32(const std::size_t& pos, return false; } - ToolchainKit::NumberCast32 num = ToolchainKit::NumberCast32(res); + LibCompiler::NumberCast32 num = LibCompiler::NumberCast32(res); if (kVerbose) { @@ -886,7 +886,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber32(const std::size_t& pos, return false; } - ToolchainKit::NumberCast32 num = ToolchainKit::NumberCast32(res); + LibCompiler::NumberCast32 num = LibCompiler::NumberCast32(res); for (char& i : num.number) { @@ -905,7 +905,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber32(const std::size_t& pos, return true; } -bool ToolchainKit::EncoderAMD64::WriteNumber16(const std::size_t& pos, +bool LibCompiler::EncoderAMD64::WriteNumber16(const std::size_t& pos, std::string& jump_label) { if (!isdigit(jump_label[pos])) @@ -919,12 +919,12 @@ bool ToolchainKit::EncoderAMD64::WriteNumber16(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid hex number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid hex number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_hex"); } } - ToolchainKit::NumberCast16 num = ToolchainKit::NumberCast16( + LibCompiler::NumberCast16 num = LibCompiler::NumberCast16( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16)); for (char& i : num.number) @@ -949,12 +949,12 @@ bool ToolchainKit::EncoderAMD64::WriteNumber16(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid binary number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid binary number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_bin"); } } - ToolchainKit::NumberCast16 num = ToolchainKit::NumberCast16( + LibCompiler::NumberCast16 num = LibCompiler::NumberCast16( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2)); if (kVerbose) @@ -979,12 +979,12 @@ bool ToolchainKit::EncoderAMD64::WriteNumber16(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid octal number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid octal number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_octal"); } } - ToolchainKit::NumberCast16 num = ToolchainKit::NumberCast16( + LibCompiler::NumberCast16 num = LibCompiler::NumberCast16( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7)); if (kVerbose) @@ -1017,7 +1017,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber16(const std::size_t& pos, } } - ToolchainKit::NumberCast16 num = ToolchainKit::NumberCast16( + LibCompiler::NumberCast16 num = LibCompiler::NumberCast16( strtol(jump_label.substr(pos).c_str(), nullptr, 10)); for (char& i : num.number) @@ -1037,7 +1037,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber16(const std::size_t& pos, return true; } -bool ToolchainKit::EncoderAMD64::WriteNumber8(const std::size_t& pos, +bool LibCompiler::EncoderAMD64::WriteNumber8(const std::size_t& pos, std::string& jump_label) { if (!isdigit(jump_label[pos])) @@ -1051,12 +1051,12 @@ bool ToolchainKit::EncoderAMD64::WriteNumber8(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid hex number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid hex number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_hex"); } } - ToolchainKit::NumberCast8 num = ToolchainKit::NumberCast8( + LibCompiler::NumberCast8 num = LibCompiler::NumberCast8( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16)); kAppBytes.push_back(num.number); @@ -1075,12 +1075,12 @@ bool ToolchainKit::EncoderAMD64::WriteNumber8(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid binary number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid binary number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_bin"); } } - ToolchainKit::NumberCast8 num = ToolchainKit::NumberCast8( + LibCompiler::NumberCast8 num = LibCompiler::NumberCast8( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2)); if (kVerbose) @@ -1099,12 +1099,12 @@ bool ToolchainKit::EncoderAMD64::WriteNumber8(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid octal number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid octal number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_octal"); } } - ToolchainKit::NumberCast8 num = ToolchainKit::NumberCast8( + LibCompiler::NumberCast8 num = LibCompiler::NumberCast8( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7)); if (kVerbose) @@ -1131,7 +1131,7 @@ bool ToolchainKit::EncoderAMD64::WriteNumber8(const std::size_t& pos, } } - ToolchainKit::NumberCast8 num = ToolchainKit::NumberCast8( + LibCompiler::NumberCast8 num = LibCompiler::NumberCast8( strtol(jump_label.substr(pos).c_str(), nullptr, 10)); kAppBytes.push_back(num.number); @@ -1151,10 +1151,10 @@ bool ToolchainKit::EncoderAMD64::WriteNumber8(const std::size_t& pos, ///////////////////////////////////////////////////////////////////////////////////////// -bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, +bool LibCompiler::EncoderAMD64::WriteLine(std::string& line, const std::string& file) { - if (ToolchainKit::find_word(line, "public_segment ")) + if (LibCompiler::find_word(line, "public_segment ")) return true; struct RegMapAMD64 @@ -1186,7 +1186,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, for (auto& opcodeAMD64 : kOpcodesAMD64) { // strict check here - if (ToolchainKit::find_word(line, opcodeAMD64.fName) && + if (LibCompiler::find_word(line, opcodeAMD64.fName) && Details::algorithm::is_valid_amd64(line)) { foundInstruction = true; @@ -1202,7 +1202,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, if (substr.find(",") == std::string::npos) { - Details::print_error("Syntax error: missing right operand.", "ToolchainKit"); + Details::print_error("Syntax error: missing right operand.", "LibCompiler"); throw std::runtime_error("syntax_err"); } @@ -1287,7 +1287,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, if (hasRBasedRegs) { Details::print_error( - "Invalid combination of operands and registers.", "ToolchainKit"); + "Invalid combination of operands and registers.", "LibCompiler"); throw std::runtime_error("comb_op_reg"); } else @@ -1324,7 +1324,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, currentRegList[0].fName[0] == 'e') { Details::print_error("Invalid combination of operands and registers.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("comb_op_reg"); } @@ -1332,7 +1332,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, currentRegList[1].fName[0] == 'e') { Details::print_error("Invalid combination of operands and registers.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("comb_op_reg"); } @@ -1342,7 +1342,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, currentRegList[0].fName[0] == 'e') { Details::print_error("Invalid combination of operands and registers.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("comb_op_reg"); } @@ -1350,7 +1350,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, currentRegList[1].fName[0] == 'e') { Details::print_error("Invalid combination of operands and registers.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("comb_op_reg"); } } @@ -1360,7 +1360,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, currentRegList[0].fName[0] == 'e') { Details::print_error("Invalid combination of operands and registers.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("comb_op_reg"); } @@ -1368,7 +1368,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, currentRegList[1].fName[0] == 'e') { Details::print_error("Invalid combination of operands and registers.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("comb_op_reg"); } } @@ -1413,7 +1413,7 @@ bool ToolchainKit::EncoderAMD64::WriteLine(std::string& line, { if (foundInstruction) { - Details::print_error("Syntax error: " + line, "ToolchainKit"); + Details::print_error("Syntax error: " + line, "LibCompiler"); throw std::runtime_error("syntax_err"); } diff --git a/dev/ToolchainKit/src/AssemblerPower.cc b/dev/LibCompiler/src/AssemblerPower.cc index 6740630..a0b5739 100644 --- a/dev/ToolchainKit/src/AssemblerPower.cc +++ b/dev/LibCompiler/src/AssemblerPower.cc @@ -17,12 +17,12 @@ #define __ASM_NEED_PPC__ 1 -#include <ToolchainKit/NFC/ErrorID.h> -#include <ToolchainKit/AAL/CPU/power64.h> -#include <ToolchainKit/NFC/PEF.h> -#include <ToolchainKit/Parser.h> -#include <ToolchainKit/NFC/AE.h> -#include <ToolchainKit/Version.h> +#include <LibCompiler/NFC/ErrorID.h> +#include <LibCompiler/AAL/CPU/power64.h> +#include <LibCompiler/NFC/PEF.h> +#include <LibCompiler/Parser.h> +#include <LibCompiler/NFC/AE.h> +#include <LibCompiler/Version.h> #include <filesystem> #include <algorithm> #include <iostream> @@ -45,7 +45,7 @@ constexpr auto cPowerIPAlignment = 0x4U; -static CharType kOutputArch = ToolchainKit::kPefArchPowerPC; +static CharType kOutputArch = LibCompiler::kPefArchPowerPC; static Boolean kOutputAsBinary = false; static UInt32 kErrorLimit = 10; @@ -60,10 +60,10 @@ static bool kVerbose = false; static std::vector<uint8_t> kBytes; -static ToolchainKit::AERecordHeader kCurrentRecord{ - .fName = "", .fKind = ToolchainKit::kPefCode, .fSize = 0, .fOffset = 0}; +static LibCompiler::AERecordHeader kCurrentRecord{ + .fName = "", .fKind = LibCompiler::kPefCode, .fSize = 0, .fOffset = 0}; -static std::vector<ToolchainKit::AERecordHeader> kRecords; +static std::vector<LibCompiler::AERecordHeader> kRecords; static std::vector<std::string> kUndefinedSymbols; static const std::string kUndefinedSymbol = ":UndefinedSymbol:"; @@ -150,13 +150,13 @@ TOOLCHAINKIT_MODULE(AssemblerMainPower64) std::string line; - ToolchainKit::AEHeader hdr{0}; + LibCompiler::AEHeader hdr{0}; memset(hdr.fPad, kAENullType, kAEPad); hdr.fMagic[0] = kAEMag0; hdr.fMagic[1] = kAEMag1; - hdr.fSize = sizeof(ToolchainKit::AEHeader); + hdr.fSize = sizeof(LibCompiler::AEHeader); hdr.fArch = kOutputArch; ///////////////////////////////////////////////////////////////////////////////////////// @@ -165,7 +165,7 @@ TOOLCHAINKIT_MODULE(AssemblerMainPower64) ///////////////////////////////////////////////////////////////////////////////////////// - ToolchainKit::EncoderPowerPC asm64; + LibCompiler::EncoderPowerPC asm64; while (std::getline(file_ptr, line)) { @@ -185,7 +185,7 @@ TOOLCHAINKIT_MODULE(AssemblerMainPower64) if (kVerbose) { std::string what = e.what(); - Details::print_warning("exit because of: " + what, "ToolchainKit"); + Details::print_warning("exit because of: " + what, "LibCompiler"); } std::filesystem::remove(object_output); @@ -223,7 +223,7 @@ TOOLCHAINKIT_MODULE(AssemblerMainPower64) for (auto& record_hdr : kRecords) { - record_hdr.fFlags |= ToolchainKit::kKindRelocationAtRuntime; + record_hdr.fFlags |= LibCompiler::kKindRelocationAtRuntime; record_hdr.fOffset = record_count; ++record_count; @@ -238,7 +238,7 @@ TOOLCHAINKIT_MODULE(AssemblerMainPower64) for (auto& sym : kUndefinedSymbols) { - ToolchainKit::AERecordHeader undefined_sym{0}; + LibCompiler::AERecordHeader undefined_sym{0}; if (kVerbose) kStdOut << "AssemblerPower: Wrote symbol " << sym << " to file...\n"; @@ -313,12 +313,12 @@ 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 (ToolchainKit::find_word(line, "extern_segment")) + if (LibCompiler::find_word(line, "extern_segment")) { if (kOutputAsBinary) { Details::print_error("Invalid extern_segment directive in flat binary mode.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("invalid_extern_segment_bin"); } @@ -326,7 +326,7 @@ static bool asm_read_attributes(std::string& line) if (name.size() == 0) { - Details::print_error("Invalid extern_segment", "ToolchainKit"); + Details::print_error("Invalid extern_segment", "LibCompiler"); throw std::runtime_error("invalid_extern_segment"); } @@ -345,17 +345,17 @@ static bool asm_read_attributes(std::string& line) if (name.find(".code64") != std::string::npos) { // data is treated as code. - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::kPefCode; } else if (name.find(".data64") != std::string::npos) { // no code will be executed from here. - kCurrentRecord.fKind = ToolchainKit::kPefData; + kCurrentRecord.fKind = LibCompiler::kPefData; } else if (name.find(".zero64") != std::string::npos) { // this is a bss section. - kCurrentRecord.fKind = ToolchainKit::kPefZero; + kCurrentRecord.fKind = LibCompiler::kPefZero; } // this is a special case for the start stub. @@ -363,7 +363,7 @@ static bool asm_read_attributes(std::string& line) if (name == kPefStart) { - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::kPefCode; } // now we can tell the code size of the previous kCurrentRecord. @@ -385,12 +385,12 @@ 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 (ToolchainKit::find_word(line, "public_segment")) + else if (LibCompiler::find_word(line, "public_segment")) { if (kOutputAsBinary) { Details::print_error("Invalid public_segment directive in flat binary mode.", - "ToolchainKit"); + "LibCompiler"); throw std::runtime_error("invalid_public_segment_bin"); } @@ -409,21 +409,21 @@ static bool asm_read_attributes(std::string& line) // data is treated as code. name_copy.erase(name_copy.find(".code64"), strlen(".code64")); - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::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 = ToolchainKit::kPefData; + kCurrentRecord.fKind = LibCompiler::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 = ToolchainKit::kPefZero; + kCurrentRecord.fKind = LibCompiler::kPefZero; } // this is a special case for the start stub. @@ -431,7 +431,7 @@ static bool asm_read_attributes(std::string& line) if (name == kPefStart) { - kCurrentRecord.fKind = ToolchainKit::kPefCode; + kCurrentRecord.fKind = LibCompiler::kPefCode; } while (name_copy.find(" ") != std::string::npos) @@ -485,14 +485,14 @@ namespace Details::algorithm ///////////////////////////////////////////////////////////////////////////////////////// -std::string ToolchainKit::EncoderPowerPC::CheckLine(std::string& line, +std::string LibCompiler::EncoderPowerPC::CheckLine(std::string& line, const std::string& file) { std::string err_str; - if (line.empty() || ToolchainKit::find_word(line, "extern_segment") || - ToolchainKit::find_word(line, "public_segment") || - line.find('#') != std::string::npos || ToolchainKit::find_word(line, ";")) + 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.find('#') != std::string::npos) { @@ -575,7 +575,7 @@ std::string ToolchainKit::EncoderPowerPC::CheckLine(std::string& line, for (auto& opcodePPC : kOpcodesPowerPC) { - if (ToolchainKit::find_word(line, opcodePPC.name)) + if (LibCompiler::find_word(line, opcodePPC.name)) { for (auto& op : operands_inst) { @@ -594,7 +594,7 @@ std::string ToolchainKit::EncoderPowerPC::CheckLine(std::string& line, std::find(filter_inst.begin(), filter_inst.end(), opcodePPC.name); it == filter_inst.cend()) { - if (ToolchainKit::find_word(line, opcodePPC.name)) + if (LibCompiler::find_word(line, opcodePPC.name)) { if (!isspace( line[line.find(opcodePPC.name) + strlen(opcodePPC.name)])) @@ -616,7 +616,7 @@ std::string ToolchainKit::EncoderPowerPC::CheckLine(std::string& line, return err_str; } -bool ToolchainKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, +bool LibCompiler::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::string& jump_label) { if (!isdigit(jump_label[pos])) @@ -630,12 +630,12 @@ bool ToolchainKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid hex number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid hex number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_hex"); } } - ToolchainKit::NumberCast64 num( + LibCompiler::NumberCast64 num( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 16)); for (char& i : num.number) @@ -657,12 +657,12 @@ bool ToolchainKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid binary number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid binary number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_bin"); } } - ToolchainKit::NumberCast64 num( + LibCompiler::NumberCast64 num( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 2)); if (kVerbose) @@ -684,12 +684,12 @@ bool ToolchainKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, { if (errno != 0) { - Details::print_error("invalid octal number: " + jump_label, "ToolchainKit"); + Details::print_error("invalid octal number: " + jump_label, "LibCompiler"); throw std::runtime_error("invalid_octal"); } } - ToolchainKit::NumberCast64 num( + LibCompiler::NumberCast64 num( strtol(jump_label.substr(pos + 2).c_str(), nullptr, 7)); if (kVerbose) @@ -719,7 +719,7 @@ bool ToolchainKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, } } - ToolchainKit::NumberCast64 num( + LibCompiler::NumberCast64 num( strtol(jump_label.substr(pos).c_str(), nullptr, 10)); for (char& i : num.number) @@ -742,10 +742,10 @@ bool ToolchainKit::EncoderPowerPC::WriteNumber(const std::size_t& pos, ///////////////////////////////////////////////////////////////////////////////////////// -bool ToolchainKit::EncoderPowerPC::WriteLine(std::string& line, +bool LibCompiler::EncoderPowerPC::WriteLine(std::string& line, const std::string& file) { - if (ToolchainKit::find_word(line, "public_segment")) + if (LibCompiler::find_word(line, "public_segment")) return true; if (!Details::algorithm::is_valid_power64(line)) return true; @@ -753,7 +753,7 @@ bool ToolchainKit::EncoderPowerPC::WriteLine(std::string& line, for (auto& opcodePPC : kOpcodesPowerPC) { // strict check here - if (ToolchainKit::find_word(line, opcodePPC.name)) + if (LibCompiler::find_word(line, opcodePPC.name)) { std::string name(opcodePPC.name); std::string jump_label, cpy_jump_label; diff --git a/dev/ToolchainKit/src/AssemblyFactory.cc b/dev/LibCompiler/src/AssemblyFactory.cc index 721a163..a0d7bd8 100644 --- a/dev/ToolchainKit/src/AssemblyFactory.cc +++ b/dev/LibCompiler/src/AssemblyFactory.cc @@ -4,8 +4,8 @@ ------------------------------------------- */ -#include <ToolchainKit/AAL/AssemblyInterface.h> -#include <ToolchainKit/NFC/ErrorID.h> +#include <LibCompiler/AAL/AssemblyInterface.h> +#include <LibCompiler/NFC/ErrorID.h> /** * @file AssemblyFactory.cxx @@ -23,7 +23,7 @@ //! @file Asm.cpp //! @brief AssemblyKit source implementation. -namespace ToolchainKit +namespace LibCompiler { ///! @brief Compile for specific format (ELF, PEF, ZBIN) Int32 AssemblyFactory::Compile(std::string& sourceFile, @@ -56,4 +56,4 @@ namespace ToolchainKit return mount_prev; } -} // namespace ToolchainKit +} // namespace LibCompiler diff --git a/dev/ToolchainKit/src/CCompiler64x0.cc b/dev/LibCompiler/src/CCompiler64x0.cc index e1a67ea..e831401 100644 --- a/dev/ToolchainKit/src/CCompiler64x0.cc +++ b/dev/LibCompiler/src/CCompiler64x0.cc @@ -10,9 +10,9 @@ /// BUGS: 0 /// TODO: none -#include <ToolchainKit/AAL/CPU/64x0.h> -#include <ToolchainKit/Parser.h> -#include <ToolchainKit/UUID.h> +#include <LibCompiler/AAL/CPU/64x0.h> +#include <LibCompiler/Parser.h> +#include <LibCompiler/UUID.h> #include <cstdio> #include <fstream> #include <iostream> @@ -23,7 +23,7 @@ #include <vector> /* C driver */ -/* This is part of the ToolchainKit. */ +/* This is part of the LibCompiler. */ /* (c) Theater Quality Incorporated */ /// @author EL Mahrouss Amlal (amlel) @@ -78,10 +78,10 @@ namespace Details struct CompilerState final { - std::vector<ToolchainKit::SyntaxLeafList> fSyntaxTreeList; + std::vector<LibCompiler::SyntaxLeafList> fSyntaxTreeList; std::vector<CompilerRegisterMap> kStackFrame; std::vector<CompilerStructMap> kStructMap; - ToolchainKit::SyntaxLeafList* fSyntaxTree{nullptr}; + LibCompiler::SyntaxLeafList* fSyntaxTree{nullptr}; std::unique_ptr<std::ofstream> fOutputAssembly; std::string fLastFile; std::string fLastError; @@ -132,7 +132,7 @@ static std::string kRegisterPrefix = kAsmRegisterPrefix; ///////////////////////////////////////// static std::vector<std::string> kFileList; -static ToolchainKit::AssemblyFactory kFactory; +static LibCompiler::AssemblyFactory kFactory; static bool kInStruct = false; static bool kOnWhileLoop = false; static bool kOnForLoop = false; @@ -141,7 +141,7 @@ static bool kIfFound = false; static size_t kBracesCount = 0UL; /* @brief C compiler backend for C */ -class CompilerFrontend64x0 final : public ToolchainKit::ICompilerFrontend +class CompilerFrontend64x0 final : public LibCompiler::ICompilerFrontend { public: explicit CompilerFrontend64x0() = default; @@ -218,7 +218,7 @@ bool CompilerFrontend64x0::Compile(const std::string text, const std::string fil // start parsing for (size_t text_index = 0; text_index < textBuffer.size(); ++text_index) { - auto syntaxLeaf = ToolchainKit::SyntaxLeafList::SyntaxLeaf(); + auto syntaxLeaf = LibCompiler::SyntaxLeafList::SyntaxLeaf(); auto gen = uuids::uuid_random_generator{generator}; uuids::uuid out = gen(); @@ -736,7 +736,7 @@ bool CompilerFrontend64x0::Compile(const std::string text, const std::string fil syntaxLeaf.fUserValue.clear(); } - auto syntaxLeaf = ToolchainKit::SyntaxLeafList::SyntaxLeaf(); + auto syntaxLeaf = LibCompiler::SyntaxLeafList::SyntaxLeaf(); syntaxLeaf.fUserValue = "\n"; kState.fSyntaxTree->fLeafList.push_back(syntaxLeaf); @@ -1004,7 +1004,7 @@ cc_next: // extern does not declare anything, it extern_segments a variable. // so that's why it's not declare upper. - if (ToolchainKit::find_word(ln, "extern")) + if (LibCompiler::find_word(ln, "extern")) { auto substr = ln.substr(ln.find("extern") + strlen("extern")); kCompilerVariables.push_back({.fValue = substr}); @@ -1075,7 +1075,7 @@ skip_braces_check: for (auto& key : kCompilerTypes) { - if (ToolchainKit::find_word(ln, key.fName)) + if (LibCompiler::find_word(ln, key.fName)) { if (isdigit(ln[ln.find(key.fName) + key.fName.size() + 1])) { @@ -1176,9 +1176,9 @@ skip_braces_check: if (ln.find('(') != std::string::npos) { - if (ln.find(';') == std::string::npos && !ToolchainKit::find_word(ln, "|") && - !ToolchainKit::find_word(ln, "||") && !ToolchainKit::find_word(ln, "&") && - !ToolchainKit::find_word(ln, "&&") && !ToolchainKit::find_word(ln, "~")) + 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, "~")) { bool found_func = false; size_t i = ln.find('('); @@ -1304,7 +1304,7 @@ public: [[maybe_unused]] static Int32 Arch() noexcept { - return ToolchainKit::AssemblyFactory::kArch64x0; + return LibCompiler::AssemblyFactory::kArch64x0; } Int32 CompileToFormat(std::string& src, Int32 arch) override @@ -1336,14 +1336,14 @@ public: kState.fOutputAssembly = std::make_unique<std::ofstream>(dest); - auto fmt = ToolchainKit::current_date(); + auto fmt = LibCompiler::current_date(); (*kState.fOutputAssembly) << "# Path: " << src_file << "\n"; (*kState.fOutputAssembly) << "# Language: 64x0 Assembly (Generated from ANSI C)\n"; (*kState.fOutputAssembly) << "# Date: " << fmt << "\n\n"; - ToolchainKit::SyntaxLeafList syntax; + LibCompiler::SyntaxLeafList syntax; kState.fSyntaxTreeList.push_back(syntax); kState.fSyntaxTree = @@ -1380,7 +1380,7 @@ public: for (auto& access_ident : access_keywords) { - if (ToolchainKit::find_word(leaf.fUserValue, access_ident)) + if (LibCompiler::find_word(leaf.fUserValue, access_ident)) { for (auto& struc : kState.kStructMap) { @@ -1391,7 +1391,7 @@ public: for (auto& keyword : keywords) { - if (ToolchainKit::find_word(leaf.fUserValue, keyword)) + if (LibCompiler::find_word(leaf.fUserValue, keyword)) { std::size_t cnt = 0UL; @@ -1422,7 +1422,7 @@ public: } } - if (ToolchainKit::find_word(leaf.fUserValue, needle)) + if (LibCompiler::find_word(leaf.fUserValue, needle)) { if (leaf.fUserValue.find("extern_segment " + needle) != std::string::npos) @@ -1505,7 +1505,7 @@ TOOLCHAINKIT_MODULE(NewOSCompilerCLang64x0) bool skip = false; kFactory.Mount(new AssemblyCCInterface()); - kMachine = ToolchainKit::AssemblyFactory::kArch64x0; + kMachine = LibCompiler::AssemblyFactory::kArch64x0; kCompilerFrontend = new CompilerFrontend64x0(); for (auto index = 1UL; index < argc; ++index) diff --git a/dev/ToolchainKit/src/CCompilerPower64.cc b/dev/LibCompiler/src/CCompilerPower64.cc index 95fee28..99a3d0f 100644 --- a/dev/ToolchainKit/src/CCompilerPower64.cc +++ b/dev/LibCompiler/src/CCompilerPower64.cc @@ -7,9 +7,9 @@ * ======================================================== */ -#include <ToolchainKit/AAL/CPU/power64.h> -#include <ToolchainKit/Parser.h> -#include <ToolchainKit/UUID.h> +#include <LibCompiler/AAL/CPU/power64.h> +#include <LibCompiler/Parser.h> +#include <LibCompiler/UUID.h> #include <fstream> #include <iostream> #include <memory> @@ -69,10 +69,10 @@ namespace Details struct CompilerState final { - std::vector<ToolchainKit::SyntaxLeafList> fSyntaxTreeList; + std::vector<LibCompiler::SyntaxLeafList> fSyntaxTreeList; std::vector<CompilerRegisterMap> kStackFrame; std::vector<CompilerStructMap> kStructMap; - ToolchainKit::SyntaxLeafList* fSyntaxTree{nullptr}; + LibCompiler::SyntaxLeafList* fSyntaxTree{nullptr}; std::unique_ptr<std::ofstream> fOutputAssembly; std::string fLastFile; std::string fLastError; @@ -123,7 +123,7 @@ static std::string kRegisterPrefix = kAsmRegisterPrefix; ///////////////////////////////////////// static std::vector<std::string> kFileList; -static ToolchainKit::AssemblyFactory kFactory; +static LibCompiler::AssemblyFactory kFactory; static bool kInStruct = false; static bool kOnWhileLoop = false; static bool kOnForLoop = false; @@ -132,7 +132,7 @@ static bool kIfFound = false; static size_t kBracesCount = 0UL; /* @brief C compiler backend for C */ -class CompilerFrontendPower64 final : public ToolchainKit::ICompilerFrontend +class CompilerFrontendPower64 final : public LibCompiler::ICompilerFrontend { public: explicit CompilerFrontendPower64() = default; @@ -209,7 +209,7 @@ bool CompilerFrontendPower64::Compile(const std::string text, const std::string // start parsing for (size_t text_index = 0; text_index < textBuffer.size(); ++text_index) { - auto syntaxLeaf = ToolchainKit::SyntaxLeafList::SyntaxLeaf(); + auto syntaxLeaf = LibCompiler::SyntaxLeafList::SyntaxLeaf(); auto gen = uuids::uuid_random_generator{generator}; uuids::uuid out = gen(); @@ -759,7 +759,7 @@ bool CompilerFrontendPower64::Compile(const std::string text, const std::string syntaxLeaf.fUserValue.clear(); } - auto syntaxLeaf = ToolchainKit::SyntaxLeafList::SyntaxLeaf(); + auto syntaxLeaf = LibCompiler::SyntaxLeafList::SyntaxLeaf(); syntaxLeaf.fUserValue = "\n"; kState.fSyntaxTree->fLeafList.push_back(syntaxLeaf); @@ -1027,7 +1027,7 @@ cc_next: // extern does not declare anything, it extern_segments a variable. // so that's why it's not declare upper. - if (ToolchainKit::find_word(ln, "extern")) + if (LibCompiler::find_word(ln, "extern")) { auto substr = ln.substr(ln.find("extern") + strlen("extern")); kCompilerVariables.push_back({.fValue = substr}); @@ -1098,7 +1098,7 @@ skip_braces_check: for (auto& key : kCompilerTypes) { - if (ToolchainKit::find_word(ln, key.fName)) + if (LibCompiler::find_word(ln, key.fName)) { if (isdigit(ln[ln.find(key.fName) + key.fName.size() + 1])) { @@ -1199,9 +1199,9 @@ skip_braces_check: if (ln.find('(') != std::string::npos) { - if (ln.find(';') == std::string::npos && !ToolchainKit::find_word(ln, "|") && - !ToolchainKit::find_word(ln, "||") && !ToolchainKit::find_word(ln, "&") && - !ToolchainKit::find_word(ln, "&&") && !ToolchainKit::find_word(ln, "~")) + 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, "~")) { bool found_func = false; size_t i = ln.find('('); @@ -1327,7 +1327,7 @@ public: [[maybe_unused]] static Int32 Arch() noexcept { - return ToolchainKit::AssemblyFactory::kArchPowerPC; + return LibCompiler::AssemblyFactory::kArchPowerPC; } Int32 CompileToFormat(std::string& src, Int32 arch) override @@ -1359,14 +1359,14 @@ public: kState.fOutputAssembly = std::make_unique<std::ofstream>(dest); - auto fmt = ToolchainKit::current_date(); + auto fmt = LibCompiler::current_date(); (*kState.fOutputAssembly) << "# Path: " << src_file << "\n"; (*kState.fOutputAssembly) << "# Language: POWER Assembly (Generated from C)\n"; (*kState.fOutputAssembly) << "# Date: " << fmt << "\n\n"; - ToolchainKit::SyntaxLeafList syntax; + LibCompiler::SyntaxLeafList syntax; kState.fSyntaxTreeList.push_back(syntax); kState.fSyntaxTree = @@ -1402,7 +1402,7 @@ public: for (auto& access_ident : access_keywords) { - if (ToolchainKit::find_word(leaf.fUserValue, access_ident)) + if (LibCompiler::find_word(leaf.fUserValue, access_ident)) { for (auto& struc : kState.kStructMap) { @@ -1413,7 +1413,7 @@ public: for (auto& keyword : keywords) { - if (ToolchainKit::find_word(leaf.fUserValue, keyword)) + if (LibCompiler::find_word(leaf.fUserValue, keyword)) { std::size_t cnt = 0UL; @@ -1444,7 +1444,7 @@ public: } } - if (ToolchainKit::find_word(leaf.fUserValue, needle)) + if (LibCompiler::find_word(leaf.fUserValue, needle)) { if (leaf.fUserValue.find("extern_segment ") != std::string::npos) { @@ -1525,7 +1525,7 @@ TOOLCHAINKIT_MODULE(NewOSCompilerCLangPowerPC) bool skip = false; kFactory.Mount(new AssemblyMountpointCLang()); - kMachine = ToolchainKit::AssemblyFactory::kArchPowerPC; + kMachine = LibCompiler::AssemblyFactory::kArchPowerPC; kCompilerFrontend = new CompilerFrontendPower64(); for (auto index = 1UL; index < argc; ++index) diff --git a/dev/ToolchainKit/src/CPlusPlusCompilerAMD64.cc b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc index 2ef9327..0de1b06 100644 --- a/dev/ToolchainKit/src/CPlusPlusCompilerAMD64.cc +++ b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc @@ -20,12 +20,12 @@ // extern_segment, @autodelete { ... }, fn foo() -> auto { ... } -#include <ToolchainKit/AAL/CPU/amd64.h> -#include <ToolchainKit/Parser.h> -#include <ToolchainKit/UUID.h> +#include <LibCompiler/AAL/CPU/amd64.h> +#include <LibCompiler/Parser.h> +#include <LibCompiler/UUID.h> /* ZKA C++ Compiler */ -/* This is part of the ToolchainKit. */ +/* This is part of the LibCompiler. */ /* (c) Theater Quality Incorporated */ /// @author EL Mahrouss Amlal (amlel) @@ -97,7 +97,7 @@ namespace Details { std::vector<CompilerRegisterMap> fStackMapVector; std::vector<CompilerStructMap> fStructMapVector; - ToolchainKit::SyntaxLeafList* fSyntaxTree{nullptr}; + LibCompiler::SyntaxLeafList* fSyntaxTree{nullptr}; std::unique_ptr<std::ofstream> fOutputAssembly; std::string fLastFile; std::string fLastError; @@ -127,7 +127,7 @@ namespace Details ///////////////////////////////////////////////////////////////////////////////////////// // Target architecture. -static int kMachine = ToolchainKit::AssemblyFactory::kArchAMD64; +static int kMachine = LibCompiler::AssemblyFactory::kArchAMD64; ///////////////////////////////////////// @@ -139,7 +139,7 @@ static size_t kRegisterCnt = kAsmRegisterLimit; static size_t kStartUsable = 8; static size_t kUsableLimit = 15; static size_t kRegisterCounter = kStartUsable; -static std::vector<ToolchainKit::CompilerKeyword> kKeywords; +static std::vector<LibCompiler::CompilerKeyword> kKeywords; ///////////////////////////////////////// @@ -148,7 +148,7 @@ static std::vector<ToolchainKit::CompilerKeyword> kKeywords; ///////////////////////////////////////// static std::vector<std::string> kFileList; -static ToolchainKit::AssemblyFactory kFactory; +static LibCompiler::AssemblyFactory kFactory; static bool kInStruct = false; static bool kOnWhileLoop = false; static bool kOnForLoop = false; @@ -156,7 +156,7 @@ static bool kInBraces = false; static size_t kBracesCount = 0UL; /* @brief C++ compiler backend for the ZKA C++ driver */ -class CompilerFrontendCPlusPlus final : public ToolchainKit::ICompilerFrontend +class CompilerFrontendCPlusPlus final : public LibCompiler::ICompilerFrontend { public: explicit CompilerFrontendCPlusPlus() = default; @@ -226,7 +226,7 @@ bool CompilerFrontendCPlusPlus::Compile(const std::string text, return false; std::size_t index = 0UL; - std::vector<std::pair<ToolchainKit::CompilerKeyword, std::size_t>> keywords_list; + std::vector<std::pair<LibCompiler::CompilerKeyword, std::size_t>> keywords_list; bool found = false; static bool commentBlock = false; @@ -237,15 +237,15 @@ bool CompilerFrontendCPlusPlus::Compile(const std::string text, { switch (keyword.keyword_kind) { - case ToolchainKit::eKeywordKindCommentMultiLineStart: { + case LibCompiler::eKeywordKindCommentMultiLineStart: { commentBlock = true; return true; } - case ToolchainKit::eKeywordKindCommentMultiLineEnd: { + case LibCompiler::eKeywordKindCommentMultiLineEnd: { commentBlock = false; break; } - case ToolchainKit::eKeywordKindCommentInline: { + case LibCompiler::eKeywordKindCommentInline: { break; } default: @@ -253,15 +253,15 @@ bool CompilerFrontendCPlusPlus::Compile(const std::string text, } if (text[text.find(keyword.keyword_name) - 1] == '+' && - keyword.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableAssign) + keyword.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableAssign) continue; if (text[text.find(keyword.keyword_name) - 1] == '-' && - keyword.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableAssign) + keyword.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableAssign) continue; if (text[text.find(keyword.keyword_name) + 1] == '=' && - keyword.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableAssign) + keyword.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableAssign) continue; keywords_list.emplace_back(std::make_pair(keyword, index)); @@ -285,11 +285,11 @@ bool CompilerFrontendCPlusPlus::Compile(const std::string text, for (auto& keyword : keywords_list) { - auto syntax_tree = ToolchainKit::SyntaxLeafList::SyntaxLeaf(); + auto syntax_tree = LibCompiler::SyntaxLeafList::SyntaxLeaf(); switch (keyword.first.keyword_kind) { - case ToolchainKit::KeywordKind::eKeywordKindIf: { + case LibCompiler::KeywordKind::eKeywordKindIf: { auto expr = text.substr(text.find(keyword.first.keyword_name) + keyword.first.keyword_name.size() + 1, text.find(")") - 1); if (expr.find(">=") != std::string::npos) @@ -377,7 +377,7 @@ bool CompilerFrontendCPlusPlus::Compile(const std::string text, break; } - case ToolchainKit::KeywordKind::eKeywordKindFunctionStart: { + case LibCompiler::KeywordKind::eKeywordKindFunctionStart: { for (auto& ch : text) { if (isdigit(ch)) @@ -439,7 +439,7 @@ bool CompilerFrontendCPlusPlus::Compile(const std::string text, tk_write_assembly: syntax_tree.fUserValue = "jmp __TOOLCHAINKIT_" + fnName + "\n"; } - case ToolchainKit::KeywordKind::eKeywordKindFunctionEnd: { + case LibCompiler::KeywordKind::eKeywordKindFunctionEnd: { if (text.ends_with(";")) break; @@ -454,50 +454,50 @@ tk_write_assembly: kRegisterMap.clear(); break; } - case ToolchainKit::KeywordKind::eKeywordKindEndInstr: - case ToolchainKit::KeywordKind::eKeywordKindVariableInc: - case ToolchainKit::KeywordKind::eKeywordKindVariableDec: - case ToolchainKit::KeywordKind::eKeywordKindVariableAssign: { + case LibCompiler::KeywordKind::eKeywordKindEndInstr: + case LibCompiler::KeywordKind::eKeywordKindVariableInc: + case LibCompiler::KeywordKind::eKeywordKindVariableDec: + case LibCompiler::KeywordKind::eKeywordKindVariableAssign: { std::string valueOfVar = ""; - if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableInc) + if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableInc) { valueOfVar = text.substr(text.find("+=") + 2); } - else if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableDec) + else if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableDec) { valueOfVar = text.substr(text.find("-=") + 2); } - else if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableAssign) + else if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableAssign) { valueOfVar = text.substr(text.find("=") + 1); } - else if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindEndInstr) + else if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindEndInstr) { break; } while (valueOfVar.find(";") != std::string::npos && - keyword.first.keyword_kind != ToolchainKit::KeywordKind::eKeywordKindEndInstr) + keyword.first.keyword_kind != LibCompiler::KeywordKind::eKeywordKindEndInstr) { valueOfVar.erase(valueOfVar.find(";")); } std::string varName = text; - if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableInc) + if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableInc) { varName.erase(varName.find("+=")); } - else if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableDec) + else if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableDec) { varName.erase(varName.find("-=")); } - else if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableAssign) + else if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableAssign) { varName.erase(varName.find("=")); } - else if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindEndInstr) + else if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindEndInstr) { varName.erase(varName.find(";")); } @@ -506,7 +506,7 @@ tk_write_assembly: for (auto& keyword : kKeywords) { - if (keyword.keyword_kind == ToolchainKit::eKeywordKindType) + if (keyword.keyword_kind == LibCompiler::eKeywordKindType) { if (text.find(keyword.keyword_name) != std::string::npos) { @@ -523,8 +523,8 @@ tk_write_assembly: std::string instr = "mov "; - if (typeFound && keyword.first.keyword_kind != ToolchainKit::KeywordKind::eKeywordKindVariableInc && - keyword.first.keyword_kind != ToolchainKit::KeywordKind::eKeywordKindVariableDec) + if (typeFound && keyword.first.keyword_kind != LibCompiler::KeywordKind::eKeywordKindVariableInc && + keyword.first.keyword_kind != LibCompiler::KeywordKind::eKeywordKindVariableDec) { if (kRegisterMap.size() > kRegisterList.size()) { @@ -617,7 +617,7 @@ tk_write_assembly: done: for (auto& keyword : kKeywords) { - if (keyword.keyword_kind == ToolchainKit::eKeywordKindType && + if (keyword.keyword_kind == LibCompiler::eKeywordKindType && varName.find(keyword.keyword_name) != std::string::npos) { varName.erase(varName.find(keyword.keyword_name), keyword.keyword_name.size()); @@ -630,24 +630,24 @@ tk_write_assembly: break; } - if (kKeywords[keyword.second - 1].keyword_kind == ToolchainKit::eKeywordKindType || - kKeywords[keyword.second - 1].keyword_kind == ToolchainKit::eKeywordKindTypePtr) + if (kKeywords[keyword.second - 1].keyword_kind == LibCompiler::eKeywordKindType || + kKeywords[keyword.second - 1].keyword_kind == LibCompiler::eKeywordKindTypePtr) { syntax_tree.fUserValue = "\n"; continue; } - if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindEndInstr) + if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindEndInstr) { syntax_tree.fUserValue = "\n"; continue; } - if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableInc) + if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableInc) { instr = "add "; } - else if (keyword.first.keyword_kind == ToolchainKit::KeywordKind::eKeywordKindVariableDec) + else if (keyword.first.keyword_kind == LibCompiler::KeywordKind::eKeywordKindVariableDec) { instr = "sub "; } @@ -731,7 +731,7 @@ tk_write_assembly: break; } - case ToolchainKit::KeywordKind::eKeywordKindReturn: { + case LibCompiler::KeywordKind::eKeywordKindReturn: { try { auto pos = text.find("return") + strlen("return") + 1; @@ -810,7 +810,7 @@ public: [[maybe_unused]] static Int32 Arch() noexcept { - return ToolchainKit::AssemblyFactory::kArchAMD64; + return LibCompiler::AssemblyFactory::kArchAMD64; } Int32 CompileToFormat(std::string& src, Int32 arch) override @@ -832,7 +832,7 @@ public: if (dest.empty()) { - dest = "CXX-ToolchainKit-"; + dest = "CXX-LibCompiler-"; std::random_device rd; auto seed_data = std::array<int, std::mt19937::state_size>{}; @@ -850,7 +850,7 @@ public: kState.fOutputAssembly = std::make_unique<std::ofstream>(dest); - auto fmt = ToolchainKit::current_date(); + auto fmt = LibCompiler::current_date(); (*kState.fOutputAssembly) << "; Repository Path: /" << src_file << "\n"; @@ -872,12 +872,12 @@ public: } (*kState.fOutputAssembly) - << "; Assembler Dialect: AMD64 ToolchainKit Assembler. (Generated from C++)\n"; + << "; Assembler Dialect: AMD64 LibCompiler Assembler. (Generated from C++)\n"; (*kState.fOutputAssembly) << "; Date: " << fmt << "\n"; (*kState.fOutputAssembly) << "#bits 64\n#org 0x1000000" << "\n"; - kState.fSyntaxTree = new ToolchainKit::SyntaxLeafList(); + kState.fSyntaxTree = new LibCompiler::SyntaxLeafList(); // =================================== // Parse source file. @@ -928,63 +928,63 @@ TOOLCHAINKIT_MODULE(CompilerCPlusPlusX8664) { bool skip = false; - kKeywords.push_back({.keyword_name = "if", .keyword_kind = ToolchainKit::eKeywordKindIf}); - kKeywords.push_back({.keyword_name = "else", .keyword_kind = ToolchainKit::eKeywordKindElse}); - kKeywords.push_back({.keyword_name = "else if", .keyword_kind = ToolchainKit::eKeywordKindElseIf}); - - kKeywords.push_back({.keyword_name = "class", .keyword_kind = ToolchainKit::eKeywordKindClass}); - kKeywords.push_back({.keyword_name = "struct", .keyword_kind = ToolchainKit::eKeywordKindClass}); - kKeywords.push_back({.keyword_name = "namespace", .keyword_kind = ToolchainKit::eKeywordKindNamespace}); - kKeywords.push_back({.keyword_name = "typedef", .keyword_kind = ToolchainKit::eKeywordKindTypedef}); - kKeywords.push_back({.keyword_name = "using", .keyword_kind = ToolchainKit::eKeywordKindTypedef}); - kKeywords.push_back({.keyword_name = "{", .keyword_kind = ToolchainKit::eKeywordKindBodyStart}); - kKeywords.push_back({.keyword_name = "}", .keyword_kind = ToolchainKit::eKeywordKindBodyEnd}); - kKeywords.push_back({.keyword_name = "auto", .keyword_kind = ToolchainKit::eKeywordKindVariable}); - kKeywords.push_back({.keyword_name = "int", .keyword_kind = ToolchainKit::eKeywordKindType}); - kKeywords.push_back({.keyword_name = "bool", .keyword_kind = ToolchainKit::eKeywordKindType}); - kKeywords.push_back({.keyword_name = "unsigned", .keyword_kind = ToolchainKit::eKeywordKindType}); - kKeywords.push_back({.keyword_name = "short", .keyword_kind = ToolchainKit::eKeywordKindType}); - kKeywords.push_back({.keyword_name = "char", .keyword_kind = ToolchainKit::eKeywordKindType}); - kKeywords.push_back({.keyword_name = "long", .keyword_kind = ToolchainKit::eKeywordKindType}); - kKeywords.push_back({.keyword_name = "float", .keyword_kind = ToolchainKit::eKeywordKindType}); - kKeywords.push_back({.keyword_name = "double", .keyword_kind = ToolchainKit::eKeywordKindType}); - kKeywords.push_back({.keyword_name = "void", .keyword_kind = ToolchainKit::eKeywordKindType}); - - kKeywords.push_back({.keyword_name = "auto*", .keyword_kind = ToolchainKit::eKeywordKindVariablePtr}); - kKeywords.push_back({.keyword_name = "int*", .keyword_kind = ToolchainKit::eKeywordKindTypePtr}); - kKeywords.push_back({.keyword_name = "bool*", .keyword_kind = ToolchainKit::eKeywordKindTypePtr}); - kKeywords.push_back({.keyword_name = "unsigned*", .keyword_kind = ToolchainKit::eKeywordKindTypePtr}); - kKeywords.push_back({.keyword_name = "short*", .keyword_kind = ToolchainKit::eKeywordKindTypePtr}); - kKeywords.push_back({.keyword_name = "char*", .keyword_kind = ToolchainKit::eKeywordKindTypePtr}); - kKeywords.push_back({.keyword_name = "long*", .keyword_kind = ToolchainKit::eKeywordKindTypePtr}); - kKeywords.push_back({.keyword_name = "float*", .keyword_kind = ToolchainKit::eKeywordKindTypePtr}); - kKeywords.push_back({.keyword_name = "double*", .keyword_kind = ToolchainKit::eKeywordKindTypePtr}); - kKeywords.push_back({.keyword_name = "void*", .keyword_kind = ToolchainKit::eKeywordKindTypePtr}); - - kKeywords.push_back({.keyword_name = "(", .keyword_kind = ToolchainKit::eKeywordKindFunctionStart}); - kKeywords.push_back({.keyword_name = ")", .keyword_kind = ToolchainKit::eKeywordKindFunctionEnd}); - kKeywords.push_back({.keyword_name = "=", .keyword_kind = ToolchainKit::eKeywordKindVariableAssign}); - kKeywords.push_back({.keyword_name = "+=", .keyword_kind = ToolchainKit::eKeywordKindVariableInc}); - kKeywords.push_back({.keyword_name = "-=", .keyword_kind = ToolchainKit::eKeywordKindVariableDec}); - kKeywords.push_back({.keyword_name = "const", .keyword_kind = ToolchainKit::eKeywordKindConstant}); - kKeywords.push_back({.keyword_name = "*", .keyword_kind = ToolchainKit::eKeywordKindPtr}); - kKeywords.push_back({.keyword_name = "->", .keyword_kind = ToolchainKit::eKeywordKindPtrAccess}); - kKeywords.push_back({.keyword_name = ".", .keyword_kind = ToolchainKit::eKeywordKindAccess}); - kKeywords.push_back({.keyword_name = ",", .keyword_kind = ToolchainKit::eKeywordKindArgSeparator}); - kKeywords.push_back({.keyword_name = ";", .keyword_kind = ToolchainKit::eKeywordKindEndInstr}); - kKeywords.push_back({.keyword_name = ":", .keyword_kind = ToolchainKit::eKeywordKindSpecifier}); - kKeywords.push_back({.keyword_name = "public:", .keyword_kind = ToolchainKit::eKeywordKindSpecifier}); - kKeywords.push_back({.keyword_name = "private:", .keyword_kind = ToolchainKit::eKeywordKindSpecifier}); - kKeywords.push_back({.keyword_name = "protected:", .keyword_kind = ToolchainKit::eKeywordKindSpecifier}); - kKeywords.push_back({.keyword_name = "final", .keyword_kind = ToolchainKit::eKeywordKindSpecifier}); - kKeywords.push_back({.keyword_name = "return", .keyword_kind = ToolchainKit::eKeywordKindReturn}); - kKeywords.push_back({.keyword_name = "--*", .keyword_kind = ToolchainKit::eKeywordKindCommentMultiLineStart}); - kKeywords.push_back({.keyword_name = "*/", .keyword_kind = ToolchainKit::eKeywordKindCommentMultiLineStart}); - kKeywords.push_back({.keyword_name = "--/", .keyword_kind = ToolchainKit::eKeywordKindCommentInline}); - kKeywords.push_back({.keyword_name = "==", .keyword_kind = ToolchainKit::eKeywordKindEq}); - kKeywords.push_back({.keyword_name = "!=", .keyword_kind = ToolchainKit::eKeywordKindNotEq}); - kKeywords.push_back({.keyword_name = ">=", .keyword_kind = ToolchainKit::eKeywordKindGreaterEq}); - kKeywords.push_back({.keyword_name = "<=", .keyword_kind = ToolchainKit::eKeywordKindLessEq}); + kKeywords.push_back({.keyword_name = "if", .keyword_kind = LibCompiler::eKeywordKindIf}); + kKeywords.push_back({.keyword_name = "else", .keyword_kind = LibCompiler::eKeywordKindElse}); + kKeywords.push_back({.keyword_name = "else if", .keyword_kind = LibCompiler::eKeywordKindElseIf}); + + kKeywords.push_back({.keyword_name = "class", .keyword_kind = LibCompiler::eKeywordKindClass}); + kKeywords.push_back({.keyword_name = "struct", .keyword_kind = LibCompiler::eKeywordKindClass}); + kKeywords.push_back({.keyword_name = "namespace", .keyword_kind = LibCompiler::eKeywordKindNamespace}); + kKeywords.push_back({.keyword_name = "typedef", .keyword_kind = LibCompiler::eKeywordKindTypedef}); + kKeywords.push_back({.keyword_name = "using", .keyword_kind = LibCompiler::eKeywordKindTypedef}); + kKeywords.push_back({.keyword_name = "{", .keyword_kind = LibCompiler::eKeywordKindBodyStart}); + kKeywords.push_back({.keyword_name = "}", .keyword_kind = LibCompiler::eKeywordKindBodyEnd}); + kKeywords.push_back({.keyword_name = "auto", .keyword_kind = LibCompiler::eKeywordKindVariable}); + kKeywords.push_back({.keyword_name = "int", .keyword_kind = LibCompiler::eKeywordKindType}); + kKeywords.push_back({.keyword_name = "bool", .keyword_kind = LibCompiler::eKeywordKindType}); + kKeywords.push_back({.keyword_name = "unsigned", .keyword_kind = LibCompiler::eKeywordKindType}); + kKeywords.push_back({.keyword_name = "short", .keyword_kind = LibCompiler::eKeywordKindType}); + kKeywords.push_back({.keyword_name = "char", .keyword_kind = LibCompiler::eKeywordKindType}); + kKeywords.push_back({.keyword_name = "long", .keyword_kind = LibCompiler::eKeywordKindType}); + kKeywords.push_back({.keyword_name = "float", .keyword_kind = LibCompiler::eKeywordKindType}); + kKeywords.push_back({.keyword_name = "double", .keyword_kind = LibCompiler::eKeywordKindType}); + kKeywords.push_back({.keyword_name = "void", .keyword_kind = LibCompiler::eKeywordKindType}); + + kKeywords.push_back({.keyword_name = "auto*", .keyword_kind = LibCompiler::eKeywordKindVariablePtr}); + kKeywords.push_back({.keyword_name = "int*", .keyword_kind = LibCompiler::eKeywordKindTypePtr}); + kKeywords.push_back({.keyword_name = "bool*", .keyword_kind = LibCompiler::eKeywordKindTypePtr}); + kKeywords.push_back({.keyword_name = "unsigned*", .keyword_kind = LibCompiler::eKeywordKindTypePtr}); + kKeywords.push_back({.keyword_name = "short*", .keyword_kind = LibCompiler::eKeywordKindTypePtr}); + kKeywords.push_back({.keyword_name = "char*", .keyword_kind = LibCompiler::eKeywordKindTypePtr}); + kKeywords.push_back({.keyword_name = "long*", .keyword_kind = LibCompiler::eKeywordKindTypePtr}); + kKeywords.push_back({.keyword_name = "float*", .keyword_kind = LibCompiler::eKeywordKindTypePtr}); + kKeywords.push_back({.keyword_name = "double*", .keyword_kind = LibCompiler::eKeywordKindTypePtr}); + kKeywords.push_back({.keyword_name = "void*", .keyword_kind = LibCompiler::eKeywordKindTypePtr}); + + kKeywords.push_back({.keyword_name = "(", .keyword_kind = LibCompiler::eKeywordKindFunctionStart}); + kKeywords.push_back({.keyword_name = ")", .keyword_kind = LibCompiler::eKeywordKindFunctionEnd}); + kKeywords.push_back({.keyword_name = "=", .keyword_kind = LibCompiler::eKeywordKindVariableAssign}); + kKeywords.push_back({.keyword_name = "+=", .keyword_kind = LibCompiler::eKeywordKindVariableInc}); + kKeywords.push_back({.keyword_name = "-=", .keyword_kind = LibCompiler::eKeywordKindVariableDec}); + kKeywords.push_back({.keyword_name = "const", .keyword_kind = LibCompiler::eKeywordKindConstant}); + kKeywords.push_back({.keyword_name = "*", .keyword_kind = LibCompiler::eKeywordKindPtr}); + kKeywords.push_back({.keyword_name = "->", .keyword_kind = LibCompiler::eKeywordKindPtrAccess}); + kKeywords.push_back({.keyword_name = ".", .keyword_kind = LibCompiler::eKeywordKindAccess}); + kKeywords.push_back({.keyword_name = ",", .keyword_kind = LibCompiler::eKeywordKindArgSeparator}); + kKeywords.push_back({.keyword_name = ";", .keyword_kind = LibCompiler::eKeywordKindEndInstr}); + kKeywords.push_back({.keyword_name = ":", .keyword_kind = LibCompiler::eKeywordKindSpecifier}); + kKeywords.push_back({.keyword_name = "public:", .keyword_kind = LibCompiler::eKeywordKindSpecifier}); + kKeywords.push_back({.keyword_name = "private:", .keyword_kind = LibCompiler::eKeywordKindSpecifier}); + kKeywords.push_back({.keyword_name = "protected:", .keyword_kind = LibCompiler::eKeywordKindSpecifier}); + kKeywords.push_back({.keyword_name = "final", .keyword_kind = LibCompiler::eKeywordKindSpecifier}); + kKeywords.push_back({.keyword_name = "return", .keyword_kind = LibCompiler::eKeywordKindReturn}); + kKeywords.push_back({.keyword_name = "--*", .keyword_kind = LibCompiler::eKeywordKindCommentMultiLineStart}); + kKeywords.push_back({.keyword_name = "*/", .keyword_kind = LibCompiler::eKeywordKindCommentMultiLineStart}); + kKeywords.push_back({.keyword_name = "--/", .keyword_kind = LibCompiler::eKeywordKindCommentInline}); + kKeywords.push_back({.keyword_name = "==", .keyword_kind = LibCompiler::eKeywordKindEq}); + kKeywords.push_back({.keyword_name = "!=", .keyword_kind = LibCompiler::eKeywordKindNotEq}); + kKeywords.push_back({.keyword_name = ">=", .keyword_kind = LibCompiler::eKeywordKindGreaterEq}); + kKeywords.push_back({.keyword_name = "<=", .keyword_kind = LibCompiler::eKeywordKindLessEq}); kFactory.Mount(new AssemblyCPlusPlusInterface()); kCompilerFrontend = new CompilerFrontendCPlusPlus(); diff --git a/dev/ToolchainKit/src/CPlusPlusCompilerPreProcessor.cc b/dev/LibCompiler/src/CPlusPlusCompilerPreProcessor.cc index 3550a4c..819cfc7 100644 --- a/dev/ToolchainKit/src/CPlusPlusCompilerPreProcessor.cc +++ b/dev/LibCompiler/src/CPlusPlusCompilerPreProcessor.cc @@ -9,8 +9,8 @@ /// BUGS: 0 -#include <ToolchainKit/Parser.h> -#include <ToolchainKit/NFC/ErrorID.h> +#include <LibCompiler/Parser.h> +#include <LibCompiler/NFC/ErrorID.h> #include <algorithm> #include <filesystem> #include <fstream> @@ -370,21 +370,21 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) for (auto macro : kMacros) { - if (ToolchainKit::find_word(hdr_line, macro.fName)) + if (LibCompiler::find_word(hdr_line, macro.fName)) { - if (hdr_line.substr(hdr_line.find(macro.fName)).find(macro.fName + '(') != ToolchainKit::String::npos) + if (hdr_line.substr(hdr_line.find(macro.fName)).find(macro.fName + '(') != LibCompiler::String::npos) { if (!macro.fArgs.empty()) { - ToolchainKit::String symbol_val = macro.fValue; - std::vector<ToolchainKit::String> args; + LibCompiler::String symbol_val = macro.fValue; + std::vector<LibCompiler::String> args; size_t x_arg_indx = 0; - ToolchainKit::String line_after_define = hdr_line; - ToolchainKit::String str_arg; + LibCompiler::String line_after_define = hdr_line; + LibCompiler::String str_arg; - if (line_after_define.find("(") != ToolchainKit::String::npos) + if (line_after_define.find("(") != LibCompiler::String::npos) { line_after_define.erase(0, line_after_define.find("(") + 1); @@ -411,7 +411,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]) != ToolchainKit::String::npos) + if (symbol_val.find(macro.fArgs[x_arg_indx]) != LibCompiler::String::npos) { symbol_val.replace(symbol_val.find(macro.fArgs[x_arg_indx]), macro.fArgs[x_arg_indx].size(), args[x_arg_indx]); @@ -494,7 +494,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) std::string str; - if (line_after_define.find("(") != ToolchainKit::String::npos) + if (line_after_define.find("(") != LibCompiler::String::npos) { line_after_define.erase(0, line_after_define.find("(") + 1); diff --git a/dev/ToolchainKit/src/Detail/AsmUtils.h b/dev/LibCompiler/src/Detail/AsmUtils.h index 369e415..0825fa5 100644 --- a/dev/ToolchainKit/src/Detail/AsmUtils.h +++ b/dev/LibCompiler/src/Detail/AsmUtils.h @@ -6,10 +6,10 @@ #pragma once -#include <ToolchainKit/AAL/AssemblyInterface.h> -#include <ToolchainKit/Parser.h> +#include <LibCompiler/AAL/AssemblyInterface.h> +#include <LibCompiler/Parser.h> -using namespace ToolchainKit; +using namespace LibCompiler; namespace Details { @@ -37,7 +37,7 @@ static NumberCast32 GetNumber32(std::string lineBuffer, std::string numberKey) { if (errno != 0) { - Details::print_error("invalid hex number: " + lineBuffer, "ToolchainKit"); + Details::print_error("invalid hex number: " + lineBuffer, "LibCompiler"); throw std::runtime_error("invalid_hex"); } } @@ -57,7 +57,7 @@ static NumberCast32 GetNumber32(std::string lineBuffer, std::string numberKey) { if (errno != 0) { - Details::print_error("invalid binary number:" + lineBuffer, "ToolchainKit"); + Details::print_error("invalid binary number:" + lineBuffer, "LibCompiler"); throw std::runtime_error("invalid_bin"); } } @@ -77,7 +77,7 @@ static NumberCast32 GetNumber32(std::string lineBuffer, std::string numberKey) { if (errno != 0) { - Details::print_error("invalid octal number: " + lineBuffer, "ToolchainKit"); + Details::print_error("invalid octal number: " + lineBuffer, "LibCompiler"); throw std::runtime_error("invalid_octal"); } } @@ -97,7 +97,7 @@ static NumberCast32 GetNumber32(std::string lineBuffer, std::string numberKey) { if (errno != 0) { - Details::print_error("invalid hex number: " + lineBuffer, "ToolchainKit"); + Details::print_error("invalid hex number: " + lineBuffer, "LibCompiler"); throw std::runtime_error("invalid_hex"); } } diff --git a/dev/ToolchainKit/src/Detail/ClUtils.h b/dev/LibCompiler/src/Detail/ClUtils.h index 953c801..4596148 100644 --- a/dev/ToolchainKit/src/Detail/ClUtils.h +++ b/dev/LibCompiler/src/Detail/ClUtils.h @@ -6,8 +6,8 @@ #pragma once -#include <ToolchainKit/AAL/AssemblyInterface.h> -#include <ToolchainKit/Parser.h> +#include <LibCompiler/AAL/AssemblyInterface.h> +#include <LibCompiler/Parser.h> #define kZero64Section ".zero64" #define kCode64Section ".code64" diff --git a/dev/ToolchainKit/src/Detail/ReadMe.md b/dev/LibCompiler/src/Detail/ReadMe.md index e9d0a2c..e9d0a2c 100644 --- a/dev/ToolchainKit/src/Detail/ReadMe.md +++ b/dev/LibCompiler/src/Detail/ReadMe.md diff --git a/dev/ToolchainKit/src/DynamicLinker64PEF.cc b/dev/LibCompiler/src/DynamicLinker64PEF.cc index 14042ec..67b6105 100644 --- a/dev/ToolchainKit/src/DynamicLinker64PEF.cc +++ b/dev/LibCompiler/src/DynamicLinker64PEF.cc @@ -14,22 +14,22 @@ /// It will be loaded when the program loader will start the image. //! Toolchain Kit. -#include <ToolchainKit/Defines.h> +#include <LibCompiler/Defines.h> -#include <ToolchainKit/NFC/ErrorID.h> +#include <LibCompiler/NFC/ErrorID.h> //! Assembler Kit -#include <ToolchainKit/AAL/AssemblyInterface.h> +#include <LibCompiler/AAL/AssemblyInterface.h> //! Preferred Executable Format -#include <ToolchainKit/NFC/PEF.h> -#include <ToolchainKit/UUID.h> +#include <LibCompiler/NFC/PEF.h> +#include <LibCompiler/UUID.h> //! Release macros. -#include <ToolchainKit/Version.h> +#include <LibCompiler/Version.h> //! Advanced Executable Object Format. -#include <ToolchainKit/NFC/AE.h> +#include <LibCompiler/NFC/AE.h> #include <cstdint> #define kLinkerVersionStr "TQ Media 64-Bit Linker %s, (c) Theater Quality Incorporated 2024, all rights reserved.\n" @@ -67,10 +67,10 @@ enum kABITypeInvalid = 0xFFFF, }; -static ToolchainKit::String kOutput = ""; +static LibCompiler::String kOutput = ""; static Int32 kAbi = kABITypeZKA; static Int32 kSubArch = kPefNoSubCpu; -static Int32 kArch = ToolchainKit::kPefArchInvalid; +static Int32 kArch = LibCompiler::kPefArchInvalid; static Bool kFatBinaryEnable = false; static Bool kStartFound = false; static Bool kDuplicateSymbols = false; @@ -81,7 +81,7 @@ static const char* kLdDefineSymbol = ":UndefinedSymbol:"; static const char* kLdDynamicSym = ":RuntimeSymbol:"; /* object code and list. */ -static std::vector<ToolchainKit::String> kObjectList; +static std::vector<LibCompiler::String> kObjectList; static std::vector<Details::DynamicLinkerBlob> kObjectBytes; static uintptr_t kMIBCount = 8; @@ -133,37 +133,37 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) } else if (StringCompare(argv[linker_arg], "--ld64:64k") == 0) { - kArch = ToolchainKit::kPefArch64000; + kArch = LibCompiler::kPefArch64000; continue; } else if (StringCompare(argv[linker_arg], "--ld64:amd64") == 0) { - kArch = ToolchainKit::kPefArchAMD64; + kArch = LibCompiler::kPefArchAMD64; continue; } else if (StringCompare(argv[linker_arg], "--ld64:32k") == 0) { - kArch = ToolchainKit::kPefArch32000; + kArch = LibCompiler::kPefArch32000; continue; } else if (StringCompare(argv[linker_arg], "--ld64:power64") == 0) { - kArch = ToolchainKit::kPefArchPowerPC; + kArch = LibCompiler::kPefArchPowerPC; continue; } else if (StringCompare(argv[linker_arg], "--ld64:riscv64") == 0) { - kArch = ToolchainKit::kPefArchRISCV; + kArch = LibCompiler::kPefArchRISCV; continue; } else if (StringCompare(argv[linker_arg], "--ld64:arm64") == 0) { - kArch = ToolchainKit::kPefArchARM64; + kArch = LibCompiler::kPefArchARM64; continue; } @@ -180,7 +180,7 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) continue; } - if (kOutput.find(kPefExt) != ToolchainKit::String::npos) + if (kOutput.find(kPefExt) != LibCompiler::String::npos) kOutput.erase(kOutput.find(kPefExt), strlen(kPefExt)); kOutput += kPefDylibExt; @@ -246,12 +246,12 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) return TOOLCHAINKIT_EXEC_ERROR; } - ToolchainKit::PEFContainer pef_container{}; + LibCompiler::PEFContainer pef_container{}; int32_t archs = kArch; pef_container.Count = 0UL; - pef_container.Kind = is_executable ? ToolchainKit::kPefKindExec : ToolchainKit::kPefKindDylib; + pef_container.Kind = is_executable ? LibCompiler::kPefKindExec : LibCompiler::kPefKindDylib; pef_container.SubCpu = kSubArch; pef_container.Linker = kLinkerId; // Theater Quality Incorporated Linker pef_container.Abi = kAbi; // Multi-Processor UX ABI @@ -263,7 +263,7 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) // specify the start address, can be 0x10000 pef_container.Start = kLinkerDefaultOrigin; - pef_container.HdrSz = sizeof(ToolchainKit::PEFContainer); + pef_container.HdrSz = sizeof(LibCompiler::PEFContainer); std::ofstream output_fc(kOutput, std::ofstream::binary); @@ -279,15 +279,15 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) //! Read AE to convert as PEF. - std::vector<ToolchainKit::PEFCommandHeader> command_headers; - ToolchainKit::Utils::AEReadableProtocol reader_protocol{}; + std::vector<LibCompiler::PEFCommandHeader> command_headers; + LibCompiler::Utils::AEReadableProtocol reader_protocol{}; for (const auto& objectFile : kObjectList) { if (!std::filesystem::exists(objectFile)) continue; - ToolchainKit::AEHeader hdr{}; + LibCompiler::AEHeader hdr{}; reader_protocol.FP = std::ifstream(objectFile, std::ifstream::binary); reader_protocol.FP >> hdr; @@ -295,7 +295,7 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) auto ae_header = hdr; if (ae_header.fMagic[0] == kAEMag0 && ae_header.fMagic[1] == kAEMag1 && - ae_header.fSize == sizeof(ToolchainKit::AEHeader)) + ae_header.fSize == sizeof(LibCompiler::AEHeader)) { if (ae_header.fArch != kArch) { @@ -333,37 +333,37 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) pef_container.Count = cnt; char_type* raw_ae_records = - new char_type[cnt * sizeof(ToolchainKit::AERecordHeader)]; + new char_type[cnt * sizeof(LibCompiler::AERecordHeader)]; - memset(raw_ae_records, 0, cnt * sizeof(ToolchainKit::AERecordHeader)); + memset(raw_ae_records, 0, cnt * sizeof(LibCompiler::AERecordHeader)); auto* ae_records = reader_protocol.Read(raw_ae_records, cnt); for (size_t ae_record_index = 0; ae_record_index < cnt; ++ae_record_index) { - ToolchainKit::PEFCommandHeader command_header{0}; + LibCompiler::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); - ToolchainKit::String cmd_hdr_name(command_header.Name); + LibCompiler::String cmd_hdr_name(command_header.Name); // check this header if it's any valid. if (cmd_hdr_name.find(kPefCode64) == - ToolchainKit::String::npos && + LibCompiler::String::npos && cmd_hdr_name.find(kPefData64) == - ToolchainKit::String::npos && + LibCompiler::String::npos && cmd_hdr_name.find(kPefZero64) == - ToolchainKit::String::npos) + LibCompiler::String::npos) { if (cmd_hdr_name.find(kPefStart) == - ToolchainKit::String::npos && + LibCompiler::String::npos && *command_header.Name == 0) { if (cmd_hdr_name.find(kLdDefineSymbol) != - ToolchainKit::String::npos) + LibCompiler::String::npos) { goto ld_mark_header; } @@ -375,9 +375,9 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) } if (cmd_hdr_name.find(kPefStart) != - ToolchainKit::String::npos && + LibCompiler::String::npos && cmd_hdr_name.find(kPefCode64) != - ToolchainKit::String::npos) + LibCompiler::String::npos) { kStartFound = true; } @@ -436,23 +436,23 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) output_fc.seekp(std::streamsize(pef_container.HdrSz)); - std::vector<ToolchainKit::String> not_found; - std::vector<ToolchainKit::String> symbols; + std::vector<LibCompiler::String> not_found; + std::vector<LibCompiler::String> 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 (ToolchainKit::String(command_hdr.Name).find(kLdDefineSymbol) != - ToolchainKit::String::npos && - ToolchainKit::String(command_hdr.Name).find(kLdDynamicSym) == ToolchainKit::String::npos) + if (LibCompiler::String(command_hdr.Name).find(kLdDefineSymbol) != + LibCompiler::String::npos && + LibCompiler::String(command_hdr.Name).find(kLdDynamicSym) == LibCompiler::String::npos) { if (kVerbose) kStdOut << "Found undefined symbol: " << command_hdr.Name << "\n"; if (auto it = std::find(not_found.begin(), not_found.end(), - ToolchainKit::String(command_hdr.Name)); + LibCompiler::String(command_hdr.Name)); it == not_found.end()) { not_found.emplace_back(command_hdr.Name); @@ -468,12 +468,12 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) ++not_found_idx) { if (const auto it = std::find(not_found.begin(), not_found.end(), - ToolchainKit::String(command_headers[not_found_idx].Name)); + LibCompiler::String(command_headers[not_found_idx].Name)); it != not_found.end()) { - ToolchainKit::String symbol_imp = *it; + LibCompiler::String symbol_imp = *it; - if (symbol_imp.find(kLdDefineSymbol) == ToolchainKit::String::npos) + if (symbol_imp.find(kLdDefineSymbol) == LibCompiler::String::npos) continue; // erase the lookup prefix. @@ -481,19 +481,19 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) 0, symbol_imp.find(kLdDefineSymbol) + strlen(kLdDefineSymbol)); // demangle everything. - while (symbol_imp.find('$') != ToolchainKit::String::npos) + while (symbol_imp.find('$') != LibCompiler::String::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 (ToolchainKit::String(command_hdr.Name).find(symbol_imp) != - ToolchainKit::String::npos && - ToolchainKit::String(command_hdr.Name).find(kLdDefineSymbol) == - ToolchainKit::String::npos) + if (LibCompiler::String(command_hdr.Name).find(symbol_imp) != + LibCompiler::String::npos && + LibCompiler::String(command_hdr.Name).find(kLdDefineSymbol) == + LibCompiler::String::npos) { - ToolchainKit::String undefined_symbol = command_hdr.Name; + LibCompiler::String undefined_symbol = command_hdr.Name; auto result_of_sym = undefined_symbol.substr(undefined_symbol.find(symbol_imp)); @@ -532,38 +532,38 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) // step 4: write all PEF commands. - ToolchainKit::PEFCommandHeader date_cmd_hdr{}; + LibCompiler::PEFCommandHeader date_cmd_hdr{}; time_t timestamp = time(nullptr); - ToolchainKit::String timeStampStr = "Container:BuildEpoch:"; + LibCompiler::String 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 = ToolchainKit::kPefZero; + date_cmd_hdr.Kind = LibCompiler::kPefZero; date_cmd_hdr.Offset = output_fc.tellp(); date_cmd_hdr.Size = timeStampStr.size(); command_headers.push_back(date_cmd_hdr); - ToolchainKit::PEFCommandHeader abi_cmd_hdr{}; + LibCompiler::PEFCommandHeader abi_cmd_hdr{}; - ToolchainKit::String abi = kLinkerAbiContainer; + LibCompiler::String abi = kLinkerAbiContainer; switch (kArch) { - case ToolchainKit::kPefArchAMD64: { + case LibCompiler::kPefArchAMD64: { abi += "MSFT"; break; } - case ToolchainKit::kPefArchPowerPC: { + case LibCompiler::kPefArchPowerPC: { abi += "SYSV"; break; } - case ToolchainKit::kPefArch32000: - case ToolchainKit::kPefArch64000: { + case LibCompiler::kPefArch32000: + case LibCompiler::kPefArch64000: { abi += " ZWS"; break; } @@ -578,11 +578,11 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) abi_cmd_hdr.Size = abi.size(); abi_cmd_hdr.Offset = output_fc.tellp(); abi_cmd_hdr.Flags = 0; - abi_cmd_hdr.Kind = ToolchainKit::kPefLinkerID; + abi_cmd_hdr.Kind = LibCompiler::kPefLinkerID; command_headers.push_back(abi_cmd_hdr); - ToolchainKit::PEFCommandHeader stack_cmd_hdr{0}; + LibCompiler::PEFCommandHeader stack_cmd_hdr{0}; stack_cmd_hdr.Cpu = kArch; stack_cmd_hdr.Flags = 0; @@ -593,7 +593,7 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) command_headers.push_back(stack_cmd_hdr); - ToolchainKit::PEFCommandHeader uuid_cmd_hdr{}; + LibCompiler::PEFCommandHeader uuid_cmd_hdr{}; std::random_device rd; @@ -612,35 +612,35 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) uuid_cmd_hdr.Size = strlen(uuid_cmd_hdr.Name); uuid_cmd_hdr.Offset = output_fc.tellp(); - uuid_cmd_hdr.Flags = ToolchainKit::kPefLinkerID; - uuid_cmd_hdr.Kind = ToolchainKit::kPefZero; + uuid_cmd_hdr.Flags = LibCompiler::kPefLinkerID; + uuid_cmd_hdr.Kind = LibCompiler::kPefZero; command_headers.push_back(uuid_cmd_hdr); // prepare a symbol vector. - std::vector<ToolchainKit::String> undef_symbols; - std::vector<ToolchainKit::String> dupl_symbols; - std::vector<ToolchainKit::String> resolve_symbols; + std::vector<LibCompiler::String> undef_symbols; + std::vector<LibCompiler::String> dupl_symbols; + std::vector<LibCompiler::String> resolve_symbols; constexpr Int32 cPaddingOffset = 16; - size_t previous_offset = (command_headers.size() * sizeof(ToolchainKit::PEFCommandHeader)) + cPaddingOffset; + size_t previous_offset = (command_headers.size() * sizeof(LibCompiler::PEFCommandHeader)) + cPaddingOffset; // Finally write down the command headers. // And check for any duplications for (size_t commandHeaderIndex = 0UL; commandHeaderIndex < command_headers.size(); ++commandHeaderIndex) { - if (ToolchainKit::String(command_headers[commandHeaderIndex].Name) - .find(kLdDefineSymbol) != ToolchainKit::String::npos && - ToolchainKit::String(command_headers[commandHeaderIndex].Name) - .find(kLdDynamicSym) == ToolchainKit::String::npos) + if (LibCompiler::String(command_headers[commandHeaderIndex].Name) + .find(kLdDefineSymbol) != LibCompiler::String::npos && + LibCompiler::String(command_headers[commandHeaderIndex].Name) + .find(kLdDynamicSym) == LibCompiler::String::npos) { // ignore :UndefinedSymbol: headers, they do not contain code. continue; } - ToolchainKit::String symbol_name = command_headers[commandHeaderIndex].Name; + LibCompiler::String symbol_name = command_headers[commandHeaderIndex].Name; if (!symbol_name.empty()) { @@ -650,13 +650,13 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) command_headers[commandHeaderIndex].Offset += previous_offset; previous_offset += command_headers[commandHeaderIndex].Size; - ToolchainKit::String name = command_headers[commandHeaderIndex].Name; + LibCompiler::String 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) != ToolchainKit::String::npos && - name.find(kPefCode64) != ToolchainKit::String::npos) + if (name.find(kPefStart) != LibCompiler::String::npos && + name.find(kPefCode64) != LibCompiler::String::npos) { pef_container.Start = command_headers[commandHeaderIndex].Offset; auto tellCurPos = output_fc.tellp(); @@ -682,10 +682,10 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) if (sub_command_header_index == commandHeaderIndex) continue; - if (ToolchainKit::String(command_headers[sub_command_header_index].Name) - .find(kLdDefineSymbol) != ToolchainKit::String::npos && - ToolchainKit::String(command_headers[sub_command_header_index].Name) - .find(kLdDynamicSym) == ToolchainKit::String::npos) + if (LibCompiler::String(command_headers[sub_command_header_index].Name) + .find(kLdDefineSymbol) != LibCompiler::String::npos && + LibCompiler::String(command_headers[sub_command_header_index].Name) + .find(kLdDynamicSym) == LibCompiler::String::npos) { if (kVerbose) { @@ -699,7 +699,7 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) auto& command_hdr = command_headers[sub_command_header_index]; if (command_hdr.Name == - ToolchainKit::String(command_headers[commandHeaderIndex].Name)) + LibCompiler::String(command_headers[commandHeaderIndex].Name)) { if (std::find(dupl_symbols.cbegin(), dupl_symbols.cend(), command_hdr.Name) == dupl_symbols.cend()) @@ -738,12 +738,12 @@ TOOLCHAINKIT_MODULE(DynamicLinker64PEF) // step 3: check if we have those symbols - std::vector<ToolchainKit::String> unreferenced_symbols; + std::vector<LibCompiler::String> unreferenced_symbols; for (auto& command_hdr : command_headers) { if (auto it = std::find(not_found.begin(), not_found.end(), - ToolchainKit::String(command_hdr.Name)); + LibCompiler::String(command_hdr.Name)); it != not_found.end()) { unreferenced_symbols.emplace_back(command_hdr.Name); diff --git a/dev/ToolchainKit/src/String.cc b/dev/LibCompiler/src/String.cc index 17f9624..0804c2b 100644 --- a/dev/ToolchainKit/src/String.cc +++ b/dev/LibCompiler/src/String.cc @@ -1,7 +1,7 @@ /* * ======================================================== * - * ToolchainKit + * LibCompiler * Copyright (C) 2024 Theater Quality Inc, all rights reserved. * * ======================================================== @@ -18,9 +18,9 @@ * */ -#include <ToolchainKit/NFC/String.h> +#include <LibCompiler/NFC/String.h> -namespace ToolchainKit +namespace LibCompiler { CharType* StringView::Data() { @@ -253,4 +253,4 @@ namespace ToolchainKit return *this; } -} // namespace ToolchainKit +} // namespace LibCompiler diff --git a/dev/CodeKit/TerminalEmulator.h b/dev/LibIDE/TerminalEmulator.h index a2cd57a..a2cd57a 100644 --- a/dev/CodeKit/TerminalEmulator.h +++ b/dev/LibIDE/TerminalEmulator.h |
