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/cpp.cc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'CompilerDriver/cpp.cc') diff --git a/CompilerDriver/cpp.cc b/CompilerDriver/cpp.cc index 29507b7..3b6d914 100644 --- a/CompilerDriver/cpp.cc +++ b/CompilerDriver/cpp.cc @@ -7,8 +7,8 @@ * ======================================================== */ -#include -#include +#include +#include #include #include #include @@ -58,8 +58,8 @@ namespace details CXXKIT_COPY_DEFAULT(cpp_pragma); - std::string fMacroName{ "" }; - Int32(*fParse)(std::string& line, std::ifstream& hdr_file, std::ofstream& pp_out); + std::string fMacroName; + cpp_parser_fn_t fParse; }; } @@ -144,15 +144,15 @@ int32_t cpp_parse_if_condition(details::cpp_macro_condition& cond, std::string number; - for (auto& macro : kMacros) + for (auto& macro_num : kMacros) { - if (substr_macro.find(macro.fName) != std::string::npos) + if (substr_macro.find(macro_num.fName) != std::string::npos) { - for (size_t i = 0; i < macro.fName.size(); ++i) + for (size_t i = 0; i < macro_num.fName.size(); ++i) { - if (isdigit(macro.fValue[i])) + if (isdigit(macro_num.fValue[i])) { - number += macro.fValue[i]; + number += macro_num.fValue[i]; } else { @@ -287,9 +287,7 @@ void cpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) std::string line_after_include; bool inactive_code = false; - bool comment = false; bool defined = false; - bool else_branch = false; try { @@ -473,15 +471,15 @@ void cpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) std::string symbol; - for (size_t i = 0; i < macro.fValue.size(); i++) + for (char i : macro.fValue) { - if (macro.fValue[i] == '(') + if (i == '(') break; - if (macro.fValue[i] == '\\') + if (i == '\\') continue; - symbol += macro.fValue[i]; + symbol += i; } hdr_line.replace(hdr_line.find(macro.fName), macro.fName.size(), symbol); @@ -596,8 +594,6 @@ void cpp_parse_file(std::ifstream& hdr_file, std::ofstream& pp_out) continue; } - - else_branch = true; } else if (hdr_line[0] == '#' && hdr_line.find("ifdef") != std::string::npos) @@ -845,7 +841,11 @@ kIncludeFile: for (auto& include : kIncludes) { - std::ifstream header(include + '/' + path); + std::string header_path = include; + header_path.push_back('/'); + header_path += path; + + std::ifstream header(header_path); if (!header.is_open()) continue; @@ -857,7 +857,7 @@ kIncludeFile: break; } - if (open == false) + if (!open) { throw std::runtime_error("cpp: no such include file: " + path); } -- cgit v1.2.3