summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler/src
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-23 03:48:06 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-05-23 03:48:06 +0200
commit2eed4954c762bb8050e40798c3d9f1d3998324d1 (patch)
tree8848d4345fca4d62c23d1e7136eeff2978c9e6c5 /dev/LibCompiler/src
parent8ad58a91a11380203c4a81fe4dc93e7734631b32 (diff)
feat!(LibCompiler): Codebase and diagram has been improved.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler/src')
-rw-r--r--dev/LibCompiler/src/Asm/Assembler32x0.cc (renamed from dev/LibCompiler/src/Assembler32x0.cc)4
-rw-r--r--dev/LibCompiler/src/Asm/Assembler64x0.cc (renamed from dev/LibCompiler/src/Assembler64x0.cc)6
-rw-r--r--dev/LibCompiler/src/Asm/AssemblerAMD64.cc (renamed from dev/LibCompiler/src/AssemblerAMD64.cc)8
-rw-r--r--dev/LibCompiler/src/Asm/AssemblerARM64.cc (renamed from dev/LibCompiler/src/AssemblerARM64.cc)6
-rw-r--r--dev/LibCompiler/src/Asm/AssemblerPowerPC.cc (renamed from dev/LibCompiler/src/AssemblerPowerPC.cc)6
-rw-r--r--dev/LibCompiler/src/Cl/CCompiler64x0.cc (renamed from dev/LibCompiler/src/CCompiler64x0.cc)4
-rw-r--r--dev/LibCompiler/src/Cl/CCompilerARM64.cc (renamed from dev/LibCompiler/src/CCompilerARM64.cc)4
-rw-r--r--dev/LibCompiler/src/Cl/CCompilerPower64.cc (renamed from dev/LibCompiler/src/CCompilerPower64.cc)4
-rw-r--r--dev/LibCompiler/src/Cl/CPlusPlusCompilerAMD64.cc (renamed from dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc)10
-rw-r--r--dev/LibCompiler/src/CodeGen.cc (renamed from dev/LibCompiler/src/AssemblyFactory+AssemblyInterface.cc)10
-rw-r--r--dev/LibCompiler/src/Frontend.cc51
-rw-r--r--dev/LibCompiler/src/Linker/DynamicLinkerPEF.cc (renamed from dev/LibCompiler/src/DynamicLinkerPEF.cc)109
-rw-r--r--dev/LibCompiler/src/PP/CPlusPlusCompilerPreProcessor.cc (renamed from dev/LibCompiler/src/CPlusPlusCompilerPreProcessor.cc)139
-rw-r--r--dev/LibCompiler/src/PString.cc (renamed from dev/LibCompiler/src/StringView.cc)32
14 files changed, 226 insertions, 167 deletions
diff --git a/dev/LibCompiler/src/Assembler32x0.cc b/dev/LibCompiler/src/Asm/Assembler32x0.cc
index 44850f6..683b866 100644
--- a/dev/LibCompiler/src/Assembler32x0.cc
+++ b/dev/LibCompiler/src/Asm/Assembler32x0.cc
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
+ Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved
------------------------------------------- */
@@ -21,7 +21,7 @@
#include <LibCompiler/AE.h>
#include <LibCompiler/Backend/32x0.h>
-#include <LibCompiler/CompilerFrontend.h>
+#include <LibCompiler/Frontend.h>
#include <LibCompiler/PEF.h>
/////////////////////
diff --git a/dev/LibCompiler/src/Assembler64x0.cc b/dev/LibCompiler/src/Asm/Assembler64x0.cc
index eb5b4dd..9d07d99 100644
--- a/dev/LibCompiler/src/Assembler64x0.cc
+++ b/dev/LibCompiler/src/Asm/Assembler64x0.cc
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
+ Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved
------------------------------------------- */
@@ -21,8 +21,8 @@
#include <LibCompiler/AE.h>
#include <LibCompiler/Backend/64x0.h>
-#include <LibCompiler/CompilerFrontend.h>
-#include <LibCompiler/Detail/ClUtils.h>
+#include <LibCompiler/Util/LCClUtils.h>
+#include <LibCompiler/Frontend.h>
#include <LibCompiler/PEF.h>
#include <algorithm>
#include <filesystem>
diff --git a/dev/LibCompiler/src/AssemblerAMD64.cc b/dev/LibCompiler/src/Asm/AssemblerAMD64.cc
index f017f0d..4a4ca41 100644
--- a/dev/LibCompiler/src/AssemblerAMD64.cc
+++ b/dev/LibCompiler/src/Asm/AssemblerAMD64.cc
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
+ Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved
------------------------------------------- */
@@ -27,8 +27,8 @@
#define kAssemblerPragmaSym '#'
#include <LibCompiler/AE.h>
-#include <LibCompiler/Backend/Amd64.h>
-#include <LibCompiler/CompilerFrontend.h>
+#include <LibCompiler/Backend/X64.h>
+#include <LibCompiler/Frontend.h>
#include <LibCompiler/PEF.h>
#include <algorithm>
#include <cstdlib>
@@ -74,7 +74,7 @@ static const std::string kUndefinedSymbol = ":UndefinedSymbol:";
// \brief forward decl.
static bool asm_read_attributes(std::string line);
-#include <LibCompiler/Detail/AsmUtils.h>
+#include <LibCompiler/Util/LCAsmUtils.h>
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/dev/LibCompiler/src/AssemblerARM64.cc b/dev/LibCompiler/src/Asm/AssemblerARM64.cc
index bad974e..5014a73 100644
--- a/dev/LibCompiler/src/AssemblerARM64.cc
+++ b/dev/LibCompiler/src/Asm/AssemblerARM64.cc
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
+ Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved
------------------------------------------- */
@@ -19,9 +19,9 @@
#include <LibCompiler/AE.h>
#include <LibCompiler/Backend/Aarch64.h>
-#include <LibCompiler/CompilerFrontend.h>
-#include <LibCompiler/Detail/AsmUtils.h>
+#include <LibCompiler/Util/LCAsmUtils.h>
#include <LibCompiler/ErrorID.h>
+#include <LibCompiler/Frontend.h>
#include <LibCompiler/PEF.h>
#include <LibCompiler/Version.h>
#include <algorithm>
diff --git a/dev/LibCompiler/src/AssemblerPowerPC.cc b/dev/LibCompiler/src/Asm/AssemblerPowerPC.cc
index c0a7172..1502205 100644
--- a/dev/LibCompiler/src/AssemblerPowerPC.cc
+++ b/dev/LibCompiler/src/Asm/AssemblerPowerPC.cc
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
+ Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved
------------------------------------------- */
@@ -19,9 +19,9 @@
#include <LibCompiler/AE.h>
#include <LibCompiler/Backend/PowerPC.h>
-#include <LibCompiler/CompilerFrontend.h>
-#include <LibCompiler/Detail/AsmUtils.h>
+#include <LibCompiler/Util/LCAsmUtils.h>
#include <LibCompiler/ErrorID.h>
+#include <LibCompiler/Frontend.h>
#include <LibCompiler/PEF.h>
#include <LibCompiler/Version.h>
#include <algorithm>
diff --git a/dev/LibCompiler/src/CCompiler64x0.cc b/dev/LibCompiler/src/Cl/CCompiler64x0.cc
index 55adc75..6ca680b 100644
--- a/dev/LibCompiler/src/CCompiler64x0.cc
+++ b/dev/LibCompiler/src/Cl/CCompiler64x0.cc
@@ -11,8 +11,8 @@
/// TODO: none
#include <LibCompiler/Backend/64x0.h>
-#include <LibCompiler/CompilerFrontend.h>
-#include <LibCompiler/Detail/ClUtils.h>
+#include <LibCompiler/Util/LCClUtils.h>
+#include <LibCompiler/Frontend.h>
#include <LibCompiler/UUID.h>
#include <cstdio>
#include <fstream>
diff --git a/dev/LibCompiler/src/CCompilerARM64.cc b/dev/LibCompiler/src/Cl/CCompilerARM64.cc
index 7a342ae..9abdc8c 100644
--- a/dev/LibCompiler/src/CCompilerARM64.cc
+++ b/dev/LibCompiler/src/Cl/CCompilerARM64.cc
@@ -11,8 +11,8 @@
/// TODO: none
#include <LibCompiler/Backend/Aarch64.h>
-#include <LibCompiler/CompilerFrontend.h>
-#include <LibCompiler/Detail/ClUtils.h>
+#include <LibCompiler/Util/LCClUtils.h>
+#include <LibCompiler/Frontend.h>
#include <LibCompiler/UUID.h>
#include <cstdio>
#include <fstream>
diff --git a/dev/LibCompiler/src/CCompilerPower64.cc b/dev/LibCompiler/src/Cl/CCompilerPower64.cc
index 91cd32f..d3dd81e 100644
--- a/dev/LibCompiler/src/CCompilerPower64.cc
+++ b/dev/LibCompiler/src/Cl/CCompilerPower64.cc
@@ -8,8 +8,8 @@
*/
#include <LibCompiler/Backend/PowerPC.h>
-#include <LibCompiler/CompilerFrontend.h>
-#include <LibCompiler/Detail/ClUtils.h>
+#include <LibCompiler/Util/LCClUtils.h>
+#include <LibCompiler/Frontend.h>
#include <LibCompiler/UUID.h>
#include <cstdio>
#include <fstream>
diff --git a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc b/dev/LibCompiler/src/Cl/CPlusPlusCompilerAMD64.cc
index cc6fa67..c99508c 100644
--- a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
+++ b/dev/LibCompiler/src/Cl/CPlusPlusCompilerAMD64.cc
@@ -16,9 +16,9 @@
// extern_segment, @autodelete { ... }, fn foo() -> auto { ... }
-#include <LibCompiler/Backend/Amd64.h>
-#include <LibCompiler/CompilerFrontend.h>
-#include <LibCompiler/Detail/ClUtils.h>
+#include <LibCompiler/Backend/X64.h>
+#include <LibCompiler/Util/LCClUtils.h>
+#include <LibCompiler/Frontend.h>
#include <LibCompiler/UUID.h>
/* NeKernel C++ Compiler Driver */
@@ -358,7 +358,7 @@ Boolean CompilerFrontendCPlusPlus::Compile(std::string text, std::string file) {
++indexFnName;
}
- if (fnName.find("(") != LibCompiler::String::npos) {
+ if (fnName.find("(") != LibCompiler::STLString::npos) {
fnName.erase(fnName.find("("));
}
@@ -884,7 +884,7 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
std::string argv_i = argv[index];
std::vector<std::string> exts = kExtListCxx;
- BOOL found = false;
+ BOOL found = false;
for (std::string ext : exts) {
if (argv_i.ends_with(ext)) {
diff --git a/dev/LibCompiler/src/AssemblyFactory+AssemblyInterface.cc b/dev/LibCompiler/src/CodeGen.cc
index e6072d9..31a809b 100644
--- a/dev/LibCompiler/src/AssemblyFactory+AssemblyInterface.cc
+++ b/dev/LibCompiler/src/CodeGen.cc
@@ -1,10 +1,10 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal EL Mahrous, all rights reserved
+ Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved
------------------------------------------- */
-#include <LibCompiler/AssemblyInterface.h>
+#include <LibCompiler/CodeGen.h>
#include <LibCompiler/ErrorID.h>
/**
@@ -23,13 +23,15 @@
namespace LibCompiler {
///! @brief Compile for specific format (ELF, PEF, ZBIN)
-Int32 AssemblyFactory::Compile(std::string sourceFile, const Int32& arch) noexcept {
+Int32 AssemblyFactory::Compile(STLString sourceFile, const Int32& arch) noexcept {
if (sourceFile.length() < 1 || !fMounted) return LIBCOMPILER_UNIMPLEMENTED;
+ if (!fMounted) return LIBCOMPILER_UNIMPLEMENTED;
+
if (arch != fMounted->Arch()) return LIBCOMPILER_INVALID_ARCH;
try {
- return fMounted->CompileToFormat(sourceFile, arch);
+ return this->fMounted->CompileToFormat(sourceFile, arch);
} catch (std::exception& e) {
return LIBCOMPILER_EXEC_ERROR;
}
diff --git a/dev/LibCompiler/src/Frontend.cc b/dev/LibCompiler/src/Frontend.cc
new file mode 100644
index 0000000..69ff6fd
--- /dev/null
+++ b/dev/LibCompiler/src/Frontend.cc
@@ -0,0 +1,51 @@
+/* -------------------------------------------
+
+ Copyright (C) 2025 Amlal EL Mahrouss, all rights reserved
+
+------------------------------------------- */
+
+#include <LibCompiler/Frontend.h>
+
+namespace LibCompiler {
+/// find the perfect matching word in a haystack.
+/// \param haystack base string
+/// \param needle the string we search for.
+/// \return if we found it or not.
+bool find_word(std::string haystack, std::string needle) noexcept {
+ auto index = haystack.find(needle);
+
+ // check for needle validity.
+ if (index == std::string::npos) return false;
+
+ // declare lambda
+ auto not_part_of_word = [&](int index) {
+ if (std::isspace(haystack[index]) || std::ispunct(haystack[index])) return true;
+
+ if (index <= 0 || index >= haystack.size()) return true;
+
+ return false;
+ };
+
+ return not_part_of_word(index - 1) && not_part_of_word(index + needle.size());
+}
+
+/// find a word within strict conditions and returns a range of it.
+/// \param haystack
+/// \param needle
+/// \return position of needle.
+std::size_t find_word_range(std::string haystack, std::string needle) noexcept {
+ auto index = haystack.find(needle);
+
+ // check for needle validity.
+ if (index == std::string::npos) return false;
+
+ if (!isalnum((haystack[index + needle.size() + 1])) &&
+ !isdigit(haystack[index + needle.size() + 1]) &&
+ !isalnum((haystack[index - needle.size() - 1])) &&
+ !isdigit(haystack[index - needle.size() - 1])) {
+ return index;
+ }
+
+ return std::string::npos;
+}
+} // namespace LibCompiler \ No newline at end of file
diff --git a/dev/LibCompiler/src/DynamicLinkerPEF.cc b/dev/LibCompiler/src/Linker/DynamicLinkerPEF.cc
index 6421171..0c6f3bf 100644
--- a/dev/LibCompiler/src/DynamicLinkerPEF.cc
+++ b/dev/LibCompiler/src/Linker/DynamicLinkerPEF.cc
@@ -20,7 +20,7 @@
#include <LibCompiler/ErrorID.h>
//! Assembler Kit
-#include <LibCompiler/AssemblyInterface.h>
+#include <LibCompiler/CodeGen.h>
//! Preferred Executable Format
#include <LibCompiler/PEF.h>
@@ -35,7 +35,7 @@
#include <LibCompiler/AE.h>
//! LibCompiler utils.
-#include <LibCompiler/Detail/ClUtils.h>
+#include <LibCompiler/Util/LCClUtils.h>
//! I/O stream from std c++
#include <iostream>
@@ -80,20 +80,20 @@ enum {
kABITypeInvalid = 0xFFFF,
};
-static LibCompiler::String kOutput = "a" kPefExt;
-static Int32 kAbi = kABITypeNE;
-static Int32 kSubArch = kPefNoSubCpu;
-static Int32 kArch = LibCompiler::kPefArchInvalid;
-static Bool kFatBinaryEnable = false;
-static Bool kStartFound = false;
-static Bool kDuplicateSymbols = false;
+static LibCompiler::STLString kOutput = "a" kPefExt;
+static Int32 kAbi = kABITypeNE;
+static Int32 kSubArch = kPefNoSubCpu;
+static Int32 kArch = LibCompiler::kPefArchInvalid;
+static Bool kFatBinaryEnable = false;
+static Bool kStartFound = false;
+static Bool kDuplicateSymbols = false;
/* ld64 is to be found, mld is to be found at runtime. */
static const CharType* kLdDefineSymbol = ":UndefinedSymbol:";
static const CharType* kLdDynamicSym = ":RuntimeSymbol:";
/* object code and list. */
-static std::vector<LibCompiler::String> kObjectList;
+static std::vector<LibCompiler::STLString> kObjectList;
static std::vector<Detail::DynamicLinkerBlob> kObjectBytes;
/// @brief NE 64-bit Linker.
@@ -165,7 +165,7 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
continue;
}
- if (kOutput.find(kPefExt) != LibCompiler::String::npos)
+ if (kOutput.find(kPefExt) != LibCompiler::STLString::npos)
kOutput.erase(kOutput.find(kPefExt), strlen(kPefExt));
kOutput += kPefDylibExt;
@@ -308,15 +308,15 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
MemoryCopy(command_header.Name, ae_records[ae_record_index].fName, kPefNameLen);
- LibCompiler::String cmd_hdr_name(command_header.Name);
+ LibCompiler::STLString cmd_hdr_name(command_header.Name);
// check this header if it's any valid.
- if (cmd_hdr_name.find(kPefCode64) == LibCompiler::String::npos &&
- cmd_hdr_name.find(kPefData64) == LibCompiler::String::npos &&
- cmd_hdr_name.find(kPefZero64) == LibCompiler::String::npos) {
- if (cmd_hdr_name.find(kPefStart) == LibCompiler::String::npos &&
+ if (cmd_hdr_name.find(kPefCode64) == LibCompiler::STLString::npos &&
+ cmd_hdr_name.find(kPefData64) == LibCompiler::STLString::npos &&
+ cmd_hdr_name.find(kPefZero64) == LibCompiler::STLString::npos) {
+ if (cmd_hdr_name.find(kPefStart) == LibCompiler::STLString::npos &&
*command_header.Name == 0) {
- if (cmd_hdr_name.find(kLdDefineSymbol) != LibCompiler::String::npos) {
+ if (cmd_hdr_name.find(kLdDefineSymbol) != LibCompiler::STLString::npos) {
goto ld_mark_header;
} else {
continue;
@@ -324,8 +324,8 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
}
}
- if (cmd_hdr_name.find(kPefStart) != LibCompiler::String::npos &&
- cmd_hdr_name.find(kPefCode64) != LibCompiler::String::npos) {
+ if (cmd_hdr_name.find(kPefStart) != LibCompiler::STLString::npos &&
+ cmd_hdr_name.find(kPefCode64) != LibCompiler::STLString::npos) {
kStartFound = true;
}
@@ -381,19 +381,21 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
output_fc.seekp(std::streamsize(pef_container.HdrSz));
- std::vector<LibCompiler::String> not_found;
- std::vector<LibCompiler::String> symbols;
+ std::vector<LibCompiler::STLString> not_found;
+ std::vector<LibCompiler::STLString> 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 (LibCompiler::String(command_hdr.Name).find(kLdDefineSymbol) != LibCompiler::String::npos &&
- LibCompiler::String(command_hdr.Name).find(kLdDynamicSym) == LibCompiler::String::npos) {
+ if (LibCompiler::STLString(command_hdr.Name).find(kLdDefineSymbol) !=
+ LibCompiler::STLString::npos &&
+ LibCompiler::STLString(command_hdr.Name).find(kLdDynamicSym) ==
+ LibCompiler::STLString::npos) {
if (kVerbose) kConsoleOut << "Found undefined symbol: " << command_hdr.Name << "\n";
- if (auto it =
- std::find(not_found.begin(), not_found.end(), LibCompiler::String(command_hdr.Name));
+ if (auto it = std::find(not_found.begin(), not_found.end(),
+ LibCompiler::STLString(command_hdr.Name));
it == not_found.end()) {
not_found.emplace_back(command_hdr.Name);
}
@@ -406,26 +408,27 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
for (size_t not_found_idx = 0; not_found_idx < command_headers.size(); ++not_found_idx) {
if (const auto it = std::find(not_found.begin(), not_found.end(),
- LibCompiler::String(command_headers[not_found_idx].Name));
+ LibCompiler::STLString(command_headers[not_found_idx].Name));
it != not_found.end()) {
- LibCompiler::String symbol_imp = *it;
+ LibCompiler::STLString symbol_imp = *it;
- if (symbol_imp.find(kLdDefineSymbol) == LibCompiler::String::npos) continue;
+ if (symbol_imp.find(kLdDefineSymbol) == LibCompiler::STLString::npos) continue;
// erase the lookup prefix.
symbol_imp.erase(0, symbol_imp.find(kLdDefineSymbol) + strlen(kLdDefineSymbol));
// demangle everything.
- while (symbol_imp.find('$') != LibCompiler::String::npos)
+ while (symbol_imp.find('$') != LibCompiler::STLString::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 (LibCompiler::String(command_hdr.Name).find(symbol_imp) != LibCompiler::String::npos &&
- LibCompiler::String(command_hdr.Name).find(kLdDefineSymbol) ==
- LibCompiler::String::npos) {
- LibCompiler::String undefined_symbol = command_hdr.Name;
+ if (LibCompiler::STLString(command_hdr.Name).find(symbol_imp) !=
+ LibCompiler::STLString::npos &&
+ LibCompiler::STLString(command_hdr.Name).find(kLdDefineSymbol) ==
+ LibCompiler::STLString::npos) {
+ LibCompiler::STLString undefined_symbol = command_hdr.Name;
auto result_of_sym = undefined_symbol.substr(undefined_symbol.find(symbol_imp));
for (int i = 0; result_of_sym[i] != 0; ++i) {
@@ -462,7 +465,7 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
time_t timestamp = time(nullptr);
- LibCompiler::String timeStampStr = "Container:BuildEpoch:";
+ LibCompiler::STLString timeStampStr = "Container:BuildEpoch:";
timeStampStr += std::to_string(timestamp);
strncpy(date_cmd_hdr.Name, timeStampStr.c_str(), timeStampStr.size());
@@ -476,7 +479,7 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
LibCompiler::PEFCommandHeader abi_cmd_hdr{};
- LibCompiler::String abi = kLinkerAbiContainer;
+ LibCompiler::STLString abi = kLinkerAbiContainer;
switch (kArch) {
case LibCompiler::kPefArchAMD64: {
@@ -542,9 +545,9 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
command_headers.push_back(uuid_cmd_hdr);
// prepare a symbol vector.
- std::vector<LibCompiler::String> undef_symbols;
- std::vector<LibCompiler::String> dupl_symbols;
- std::vector<LibCompiler::String> resolve_symbols;
+ std::vector<LibCompiler::STLString> undef_symbols;
+ std::vector<LibCompiler::STLString> dupl_symbols;
+ std::vector<LibCompiler::STLString> resolve_symbols;
constexpr Int32 kPaddingOffset = 16;
@@ -567,15 +570,15 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
// And check for any duplications
for (size_t commandHeaderIndex = 0UL; commandHeaderIndex < command_headers.size();
++commandHeaderIndex) {
- if (LibCompiler::String(command_headers[commandHeaderIndex].Name).find(kLdDefineSymbol) !=
- LibCompiler::String::npos &&
- LibCompiler::String(command_headers[commandHeaderIndex].Name).find(kLdDynamicSym) ==
- LibCompiler::String::npos) {
+ if (LibCompiler::STLString(command_headers[commandHeaderIndex].Name).find(kLdDefineSymbol) !=
+ LibCompiler::STLString::npos &&
+ LibCompiler::STLString(command_headers[commandHeaderIndex].Name).find(kLdDynamicSym) ==
+ LibCompiler::STLString::npos) {
// ignore :UndefinedSymbol: headers, they do not contain code.
continue;
}
- LibCompiler::String symbol_name = command_headers[commandHeaderIndex].Name;
+ LibCompiler::STLString symbol_name = command_headers[commandHeaderIndex].Name;
if (!symbol_name.empty()) {
undef_symbols.emplace_back(symbol_name);
@@ -584,13 +587,13 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
command_headers[commandHeaderIndex].Offset += previous_offset;
previous_offset += command_headers[commandHeaderIndex].Size;
- LibCompiler::String name = command_headers[commandHeaderIndex].Name;
+ LibCompiler::STLString 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) != LibCompiler::String::npos &&
- name.find(kPefCode64) != LibCompiler::String::npos) {
+ if (name.find(kPefStart) != LibCompiler::STLString::npos &&
+ name.find(kPefCode64) != LibCompiler::STLString::npos) {
pef_container.Start = command_headers[commandHeaderIndex].Offset;
auto tellCurPos = output_fc.tellp();
@@ -612,10 +615,10 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
++sub_command_header_index) {
if (sub_command_header_index == commandHeaderIndex) continue;
- 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 (LibCompiler::STLString(command_headers[sub_command_header_index].Name)
+ .find(kLdDefineSymbol) != LibCompiler::STLString::npos &&
+ LibCompiler::STLString(command_headers[sub_command_header_index].Name)
+ .find(kLdDynamicSym) == LibCompiler::STLString::npos) {
if (kVerbose) {
kConsoleOut << "Ignoring :UndefinedSymbol: headers...\n";
}
@@ -626,7 +629,7 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
auto& command_hdr = command_headers[sub_command_header_index];
- if (command_hdr.Name == LibCompiler::String(command_headers[commandHeaderIndex].Name)) {
+ if (command_hdr.Name == LibCompiler::STLString(command_headers[commandHeaderIndex].Name)) {
if (std::find(dupl_symbols.cbegin(), dupl_symbols.cend(), command_hdr.Name) ==
dupl_symbols.cend()) {
dupl_symbols.emplace_back(command_hdr.Name);
@@ -659,11 +662,11 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
// step 3: check if we have those symbols
- std::vector<LibCompiler::String> unreferenced_symbols;
+ std::vector<LibCompiler::STLString> unreferenced_symbols;
for (auto& command_hdr : command_headers) {
if (auto it =
- std::find(not_found.begin(), not_found.end(), LibCompiler::String(command_hdr.Name));
+ std::find(not_found.begin(), not_found.end(), LibCompiler::STLString(command_hdr.Name));
it != not_found.end()) {
unreferenced_symbols.emplace_back(command_hdr.Name);
}
diff --git a/dev/LibCompiler/src/CPlusPlusCompilerPreProcessor.cc b/dev/LibCompiler/src/PP/CPlusPlusCompilerPreProcessor.cc
index 9981f37..2c7c551 100644
--- a/dev/LibCompiler/src/CPlusPlusCompilerPreProcessor.cc
+++ b/dev/LibCompiler/src/PP/CPlusPlusCompilerPreProcessor.cc
@@ -9,8 +9,8 @@
/// BUGS: 0
-#include <LibCompiler/CompilerFrontend.h>
#include <LibCompiler/ErrorID.h>
+#include <LibCompiler/Frontend.h>
#include <algorithm>
#include <filesystem>
#include <fstream>
@@ -24,7 +24,7 @@
/// @file bpp.cxx
/// @brief Preprocessor.
-typedef Int32 (*bpp_parser_fn_t)(LibCompiler::String& line, std::ifstream& hdr_file,
+typedef Int32 (*bpp_parser_fn_t)(LibCompiler::STLString& line, std::ifstream& hdr_file,
std::ofstream& pp_out);
/////////////////////////////////////////////////////////////////////////////////////////
@@ -46,8 +46,8 @@ enum {
};
struct bpp_macro_condition final {
- int32_t fType;
- LibCompiler::String fTypeName;
+ int32_t fType;
+ LibCompiler::STLString fTypeName;
void Print() {
std::cout << "type: " << fType << "\n";
@@ -56,9 +56,9 @@ struct bpp_macro_condition final {
};
struct bpp_macro final {
- std::vector<LibCompiler::String> fArgs;
- LibCompiler::String fName;
- LibCompiler::String fValue;
+ std::vector<LibCompiler::STLString> fArgs;
+ LibCompiler::STLString fName;
+ LibCompiler::STLString fValue;
void Print() {
std::cout << "name: " << fName << "\n";
@@ -71,11 +71,11 @@ struct bpp_macro final {
};
} // namespace Detail
-static std::vector<LibCompiler::String> kFiles;
-static std::vector<Detail::bpp_macro> kMacros;
-static std::vector<LibCompiler::String> kIncludes;
+static std::vector<LibCompiler::STLString> kFiles;
+static std::vector<Detail::bpp_macro> kMacros;
+static std::vector<LibCompiler::STLString> kIncludes;
-static LibCompiler::String kWorkingDir = "";
+static LibCompiler::STLString kWorkingDir = "";
/////////////////////////////////////////////////////////////////////////////////////////
@@ -85,11 +85,12 @@ static LibCompiler::String kWorkingDir = "";
/////////////////////////////////////////////////////////////////////////////////////////
int32_t bpp_parse_if_condition(Detail::bpp_macro_condition& cond, Detail::bpp_macro& macro,
- bool& inactive_code, bool& defined, LibCompiler::String& macro_str) {
+ bool& inactive_code, bool& defined,
+ LibCompiler::STLString& macro_str) {
if (cond.fType == Detail::kEqual) {
auto substr_macro = macro_str.substr(macro_str.find(macro.fName) + macro.fName.size());
- if (substr_macro.find(macro.fValue) != LibCompiler::String::npos) {
+ if (substr_macro.find(macro.fValue) != LibCompiler::STLString::npos) {
if (macro.fValue == "0") {
defined = false;
inactive_code = true;
@@ -105,8 +106,8 @@ int32_t bpp_parse_if_condition(Detail::bpp_macro_condition& cond, Detail::bpp_ma
} else if (cond.fType == Detail::kNotEqual) {
auto substr_macro = macro_str.substr(macro_str.find(macro.fName) + macro.fName.size());
- if (substr_macro.find(macro.fName) != LibCompiler::String::npos) {
- if (substr_macro.find(macro.fValue) != LibCompiler::String::npos) {
+ if (substr_macro.find(macro.fName) != LibCompiler::STLString::npos) {
+ if (substr_macro.find(macro.fValue) != LibCompiler::STLString::npos) {
defined = false;
inactive_code = true;
@@ -124,10 +125,10 @@ int32_t bpp_parse_if_condition(Detail::bpp_macro_condition& cond, Detail::bpp_ma
auto substr_macro = macro_str.substr(macro_str.find(macro.fName) + macro.fName.size());
- LibCompiler::String number;
+ LibCompiler::STLString number;
for (auto& macro_num : kMacros) {
- if (substr_macro.find(macro_num.fName) != LibCompiler::String::npos) {
+ if (substr_macro.find(macro_num.fName) != LibCompiler::STLString::npos) {
for (size_t i = 0; i < macro_num.fName.size(); ++i) {
if (isdigit(macro_num.fValue[i])) {
number += macro_num.fValue[i];
@@ -231,7 +232,7 @@ int32_t bpp_parse_if_condition(Detail::bpp_macro_condition& cond, Detail::bpp_ma
/////////////////////////////////////////////////////////////////////////////////////////
-std::vector<LibCompiler::String> kAllIncludes;
+std::vector<LibCompiler::STLString> kAllIncludes;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -241,8 +242,8 @@ std::vector<LibCompiler::String> kAllIncludes;
/////////////////////////////////////////////////////////////////////////////////////////
void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
- LibCompiler::String hdr_line;
- LibCompiler::String line_after_include;
+ LibCompiler::STLString hdr_line;
+ LibCompiler::STLString line_after_include;
bool inactive_code = false;
bool defined = false;
@@ -250,36 +251,36 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
try {
while (std::getline(hdr_file, hdr_line)) {
if (inactive_code) {
- if (hdr_line.find("#endif") == LibCompiler::String::npos) {
+ if (hdr_line.find("#endif") == LibCompiler::STLString::npos) {
continue;
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("#endif") != LibCompiler::String::npos) {
+ hdr_line.find("#endif") != LibCompiler::STLString::npos) {
inactive_code = false;
}
- if (hdr_line.find("*/") != LibCompiler::String::npos) {
+ if (hdr_line.find("*/") != LibCompiler::STLString::npos) {
continue;
}
}
- if (hdr_line.find("--/") != LibCompiler::String::npos) {
+ if (hdr_line.find("--/") != LibCompiler::STLString::npos) {
hdr_line.erase(hdr_line.find("--/"));
}
- if (hdr_line.find("--*") != LibCompiler::String::npos) {
+ if (hdr_line.find("--*") != LibCompiler::STLString::npos) {
inactive_code = true;
// get rid of comment.
hdr_line.erase(hdr_line.find("--*"));
}
/// BPP 'brief' documentation.
- if (hdr_line.find("@brief") != LibCompiler::String::npos) {
+ if (hdr_line.find("@brief") != LibCompiler::STLString::npos) {
hdr_line.erase(hdr_line.find("@brief"));
// TODO: Write an <file_name>.html or append to it.
}
- if (hdr_line[0] == kMacroPrefix && hdr_line.find("endif") != LibCompiler::String::npos) {
+ if (hdr_line[0] == kMacroPrefix && hdr_line.find("endif") != LibCompiler::STLString::npos) {
if (!defined && inactive_code) {
inactive_code = false;
defined = false;
@@ -301,17 +302,17 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
for (auto macro : kMacros) {
if (LibCompiler::find_word(hdr_line, macro.fName)) {
if (hdr_line.substr(hdr_line.find(macro.fName)).find(macro.fName + '(') !=
- LibCompiler::String::npos) {
+ LibCompiler::STLString::npos) {
if (!macro.fArgs.empty()) {
- LibCompiler::String symbol_val = macro.fValue;
- std::vector<LibCompiler::String> args;
+ LibCompiler::STLString symbol_val = macro.fValue;
+ std::vector<LibCompiler::STLString> args;
size_t x_arg_indx = 0;
- LibCompiler::String line_after_define = hdr_line;
- LibCompiler::String str_arg;
+ LibCompiler::STLString line_after_define = hdr_line;
+ LibCompiler::STLString str_arg;
- if (line_after_define.find("(") != LibCompiler::String::npos) {
+ if (line_after_define.find("(") != LibCompiler::STLString::npos) {
line_after_define.erase(0, line_after_define.find("(") + 1);
for (auto& subc : line_after_define) {
@@ -332,7 +333,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]) != LibCompiler::String::npos) {
+ if (symbol_val.find(macro.fArgs[x_arg_indx]) != LibCompiler::STLString::npos) {
symbol_val.replace(symbol_val.find(macro.fArgs[x_arg_indx]),
macro.fArgs[x_arg_indx].size(), args[x_arg_indx]);
++x_arg_indx;
@@ -358,16 +359,16 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
}
}
- if (hdr_line[0] == kMacroPrefix && hdr_line.find("define ") != LibCompiler::String::npos) {
+ if (hdr_line[0] == kMacroPrefix && hdr_line.find("define ") != LibCompiler::STLString::npos) {
auto line_after_define = hdr_line.substr(hdr_line.find("define ") + strlen("define "));
- LibCompiler::String macro_value;
- LibCompiler::String macro_key;
+ LibCompiler::STLString macro_value;
+ LibCompiler::STLString macro_key;
std::size_t pos = 0UL;
- std::vector<LibCompiler::String> args;
- bool on_args = false;
+ std::vector<LibCompiler::STLString> args;
+ bool on_args = false;
for (auto& ch : line_after_define) {
++pos;
@@ -397,9 +398,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
macro_key += ch;
}
- LibCompiler::String str;
+ LibCompiler::STLString str;
- if (line_after_define.find("(") != LibCompiler::String::npos) {
+ if (line_after_define.find("(") != LibCompiler::STLString::npos) {
line_after_define.erase(0, line_after_define.find("(") + 1);
for (auto& subc : line_after_define) {
@@ -438,9 +439,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
continue;
}
- if (hdr_line[0] == kMacroPrefix && hdr_line.find("ifndef") != LibCompiler::String::npos) {
+ if (hdr_line[0] == kMacroPrefix && hdr_line.find("ifndef") != LibCompiler::STLString::npos) {
auto line_after_ifndef = hdr_line.substr(hdr_line.find("ifndef") + strlen("ifndef") + 1);
- LibCompiler::String macro;
+ LibCompiler::STLString macro;
for (auto& ch : line_after_ifndef) {
if (ch == ' ') {
@@ -469,7 +470,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
inactive_code = false;
for (auto& macro_ref : kMacros) {
- if (hdr_line.find(macro_ref.fName) != LibCompiler::String::npos) {
+ if (hdr_line.find(macro_ref.fName) != LibCompiler::STLString::npos) {
found = true;
break;
}
@@ -482,7 +483,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
continue;
}
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("else") != LibCompiler::String::npos) {
+ hdr_line.find("else") != LibCompiler::STLString::npos) {
if (!defined && inactive_code) {
inactive_code = false;
defined = true;
@@ -495,9 +496,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
continue;
}
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("ifdef") != LibCompiler::String::npos) {
+ hdr_line.find("ifdef") != LibCompiler::STLString::npos) {
auto line_after_ifdef = hdr_line.substr(hdr_line.find("ifdef") + strlen("ifdef") + 1);
- LibCompiler::String macro;
+ LibCompiler::STLString macro;
for (auto& ch : line_after_ifdef) {
if (ch == ' ') {
@@ -525,14 +526,15 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
inactive_code = true;
for (auto& macro_ref : kMacros) {
- if (hdr_line.find(macro_ref.fName) != LibCompiler::String::npos) {
+ if (hdr_line.find(macro_ref.fName) != LibCompiler::STLString::npos) {
defined = true;
inactive_code = false;
break;
}
}
- } else if (hdr_line[0] == kMacroPrefix && hdr_line.find("if") != LibCompiler::String::npos) {
+ } else if (hdr_line[0] == kMacroPrefix &&
+ hdr_line.find("if") != LibCompiler::STLString::npos) {
inactive_code = true;
std::vector<Detail::bpp_macro_condition> bpp_macro_condition_list = {
@@ -565,9 +567,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
int32_t good_to_go = 0;
for (auto& macro_condition : bpp_macro_condition_list) {
- if (hdr_line.find(macro_condition.fTypeName) != LibCompiler::String::npos) {
+ if (hdr_line.find(macro_condition.fTypeName) != LibCompiler::STLString::npos) {
for (auto& found_macro : kMacros) {
- if (hdr_line.find(found_macro.fName) != LibCompiler::String::npos) {
+ if (hdr_line.find(found_macro.fName) != LibCompiler::STLString::npos) {
good_to_go = bpp_parse_if_condition(macro_condition, found_macro, inactive_code,
defined, hdr_line);
@@ -579,8 +581,8 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
if (good_to_go) continue;
- auto line_after_if = hdr_line.substr(hdr_line.find("if") + strlen("if") + 1);
- LibCompiler::String macro;
+ auto line_after_if = hdr_line.substr(hdr_line.find("if") + strlen("if") + 1);
+ LibCompiler::STLString macro;
for (auto& ch : line_after_if) {
if (ch == ' ') {
@@ -605,7 +607,8 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
// last try, is it defined to be one?
for (auto& macro_ref : kMacros) {
- if (macro_ref.fName.find(macro) != LibCompiler::String::npos && macro_ref.fValue == "1") {
+ if (macro_ref.fName.find(macro) != LibCompiler::STLString::npos &&
+ macro_ref.fValue == "1") {
inactive_code = false;
defined = true;
@@ -613,9 +616,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
}
}
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("warning") != LibCompiler::String::npos) {
+ hdr_line.find("warning") != LibCompiler::STLString::npos) {
auto line_after_warning = hdr_line.substr(hdr_line.find("warning") + strlen("warning") + 1);
- LibCompiler::String message;
+ LibCompiler::STLString message;
for (auto& ch : line_after_warning) {
if (ch == '\r' || ch == '\n') {
@@ -627,9 +630,9 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
std::cout << "warn: " << message << std::endl;
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("error") != LibCompiler::String::npos) {
+ hdr_line.find("error") != LibCompiler::STLString::npos) {
auto line_after_warning = hdr_line.substr(hdr_line.find("error") + strlen("error") + 1);
- LibCompiler::String message;
+ LibCompiler::STLString message;
for (auto& ch : line_after_warning) {
if (ch == '\r' || ch == '\n') {
@@ -641,7 +644,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
throw std::runtime_error("error: " + message);
} else if (hdr_line[0] == kMacroPrefix &&
- hdr_line.find("include ") != LibCompiler::String::npos) {
+ hdr_line.find("include ") != LibCompiler::STLString::npos) {
line_after_include = hdr_line.substr(hdr_line.find("include ") + strlen("include "));
kIncludeFile:
@@ -651,7 +654,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
continue;
}
- LibCompiler::String path;
+ LibCompiler::STLString path;
kAllIncludes.push_back(line_after_include);
@@ -691,7 +694,7 @@ void bpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) {
}
for (auto& include : kIncludes) {
- LibCompiler::String header_path = include;
+ LibCompiler::STLString header_path = include;
header_path.push_back('/');
header_path += path;
@@ -830,7 +833,7 @@ LIBCOMPILER_MODULE(CPlusPlusPreprocessorMain) {
}
if (strcmp(argv[index], "--cppdrv:include-dir") == 0) {
- LibCompiler::String inc = argv[index + 1];
+ LibCompiler::STLString inc = argv[index + 1];
skip = true;
@@ -838,17 +841,17 @@ LIBCOMPILER_MODULE(CPlusPlusPreprocessorMain) {
}
if (strcmp(argv[index], "--cppdrv:working-dir") == 0) {
- LibCompiler::String inc = argv[index + 1];
- skip = true;
- kWorkingDir = inc;
+ LibCompiler::STLString inc = argv[index + 1];
+ skip = true;
+ kWorkingDir = inc;
}
if (strcmp(argv[index], "--cppdrv:def") == 0 && argv[index + 1] != nullptr &&
argv[index + 2] != nullptr) {
- LibCompiler::String macro_key = argv[index + 1];
+ LibCompiler::STLString macro_key = argv[index + 1];
- LibCompiler::String macro_value;
- bool is_string = false;
+ LibCompiler::STLString macro_value;
+ bool is_string = false;
for (int argv_find_len = 0; argv_find_len < strlen(argv[index]); ++argv_find_len) {
if (!isdigit(argv[index][argv_find_len])) {
diff --git a/dev/LibCompiler/src/StringView.cc b/dev/LibCompiler/src/PString.cc
index 41ee636..c8c060b 100644
--- a/dev/LibCompiler/src/StringView.cc
+++ b/dev/LibCompiler/src/PString.cc
@@ -8,7 +8,7 @@
*/
/**
- * @file String.cxx
+ * @file PString.cxx
* @author Amlal (amlal@el-mahrouss-logic.com)
* @brief C++ string manipulation API.
* @version 0.2
@@ -18,22 +18,22 @@
*
*/
-#include <LibCompiler/StringView.h>
+#include <LibCompiler/PString.h>
namespace LibCompiler {
-CharType* StringView::Data() {
+CharType* PString::Data() {
return m_Data;
}
-const CharType* StringView::CData() const {
+const CharType* PString::CData() const {
return m_Data;
}
-SizeType StringView::Length() const {
+SizeType PString::Length() const {
return strlen(m_Data);
}
-bool StringView::operator==(const StringView& rhs) const {
+bool PString::operator==(const PString& rhs) const {
if (rhs.Length() != Length()) return false;
for (SizeType index = 0; index < Length(); ++index) {
@@ -43,7 +43,7 @@ bool StringView::operator==(const StringView& rhs) const {
return true;
}
-bool StringView::operator==(const CharType* rhs) const {
+bool PString::operator==(const CharType* rhs) const {
if (string_length(rhs) != Length()) return false;
for (SizeType index = 0; index < string_length(rhs); ++index) {
@@ -53,7 +53,7 @@ bool StringView::operator==(const CharType* rhs) const {
return true;
}
-bool StringView::operator!=(const StringView& rhs) const {
+bool PString::operator!=(const PString& rhs) const {
if (rhs.Length() != Length()) return false;
for (SizeType index = 0; index < rhs.Length(); ++index) {
@@ -63,7 +63,7 @@ bool StringView::operator!=(const StringView& rhs) const {
return true;
}
-bool StringView::operator!=(const CharType* rhs) const {
+bool PString::operator!=(const CharType* rhs) const {
if (string_length(rhs) != Length()) return false;
for (SizeType index = 0; index < string_length(rhs); ++index) {
@@ -73,10 +73,10 @@ bool StringView::operator!=(const CharType* rhs) const {
return true;
}
-StringView StringBuilder::Construct(const CharType* data) {
- if (!data || *data == 0) return StringView(0);
+PString StringBuilder::Construct(const CharType* data) {
+ if (!data || *data == 0) return PString(0);
- StringView view(strlen(data));
+ PString view(strlen(data));
view += data;
return view;
@@ -183,9 +183,9 @@ const char* StringBuilder::Format(const char* fmt, const char* fmtRight) {
return ret;
}
-StringView& StringView::operator+=(const CharType* rhs) {
+PString& PString::operator+=(const CharType* rhs) {
if (strlen(rhs) > this->m_Sz) {
- throw std::runtime_error("out_of_bounds: StringView");
+ throw std::runtime_error("out_of_bounds: PString");
}
memcpy(this->m_Data + this->m_Cur, rhs, strlen(rhs));
@@ -194,9 +194,9 @@ StringView& StringView::operator+=(const CharType* rhs) {
return *this;
}
-StringView& StringView::operator+=(const StringView& rhs) {
+PString& PString::operator+=(const PString& rhs) {
if (rhs.m_Cur > this->m_Sz) {
- throw std::runtime_error("out_of_bounds: StringView");
+ throw std::runtime_error("out_of_bounds: PString");
}
memcpy(this->m_Data + this->m_Cur, rhs.CData(), strlen(rhs.CData()));