summaryrefslogtreecommitdiffhomepage
path: root/CompilerDriver
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-03 17:59:58 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-03 18:28:56 +0100
commit05c51485d56b14f7cd3c05afebd920157d7a0b8b (patch)
treec7c35a9a723ee7682a10ea2ac4835c8795bda072 /CompilerDriver
parentaa49d723caa7daf2bbc970bd9f4fe23a5a8d8df1 (diff)
WesternCompany C/C++: 1.0.1 BETA.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'CompilerDriver')
-rw-r--r--CompilerDriver/cc.cxx14
-rw-r--r--CompilerDriver/ccplus.cxx90
-rw-r--r--CompilerDriver/cpp.cxx6
-rw-r--r--CompilerDriver/ld.cxx14
-rw-r--r--CompilerDriver/makefile2
-rw-r--r--CompilerDriver/masm.cxx26
6 files changed, 69 insertions, 83 deletions
diff --git a/CompilerDriver/cc.cxx b/CompilerDriver/cc.cxx
index 03145ae..0a8647d 100644
--- a/CompilerDriver/cc.cxx
+++ b/CompilerDriver/cc.cxx
@@ -2,7 +2,7 @@
* ========================================================
*
* cc
- * Copyright WestCo, all rights reserved.
+ * Copyright Western Company, all rights reserved.
*
* ========================================================
*/
@@ -20,7 +20,7 @@
/* Optimized C driver */
/* This is part of MP-UX C SDK. */
-/* (c) WestCo */
+/* (c) Western Company */
/////////////////////
@@ -143,7 +143,7 @@ public:
std::string Check(const char* text, const char* file);
bool Compile(const std::string& text, const char* file) override;
- const char* Language() override { return "Optimized X64000 C"; }
+ const char* Language() override { return "Optimized 64x0 C"; }
};
@@ -200,9 +200,9 @@ static std::string cc_parse_function_call(std::string& _text)
namespace detail
{
- union number_type
+ union number_cast
{
- number_type(UInt64 raw)
+ number_cast(UInt64 raw)
: raw(raw)
{}
@@ -232,7 +232,7 @@ bool CompilerBackendClang::Compile(const std::string& text, const char* file)
uuid_t out{0};
uuid_generate_random(out);
- detail::number_type time_off = (UInt64)out;
+ detail::number_cast time_off = (UInt64)out;
if (!type_found)
{
@@ -1755,7 +1755,7 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
#define kPrintF printf
-#define kSplashCxx() kPrintF(kWhite "%s\n", "X64000 Optimized C compiler, v1.13, (c) WestCo")
+#define kSplashCxx() kPrintF(kWhite "%s\n", "cc, v1.13, (c) Western Company")
static void cc_print_help()
{
diff --git a/CompilerDriver/ccplus.cxx b/CompilerDriver/ccplus.cxx
index 62ce4df..d9ef3fe 100644
--- a/CompilerDriver/ccplus.cxx
+++ b/CompilerDriver/ccplus.cxx
@@ -2,7 +2,7 @@
* ========================================================
*
* ccplus
- * Copyright WestCo, all rights reserved.
+ * Copyright Western Company, all rights reserved.
*
* ========================================================
*/
@@ -14,14 +14,15 @@
#include <iostream>
#include <stack>
#include <utility>
+#include <uuid/uuid.h>
#include <C++Kit/AsmKit/Arch/64k.hpp>
#include <C++Kit/ParserKit.hpp>
#define kOk 0
-/* WestCo C driver */
+/* Western Company C driver */
/* This is part of MP-UX C SDK. */
-/* (c) WestCo */
+/* (c) Western Company */
/////////////////////
@@ -133,7 +134,7 @@ static bool kOnForLoop = false;
static bool kInBraces = false;
static size_t kBracesCount = 0UL;
-/* @brief C compiler backend for WestCo C */
+/* @brief C compiler backend for Western Company C */
class CompilerBackendClang final : public ParserKit::CompilerBackend
{
public:
@@ -144,70 +145,53 @@ public:
bool Compile(const std::string& text, const char* file) override;
- const char* Language() override { return "Optimized 64x0 C"; }
+ const char* Language() override { return "Optimized 64x0 C++"; }
};
-static CompilerBackendClang* kCompilerBackend = nullptr;
-static std::vector<detail::CompilerType> kCompilerVariables;
-static std::vector<std::string> kCompilerFunctions;
-
-// @brief this hook code before the begin/end command.
-static std::string kAddIfAnyBegin;
-static std::string kAddIfAnyEnd;
-static std::string kLatestVar;
+static CompilerBackendClang* kCompilerBackend = nullptr;
+static std::vector<detail::CompilerType> kCompilerVariables;
+static std::vector<std::string> kCompilerFunctions;
-static std::string cxx_parse_function_call(std::string& _text)
+namespace detail
{
- if (_text[0] == '(') {
- std::string substr;
- std::string args_buffer;
- std::string args;
+ union number_cast
+ {
+ number_cast(UInt64 raw)
+ : raw(raw)
+ {}
- bool type_crossed = false;
+ char number[8];
+ UInt64 raw;
+
+ };
- for (char substr_first_index: _text)
+ struct ast_interface
+ {
+ explicit ast_interface(std::string& value)
+ : mValue(value)
{
- args_buffer += substr_first_index;
+ this->_Compile();
+ }
- if (substr_first_index == ';')
- {
- args_buffer = args_buffer.erase(0, args_buffer.find('('));
- args_buffer = args_buffer.erase(args_buffer.find(';'), 1);
- args_buffer = args_buffer.erase(args_buffer.find(')'), 1);
- args_buffer = args_buffer.erase(args_buffer.find('('), 1);
+ ~ast_interface() = default;
- if (!args_buffer.empty())
- args += "\tpsh ";
+ CXXKIT_COPY_DEFAULT(ast_interface);
- while (args_buffer.find(',') != std::string::npos)
- {
- args_buffer.replace(args_buffer.find(','), 1, "\n\tpsh ");
- }
+ private:
+ std::string mProcessed;
+ std::string mValue;
- args += args_buffer;
- args += "\n\tjlr __import ";
+ void _Compile() noexcept
+ {
+ if (mValue.empty())
+ {
+ return;
}
- }
-
- return args;
- }
- return "";
-}
-
-#include <uuid/uuid.h>
-namespace detail
-{
- union number_type
- {
- number_type(UInt64 raw)
- : raw(raw)
- {}
+ }
- char number[8];
- UInt64 raw;
};
}
@@ -480,7 +464,7 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
#define kPrintF printf
-#define kSplashCxx() kPrintF(kWhite "%s\n", "X64000 C compiler, v1.13, (c) WestCo")
+#define kSplashCxx() kPrintF(kWhite "%s\n", "ccplus, v1.13, (c) Western Company.")
static void cxx_print_help()
{
diff --git a/CompilerDriver/cpp.cxx b/CompilerDriver/cpp.cxx
index d8d32bd..6986e27 100644
--- a/CompilerDriver/cpp.cxx
+++ b/CompilerDriver/cpp.cxx
@@ -2,7 +2,7 @@
* ========================================================
*
* cpp
- * Copyright WestCo, all rights reserved.
+ * Copyright Western Company, all rights reserved.
*
* ========================================================
*/
@@ -926,14 +926,14 @@ int main(int argc, char** argv)
if (strcmp(argv[index], "-v") == 0 ||
strcmp(argv[index], "--version") == 0)
{
- printf("%s\n", "MP-UX Preprocessor v1.11, (c) WestCo");
+ printf("%s\n", "cpp v1.11, (c) Western Company");
return 0;
}
if (strcmp(argv[index], "-h") == 0 ||
strcmp(argv[index], "--help") == 0)
{
- printf("%s\n", "MP-UX Preprocessor v1.11, (c) WestCo");
+ printf("%s\n", "cpp v1.11, (c) Western Company");
printf("%s\n", "--working-dir: set directory to working path.");
printf("%s\n", "--include-dir: add directory to include path.");
printf("%s\n", "--define: define macro.");
diff --git a/CompilerDriver/ld.cxx b/CompilerDriver/ld.cxx
index f101459..d316fe3 100644
--- a/CompilerDriver/ld.cxx
+++ b/CompilerDriver/ld.cxx
@@ -2,7 +2,7 @@
* ========================================================
*
* C++Kit
- * Copyright WestCo, all rights reserved.
+ * Copyright Western Company, all rights reserved.
*
* ========================================================
*/
@@ -30,7 +30,7 @@
//! @brief standard PEF entry.
#define kPefStart "__start"
-#define kToolVersion "MP-UX linker v1.14, (c) WestCo"
+#define kToolVersion "ld v1.15, (c) Western Company"
#define StringCompare(dst, src) strcmp(dst, src)
@@ -68,11 +68,13 @@ static Bool kStartFound = false;
static Bool kDuplicateSymbols = false;
static Bool kVerbose = false;
+/* ld is to be found, mld is to be found at runtime. */
static const char* kLdDefineSymbol = ":ld:";
static const char* kLdDynamicSym = ":mld:";
-static std::vector<char> kObjectBytes;
+/* object code and list. */
static std::vector<std::string> kObjectList;
+static std::vector<char> kObjectBytes;
int main(int argc, char** argv)
{
@@ -94,7 +96,7 @@ int main(int argc, char** argv)
return 0;
}
else if (StringCompare(argv[i], "-v") == 0 ||
- StringCompare(argv[i], "--version") == 0)
+ StringCompare(argv[i], "--version") == 0)
{
kStdOut << kToolVersion << std::endl;
// bye :D
@@ -181,7 +183,7 @@ int main(int argc, char** argv)
pef_container.Kind = CxxKit::kPefKindExec;
pef_container.SubCpu = kSubArch;
pef_container.Cpu = kArch;
- pef_container.Linker = kPefLinkerNumId; // WestCo Linker
+ pef_container.Linker = kPefLinkerNumId; // Western Company Linker
pef_container.Abi = kAbi; // Multi-Processor UX ABI
pef_container.Magic[0] = kPefMagic[kFatBinaryEnable ? 2 : 0];
pef_container.Magic[1] = kPefMagic[1];
@@ -582,4 +584,4 @@ ld_continue_search:
return 0;
}
-// Last rev 2-1-23 \ No newline at end of file
+// Last rev 3-1-24 \ No newline at end of file
diff --git a/CompilerDriver/makefile b/CompilerDriver/makefile
index 828f21a..f22ded6 100644
--- a/CompilerDriver/makefile
+++ b/CompilerDriver/makefile
@@ -2,7 +2,7 @@
# ========================================================
#
# C++Kit
- # Copyright WestCo, all rights reserved.
+ # Copyright Western Company, all rights reserved.
#
# ========================================================
#
diff --git a/CompilerDriver/masm.cxx b/CompilerDriver/masm.cxx
index 4119324..e3be378 100644
--- a/CompilerDriver/masm.cxx
+++ b/CompilerDriver/masm.cxx
@@ -2,7 +2,7 @@
* ========================================================
*
* C++Kit
- * Copyright WestCo, all rights reserved.
+ * Copyright Western Company, all rights reserved.
*
* ========================================================
*/
@@ -122,13 +122,13 @@ int main(int argc, char** argv)
{
if (strcmp(argv[i], "-v") == 0)
{
- kStdOut << "masm: The MP-UX Assembler.\nmasm: Copyright (c) 2023 WestCo.\n";
+ kStdOut << "masm: The MP-UX Assembler.\nmasm: Copyright (c) 2023 Western Company.\n";
return 0;
}
if (strcmp(argv[i], "-h") == 0)
{
- kStdOut << "masm: The MP-UX Assembler.\nmasm: Copyright (c) 2023 WestCo.\n";
+ kStdOut << "masm: The MP-UX Assembler.\nmasm: Copyright (c) 2023 Western Company.\n";
kStdOut << "-v: Print program version.\n";
kStdOut << "-verbose: Print verbose output.\n";
kStdOut << "-m64000: Compile for the X64000 instruction set.\n";
@@ -590,9 +590,9 @@ static std::string masm_check_line(std::string& line, const std::string& file)
namespace detail
{
- union number_type
+ union number_cast
{
- explicit number_type(UInt64 raw)
+ explicit number_cast(UInt64 raw)
: raw(raw)
{}
@@ -623,10 +623,10 @@ static bool masm_write_number(std::size_t pos, std::string& jump_label)
}
}
- detail::number_type num(strtoq(jump_label.substr(pos + 2).c_str(),
+ detail::number_cast num(strtoq(jump_label.substr(pos + 2).c_str(),
nullptr, 16));
- for (char i : num.number)
+ for (char& i : num.number)
{
kBytes.push_back(i);
}
@@ -653,7 +653,7 @@ static bool masm_write_number(std::size_t pos, std::string& jump_label)
}
}
- detail::number_type num(strtoq(jump_label.substr(pos + 2).c_str(),
+ detail::number_cast num(strtoq(jump_label.substr(pos + 2).c_str(),
nullptr, 2));
if (kVerbose)
@@ -661,7 +661,7 @@ static bool masm_write_number(std::size_t pos, std::string& jump_label)
kStdOut << "masm: found a base 2 number here: " << jump_label.substr(pos) << "\n";
}
- for (char i : num.number)
+ for (char& i : num.number)
{
kBytes.push_back(i);
}
@@ -683,7 +683,7 @@ static bool masm_write_number(std::size_t pos, std::string& jump_label)
}
}
- detail::number_type num(strtoq(jump_label.substr(pos + 2).c_str(),
+ detail::number_cast num(strtoq(jump_label.substr(pos + 2).c_str(),
nullptr, 7));
if (kVerbose)
@@ -691,7 +691,7 @@ static bool masm_write_number(std::size_t pos, std::string& jump_label)
kStdOut << "masm: found a base 8 number here: " << jump_label.substr(pos) << "\n";
}
- for (char i : num.number)
+ for (char& i : num.number)
{
kBytes.push_back(i);
}
@@ -715,10 +715,10 @@ static bool masm_write_number(std::size_t pos, std::string& jump_label)
}
}
- detail::number_type num(strtoq(jump_label.substr(pos).c_str(),
+ detail::number_cast num(strtoq(jump_label.substr(pos).c_str(),
nullptr, 10));
- for (char i : num.number)
+ for (char& i : num.number)
{
kBytes.push_back(i);
}