From 448b876120f7f5e54776e956648c17cce8daa301 Mon Sep 17 00:00:00 2001 From: msojocs Date: Sun, 18 Jun 2023 16:46:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/wxml.h | 35 +++--- src/wcc.cpp | 32 +++-- src/wxml/compiler.cpp | 287 +++++++++++++++++++++--------------------- 3 files changed, 175 insertions(+), 179 deletions(-) diff --git a/src/include/wxml.h b/src/include/wxml.h index 2532c60..fb1fae4 100644 --- a/src/include/wxml.h +++ b/src/include/wxml.h @@ -299,13 +299,26 @@ namespace WXML namespace Compiler { + WXML::DOMLib::Parser ParseSource( + std::string const& content, // 源码?a2 + std::string const& fileName, // 文件名? a3 + char lineEndMark, // '\n' a4 + std::string const& gwxMark, // gwxMark a5 + std::string const& fMark, // "f_" a6 + std::map const&, // fileData a7 + std::string&, // 错误信息 a8 + std::map>&,// map a9 + std::map&,// ??? a10 + std::map&, // ??? a11 + bool, // mark指定运算结果是否非0 a12 + bool); // mark指定运算结果是否非0 a13 int CompileLazy( std::map const& fileContent, std::string& errorMessage, // 错误信息 - std::map& outputMap, // 输出1 - std::map& dict, // 输出2 - std::map>, - std::map>, // vecFileContentMap + std::map& outputContentMap, // 输出1 编译后的代码映射 + std::map& outputFuncMap, // 输出2 编译后的函数名 + std::map>&, + std::map>& componentListMap, // vecFileContentMap componentList 页面使用的组件列表 std::vector const&, // splitedData std::map const&, // mapData1 bool, // isLLA @@ -360,20 +373,6 @@ namespace WXML // void GetFuncId(); void GetVersionInfo(std::string &a1, std::string a2); - - WXML::DOMLib::Parser ParseSource( - std::string const& content, // 源码?a2 - std::string const& fileName, // 文件名? a3 - char lineEndMark, // '\n' a4 - std::string const& gwxMark, // gwxMark a5 - std::string const& fMark, // "f_" a6 - std::map const&, // fileData a7 - std::string&, // 错误信息 a8 - std::map,// map a9 - std::map&,// ??? a10 - std::map, // ??? a11 - bool, // mark指定运算结果是否非0 a12 - bool); // mark指定运算结果是否非0 a13 int RenderDefine( WXML::DOMLib::WXMLDom &, std::string const&, diff --git a/src/wcc.cpp b/src/wcc.cpp index d935f95..9db0128 100644 --- a/src/wcc.cpp +++ b/src/wcc.cpp @@ -69,7 +69,7 @@ int main(int argc, const char **argv) vector splitedData; map mapData1; map fileContentMap; - map> vecFileContentMap; + map> componentListMap; for (int i = 0; i < paramList.size(); i++) { string param = paramList[i]; @@ -300,37 +300,33 @@ int main(int argc, const char **argv) if (!xc_Or_completeCode_Param.empty()) { string data; - string arg2; - vector list1; - vector list2; + vector allComponentList; data = getNextArg(xc_Or_completeCode_Param, splitMarkStr); unsigned long long count = strtoull(&data[0], 0, 10); for (unsigned long long i = 0; i < count; i++) { + vector componentList; string arg1 = getNextArg(xc_Or_completeCode_Param, splitMarkStr); data = getNextArg(xc_Or_completeCode_Param, splitMarkStr); unsigned long long jCount = strtoull(&data[0], 0, 10); for (unsigned long long i = 0; i < jCount; i++) { - arg2 = getNextArg(xc_Or_completeCode_Param, splitMarkStr); - list1.push_back(arg2); - auto it = vecFileContentMap.find(arg2); - if (it == vecFileContentMap.end()) + string componentName = getNextArg(xc_Or_completeCode_Param, splitMarkStr); + componentList.push_back(componentName); + // TODO: 确认逻辑是否正确 + auto it = std::find(allComponentList.begin(), allComponentList.end(), componentName); + if (it == allComponentList.end()) { - list2.push_back(arg2); + allComponentList.push_back(componentName); } } - // TODO: 还有问题 - auto it = vecFileContentMap.lower_bound(arg1); - if (it == vecFileContentMap.end() || arg1 < it->first) + auto it = componentListMap.lower_bound(arg1); + if (it == componentListMap.end() || arg1 < it->first) { - vector d; - vecFileContentMap.emplace(arg1, d); + componentListMap.emplace(arg1, componentList); } - // list1 - it->second = list1; } - vecFileContentMap["ALL"] = list2; + componentListMap["ALL"] = allComponentList; } // @@ -359,7 +355,7 @@ int main(int argc, const char **argv) outputMap1, outputMap2, // map vecFileContentMap2, // std::map> - vecFileContentMap, // vecFileContentMap + componentListMap, // componentListMap splitedData, mapData1, isLLA, diff --git a/src/wxml/compiler.cpp b/src/wxml/compiler.cpp index ea933bd..f792e1f 100644 --- a/src/wxml/compiler.cpp +++ b/src/wxml/compiler.cpp @@ -8,159 +8,23 @@ namespace WXML{ namespace Compiler { - int CompileLazy( - std::map const& fileContentMap, - std::string& errorMessage, // 错误信息 - std::map& outputMap, // 输出 - std::map& dict, // 输出 - std::map>, - std::map>, // vecFileContentMap - std::vector const& splitedData, // splitedData - std::map const& mapData1, // mapData1 - bool isLLA, // isLLA - std::string const& gwxMark, // gwxMark - uint mark, // mark - char lineEndMark, // '\n' - std::string const& , // 'e' - std::string const& , // const char off_5403C3[] = {'s','\0','e','\0'} - std::string const& ggMark, // "gg" - std::string const& eMark, // "e_" - std::string const& dMark, // "d_" - std::string const& pMark, // "p_" - std::string const& strEndMark, // '\0' - std::string const& boxMark, // "boxofchocolate" - std::string const& gdwxMark, // "$gdwx" - std::string const& fMark // "f_" - ) - { - try - { - /* code */ - std::map> ssDataMap; - std::map> v307_localVecStrMap1; - for (auto it = fileContentMap.begin(); it != fileContentMap.end(); it++) - { - /* code */ - // WXML::DOMLib::Parser parseResult = ParseSource( - // it->second, // 源码?a2 - // it->first, // 文件名 a3 - // lineEndMark, // '\n' a4 - // gwxMark, // gwxMark a5 - // fMark, // "f_" a6 - // fileContentMap, // fileContentMap a7 - // errorMessage, // 错误信息 a8 - // &v304, // map a9 - // &v309, // ??? a10 - // &v311, // ??? a11 - // (mark & 4) != 0, // a11 -> mark a12 - // (mark & 0x20) != 0); // a13 - // if (parseResult) { - // return parseResult; - // } - } - std::shared_ptr v301_localCommonStream1; // v301 - ssDataMap["__COMMON__"] = v301_localCommonStream1; - std::vector commonVec; - v307_localVecStrMap1["__COMMON__"] = commonVec; - - for (int i = 0; i < splitedData.size(); i++) - { - std::shared_ptr v328_ss; - auto it = ssDataMap.lower_bound(splitedData[i]); - if (it == ssDataMap.end()) - { - - } - std::string path = "./" + splitedData[i] + ".wxml"; - std::vector j; - j.push_back(path); - v307_localVecStrMap1[splitedData[i]] = j; - } - // for (auto it = splitedData.begin(); it != splitedData.end(); it++) - // { - - // } - - - } - catch(const std::exception& e) - { - std::cerr << e.what() << '\n'; - } - - return 0; - } - - - int DealWxsTag( - std::string const& a1, - std::string &a2, - std::string& a3, - std::string& a4, - std::string& a5, - int & a6, - std::string& a7) - { - int pos = a2.find('>', a2[4]); - std::string sub; - if (a2[pos - 1] == '/') - { - // 这个尖括号附近是这样的:/> - sub = a2.substr(a2[4] + 1, pos + 1 - a2[4] - 6); - } - else - { - sub = a2.substr(a2[4] + 1, pos + 1 - a2[4] - 5); - } - std::string data = ""); - for (int i = 1; i < a2[2]; i++) - { - data = "\n" + data; - } - for (int i = 1; i < a2[3]; i++) - { - data = " " + data; - } - // WXML::DOMLib::Parser::Parser(data); - // TODO... - return 0; - } - - void GetVersionInfo(std::string &a1, std::string a2) - { - std::stringstream result; - result << "/*"; - result << "v0.5vv_20200413_syb_scopedata"; - result << "*/"; - - result << a2; - result << ".__wcc_version__='"; - result << "v0.5vv_20200413_syb_scopedata"; - result << "';"; - result << a2; - result << ".__wcc_version_info__={\"customComponents\":true,\"fixZeroRpx\":true,\"propValueDeepCopy\":false};"; - result.str(a1); - } - WXML::DOMLib::Parser ParseSource( - std::string const& fileName, // 文件名?a2 - std::string const& content, // 源码?a3 + std::string const& fileName, // 文件名a2 + std::string const& content, // 源码a3 char lineEndMark, // '\n' a4 std::string const& gwxMark, // gwxMark a5 std::string const& fMark, // "f_" a6 - std::map const&, // fileContentMap a7 + std::map const& fileContentMap, // fileContentMap a7 std::string& errorMessage, // 错误信息 a8 - std::map result,// map a9 + std::map>& result,// map a9 std::map& map1,// ??? a10 - std::map map2, // ??? a11 + std::map& map2, // ??? a11 bool b1, // mark指定运算结果是否非0 a12 bool b2) // mark指定运算结果是否非0 a13 { WXML::DOMLib::Parser pResult; bool isWxml = fileName.substr(fileName.length() - 5) == ".wxml"; - if (isWxml) + if (isWxml) { // parse bool parseResult = false; @@ -171,7 +35,7 @@ namespace WXML{ if (parseResult) { // GetParsed - // WXML::DOMLib::WXMLDom parseDom = v50.GetParsed(); + WXML::DOMLib::WXMLDom parseDom = v50.GetParsed(); // result[fileName] = parseDom; int a; int b; @@ -311,6 +175,143 @@ namespace WXML{ } return pResult; } + + int CompileLazy( + std::map const& fileContentMap, // a2 + std::string& errorMessage, // 错误信息 a3 + std::map& outputContentMap, // 输出 a4 + std::map& outputFuncMap, // 输出 a5 + std::map>& dependencyListMap, // a6 + std::map>& componentListMap, // componentListMap a7 + std::vector const& splitedData, // splitedData a8 + std::map const& mapData1, // mapData1 a9 + bool isLLA, // isLLA a10 + std::string const& gwxMark, // gwxMark a11 + uint mark, // mark + char lineEndMark, // '\n' + std::string const& eMark1, // 'e' + std::string const& charArr, // const char off_5403C3[] = {'s','\0','e','\0'} + std::string const& ggMark, // "gg" + std::string const& eMark, // "e_" + std::string const& dMark, // "d_" + std::string const& pMark, // "p_" + std::string const& strEndMark, // '\0' + std::string const& boxMark, // "boxofchocolate" + std::string const& gdwxMark, // "$gdwx" + std::string const& fMark // "f_" + ) + { + try + { + /* code */ + std::map> ssDataMap; + std::map> v307_localVecStrMap1; + std::map> v304; + std::map v309; + std::map v311; + for (auto it = fileContentMap.begin(); it != fileContentMap.end(); it++) + { + /* code */ + WXML::DOMLib::Parser parseResult = WXML::Compiler::ParseSource( + it->second, // 源码?a2 + it->first, // 文件名 a3 + lineEndMark, // '\n' a4 + gwxMark, // gwxMark a5 + fMark, // "f_" a6 + fileContentMap, // fileContentMap a7 + errorMessage, // 错误信息 a8 + v304, // map a9 + v309, // ??? a10 + v311, // ??? a11 + (mark & 4) != 0, // a11 -> mark a12 + (mark & 0x20) != 0); // a13 + } + std::shared_ptr v301_localCommonStream1; // v301 + ssDataMap["__COMMON__"] = v301_localCommonStream1; + std::vector commonVec; + v307_localVecStrMap1["__COMMON__"] = commonVec; + + for (int i = 0; i < splitedData.size(); i++) + { + std::shared_ptr v328_ss; + auto it = ssDataMap.lower_bound(splitedData[i]); + if (it == ssDataMap.end()) + { + + } + std::string path = "./" + splitedData[i] + ".wxml"; + std::vector j; + j.push_back(path); + v307_localVecStrMap1[splitedData[i]] = j; + } + // for (auto it = splitedData.begin(); it != splitedData.end(); it++) + // { + + // } + + + } + catch(const std::exception& e) + { + std::cerr << e.what() << '\n'; + } + + return 0; + } + + + int DealWxsTag( + std::string const& a1, + std::string &a2, + std::string& a3, + std::string& a4, + std::string& a5, + int & a6, + std::string& a7) + { + int pos = a2.find('>', a2[4]); + std::string sub; + if (a2[pos - 1] == '/') + { + // 这个尖括号附近是这样的:/> + sub = a2.substr(a2[4] + 1, pos + 1 - a2[4] - 6); + } + else + { + sub = a2.substr(a2[4] + 1, pos + 1 - a2[4] - 5); + } + std::string data = ""); + for (int i = 1; i < a2[2]; i++) + { + data = "\n" + data; + } + for (int i = 1; i < a2[3]; i++) + { + data = " " + data; + } + // WXML::DOMLib::Parser::Parser(data); + // TODO... + return 0; + } + + void GetVersionInfo(std::string &a1, std::string a2) + { + std::stringstream result; + result << "/*"; + result << "v0.5vv_20200413_syb_scopedata"; + result << "*/"; + + result << a2; + result << ".__wcc_version__='"; + result << "v0.5vv_20200413_syb_scopedata"; + result << "';"; + result << a2; + result << ".__wcc_version_info__={\"customComponents\":true,\"fixZeroRpx\":true,\"propValueDeepCopy\":false};"; + result.str(a1); + } + int RenderDefine( WXML::DOMLib::WXMLDom & a1, std::string const& a2,