diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-04 15:26:59 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-04 15:26:59 +0100 |
| commit | 60271b79a91a06772241aed737426f5d097ca533 (patch) | |
| tree | 62d5d5407beb877dc6b3d2177b2a9ee4f9fe7c8c | |
| parent | 6171a0adfacdc5834f2fc2a9d885ba3ef3cc15d8 (diff) | |
mpcc: add support for .cc
ld: abort when an unknown flag is found.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
| -rw-r--r-- | CompilerDriver/cc.cc | 7 | ||||
| -rw-r--r-- | CompilerDriver/ld.cc | 15 | ||||
| -rw-r--r-- | CompilerFrontend/cl/.gitignore | 3 | ||||
| -rw-r--r-- | CompilerFrontend/cl/compiler.d | 24 |
4 files changed, 39 insertions, 10 deletions
diff --git a/CompilerDriver/cc.cc b/CompilerDriver/cc.cc index 7d34875..4135be0 100644 --- a/CompilerDriver/cc.cc +++ b/CompilerDriver/cc.cc @@ -50,6 +50,12 @@ namespace detail std::string fRegister; }; + struct CompilerClass + { + CompilerRegisterMap fRootRegister; + std::vector<CompilerRegisterMap> fRegisters; + }; + struct CompilerState { std::vector<ParserKit::SyntaxLeafList> fSyntaxTreeList; @@ -652,6 +658,7 @@ bool CompilerBackendClang::Compile(const std::string& text, const char* file) _text.find("struct") == std::string::npos && _text.find("extern") == std::string::npos && _text.find("union") == std::string::npos && + _text.find("class") == std::string::npos && _text.find("typedef") == std::string::npos) substr += "__export .data "; } diff --git a/CompilerDriver/ld.cc b/CompilerDriver/ld.cc index f1ac535..f3a2225 100644 --- a/CompilerDriver/ld.cc +++ b/CompilerDriver/ld.cc @@ -144,12 +144,16 @@ int main(int argc, char** argv) } else { + if (argv[i][0] == '-') + { + kStdOut << "ld: unknown flag: " << argv[i] << "\n"; + return -CXXKIT_EXEC_ERROR; + } + kObjectList.emplace_back(argv[i]); continue; } - - kStdOut << "ld: ignore flag: " << argv[i] << "\n"; } // sanity check. @@ -319,8 +323,8 @@ ld_mark_header: std::vector<char> bytes; bytes.resize(ae_header.fCodeSize); - input_object.seekg(ae_header.fStartCode); - input_object.read(bytes.data(), ae_header.fCodeSize); + input_object.seekg(std::streamsize(ae_header.fStartCode)); + input_object.read(bytes.data(), std::streamsize(ae_header.fCodeSize)); for (auto& byte : bytes) { @@ -481,6 +485,7 @@ ld_continue_search: // prepare a symbol vector. std::vector<std::string> undefined_symbols; std::vector<std::string> duplicate_symbols; + std::vector<std::string> symbols_to_resolve; // Finally write down the command headers. // And check for any duplications @@ -524,7 +529,7 @@ ld_continue_search: { if (std::find(duplicate_symbols.cbegin(), duplicate_symbols.cend(), pef_command_hdr.Name) == duplicate_symbols.cend()) { - duplicate_symbols.push_back(pef_command_hdr.Name); + duplicate_symbols.emplace_back(pef_command_hdr.Name); } if (kVerbose) diff --git a/CompilerFrontend/cl/.gitignore b/CompilerFrontend/cl/.gitignore index 76a16b1..2641307 100644 --- a/CompilerFrontend/cl/.gitignore +++ b/CompilerFrontend/cl/.gitignore @@ -6,7 +6,8 @@ bin/masm bin/mkcdfs bin/ccplus bin/cppfront - +test/*.cc +test/*.64x *.c.pp *.cxx.pp test/*.c diff --git a/CompilerFrontend/cl/compiler.d b/CompilerFrontend/cl/compiler.d index 23cfd22..7c38a06 100644 --- a/CompilerFrontend/cl/compiler.d +++ b/CompilerFrontend/cl/compiler.d @@ -71,17 +71,33 @@ public class CompileCommand ~ " " ~ " --working-dir ./ --include-dir " ~ includePath ~ " " ~ file); - mcc_summon_executable("/usr/local/bin/bin/cc --asm=masm -fmax-exceptions 20 --compiler=dolvik " ~ - file ~ ".pp"); - string changed; + string ext; + bool ext_now = false; foreach (ch; file) { if (ch == '.') + { + ext_now = true; break; + } - changed ~= ch; + if (!ext_now) + changed ~= ch; + else + ext ~= ch; + } + + if (ext == ".cc") + { + mcc_summon_executable("/usr/local/bin/bin/ccplus --asm=masm -fmax-exceptions 20 --compiler=dolvik " ~ + file ~ ".pp"); + } + else + { + mcc_summon_executable("/usr/local/bin/bin/cc --asm=masm -fmax-exceptions 20 --compiler=dolvik " ~ + file ~ ".pp"); } changed ~= ".64x"; |
