From 6cda526bd4efcee31b1ea7405dc46d7985ba64e6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 4 Jan 2024 21:36:54 +0100 Subject: masm: fix assembler bug where addr1, 0x0 (add r1, 0x0) doesn't error out. cc/ccplus: minor compiler changes, will get to them very soon... refactor: rename C++Kit to CompilerKit. Signed-off-by: Amlal El Mahrouss --- CompilerDriver/cc.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'CompilerDriver/cc.cc') diff --git a/CompilerDriver/cc.cc b/CompilerDriver/cc.cc index 4135be0..d3f48d8 100644 --- a/CompilerDriver/cc.cc +++ b/CompilerDriver/cc.cc @@ -13,8 +13,8 @@ #include #include #include -#include -#include +#include +#include #define kOk 0 @@ -134,7 +134,7 @@ static std::string kRegisterPrefix = kAsmRegisterPrefix; ///////////////////////////////////////// static std::vector kFileList; -static CxxKit::AssemblyFactory kFactory; +static CompilerKit::AssemblyFactory kFactory; static bool kInStruct = false; static bool kOnWhileLoop = false; static bool kOnForLoop = false; @@ -1619,7 +1619,7 @@ next: ///////////////////////////////////////////////////////////////////////////////////////// -class AssemblyMountpointClang final : public CxxKit::AssemblyMountpoint +class AssemblyMountpointClang final : public CompilerKit::AssemblyMountpoint { public: explicit AssemblyMountpointClang() = default; @@ -1627,9 +1627,9 @@ public: CXXKIT_COPY_DEFAULT(AssemblyMountpointClang); - [[maybe_unused]] static Int32 Arch() noexcept { return CxxKit::AssemblyFactory::kArchRISCV; } + [[maybe_unused]] static Int32 Arch() noexcept { return CompilerKit::AssemblyFactory::kArchRISCV; } - Int32 CompileToFormat(CxxKit::StringView& src, Int32 arch) override + Int32 CompileToFormat(CompilerKit::StringView& src, Int32 arch) override { if (arch != AssemblyMountpointClang::Arch()) return -1; @@ -1657,7 +1657,7 @@ public: kState.fOutputAssembly = std::make_unique(dest); - auto fmt = CxxKit::current_date(); + auto fmt = CompilerKit::current_date(); (*kState.fOutputAssembly) << "# Path: " << src_file << "\n"; (*kState.fOutputAssembly) << "# Language: MP-UX Assembly\n"; @@ -1688,6 +1688,10 @@ public: std::vector keywords = { "ldw", "stw", "lda", "sta", "add", "dec", "mv"}; + /// + /// Replace, optimize, fix assembly output. + /// + for (auto& leaf : kState.fSyntaxTree->fLeafList) { for (auto& keyword : keywords) @@ -1835,7 +1839,7 @@ int main(int argc, char** argv) delete kFactory.Unmount(); kFactory.Mount(new AssemblyMountpointClang()); - kMachine = CxxKit::AssemblyFactory::kArchRISCV; + kMachine = CompilerKit::AssemblyFactory::kArchRISCV; continue; } @@ -1875,7 +1879,7 @@ int main(int argc, char** argv) kFileList.emplace_back(argv[index]); - CxxKit::StringView srcFile = CxxKit::StringBuilder::Construct(argv[index]); + CompilerKit::StringView srcFile = CompilerKit::StringBuilder::Construct(argv[index]); if (strstr(argv[index], kExt) == nullptr) { -- cgit v1.2.3