From 396b2d11ad8d2ce073d9a9c16a8d20adad6c3258 Mon Sep 17 00:00:00 2001 From: msojocs Date: Thu, 8 Jun 2023 21:34:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90main=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E7=9A=84=E5=A4=A7=E8=87=B4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 9 +- CMakeLists.txt | 2 + src/include/file.h | 4 +- src/include/string_utils.h | 9 + src/include/wxml.h | 68 +++++--- src/utils/file.cpp | 27 +-- src/utils/string_utils.cpp | 28 +++ src/wcc.cpp | 290 ++++++++++++++++++++++++++++++-- src/wcc/usage.cpp | 2 +- src/wxml/compiler.cpp | 14 +- src/wxml/dom_lib.cpp | 14 ++ src/wxml/expr_lib/tokenizer.cpp | 14 ++ src/wxml/rewrite.cpp | 14 ++ test/wcc.cpp | 229 +++++++++++++------------ 14 files changed, 551 insertions(+), 173 deletions(-) create mode 100644 src/include/string_utils.h create mode 100644 src/utils/string_utils.cpp create mode 100644 src/wxml/rewrite.cpp diff --git a/.vscode/settings.json b/.vscode/settings.json index ec22469..24e9ce0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -44,6 +44,13 @@ "stdexcept": "cpp", "streambuf": "cpp", "typeinfo": "cpp", - "cstring": "cpp" + "cstring": "cpp", + "map": "cpp" + }, + "cmake.debugConfig": { + "args": [ + "-llw", + "111,222" + ] } } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index d75b922..813efc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ enable_testing() add_executable(wcc src/wcc.cpp src/wcc/usage.cpp + src/wxml/compiler.cpp + src/utils/string_utils.cpp src/utils/file.cpp ) add_executable(wcsc diff --git a/src/include/file.h b/src/include/file.h index 0ef0896..8404660 100644 --- a/src/include/file.h +++ b/src/include/file.h @@ -1,7 +1,7 @@ #ifndef __FILE_H__ #define __FILE_H__ -int readFile (std::string fileName, std::string result); -void getNextArg(std::string &line, std::string &data, char lineEndMark); +int readFile (const char* fileName, std::string &result); +std::string getNextArg(std::string &data, std::string const & lineEndMark); #endif \ No newline at end of file diff --git a/src/include/string_utils.h b/src/include/string_utils.h new file mode 100644 index 0000000..70af5f8 --- /dev/null +++ b/src/include/string_utils.h @@ -0,0 +1,9 @@ +#ifndef __STRING_UTILS_H__ +#define __STRING_UTILS_H__ +#include +#include + +std::string& trim(std::string &s); +void split(std::vector result, std::string source, std::string mark); + +#endif \ No newline at end of file diff --git a/src/include/wxml.h b/src/include/wxml.h index 9d3fb57..864ff4b 100644 --- a/src/include/wxml.h +++ b/src/include/wxml.h @@ -2,6 +2,9 @@ #define __WXML_H_ #include +#include +#include +#include namespace WXML{ class Compiler @@ -11,22 +14,41 @@ namespace WXML{ public: Compiler(/* args */); ~Compiler(); - static void CompileLazy(); - static void DealWxsTag(); - static void GetFuncId(); - static void GetVersionInfo(int a1, int *a2); - static void ParseSource(); - static void RenderDefine(); + + + static std::string CompileLazy( + std::map const&, + std::string&, + std::map&, + std::map&, + std::map, std::less, std::allocator>>>, + std::allocator>, + std::allocator const&, + std::map const&, + bool, + std::string const&, + uint, + char, + std::string const&, + std::string const&, + std::string const&, + std::string const&, + std::string const&, + std::string const&, + std::string const&, + std::string const&, + std::string const&, + std::string const&, + std::string const&); + + // static void DealWxsTag(); + // static void GetFuncId(); + static void GetVersionInfo(std::string &a1, std::string a2); + // static void ParseSource(); + // static void RenderDefine(); static void WXMLHelperCode(std::string &result); }; - Compiler::Compiler(/* args */) - { - } - - Compiler::~Compiler() - { - } class DOMLib { @@ -38,13 +60,16 @@ namespace WXML{ ~DOMLib(); }; - DOMLib::DOMLib(/* args */) + class Rewrite { - } + private: + /* data */ + public: + Rewrite(/* args */); + ~Rewrite(); + + }; - DOMLib::~DOMLib() - { - } namespace EXPRLib { @@ -57,13 +82,6 @@ namespace WXML{ ~Tokenizer(); }; - Tokenizer::Tokenizer(/* args */) - { - } - - Tokenizer::~Tokenizer() - { - } } // namespace EXPRLib diff --git a/src/utils/file.cpp b/src/utils/file.cpp index 1f0f557..78e68de 100644 --- a/src/utils/file.cpp +++ b/src/utils/file.cpp @@ -1,6 +1,7 @@ #include #include #include "../include/file.h" +#include "../include/string_utils.h" /** * 读取文件内容 @@ -10,17 +11,15 @@ * * @return int 0成功 | -1失败 */ -int readFile (std::string fileName, std::string &result) { - FILE *f = NULL; +int readFile (const char* fileName, std::string &result) { + FILE *f = stdin; char temp[1020]; char buf[1024]; unsigned int len; result = "\0"; - if (fileName.empty()) { - return -1; - } - f = fopen(fileName.c_str(), "r"); + if (fileName) + f = fopen(fileName, "r"); if (!f) { return -1; } @@ -39,25 +38,13 @@ int readFile (std::string fileName, std::string &result) { return 0; } -std::string& trim(std::string &s) -{ - if (s.empty()) - { - return s; - } - - s.erase(0,s.find_first_not_of(" ")); - s.erase(s.find_last_not_of(" ") + 1); - return s; -} - /** * * @param line 存储行数据的容器 * @param data 配置内容数据 * @param lineEndMark 行结束标志 \n */ -void getNextArg(std::string &line, std::string &data, char lineEndMark) { +std::string getNextArg(std::string &data, std::string const & lineEndMark) { int pos = data.find(lineEndMark, 0); std::string lineData; if (pos == -1) { @@ -69,5 +56,5 @@ void getNextArg(std::string &line, std::string &data, char lineEndMark) { data = data.substr(pos); } trim(lineData); - line = lineData; + return lineData; } \ No newline at end of file diff --git a/src/utils/string_utils.cpp b/src/utils/string_utils.cpp new file mode 100644 index 0000000..8b9c0bf --- /dev/null +++ b/src/utils/string_utils.cpp @@ -0,0 +1,28 @@ +#include "../include/string_utils.h" + +std::string& trim(std::string &s) +{ + if (s.empty()) + { + return s; + } + + s.erase(0, s.find_first_not_of(" ")); + s.erase(s.find_last_not_of(" ") + 1); + return s; +} + + +void split(std::vector result, std::string source, std::string mark) { + int currentPos = 0; + for (int i = source.find(mark, 0); ; i = source.find(mark, currentPos)) + { + std::string ele = source.substr(currentPos, i); + trim(ele); + result.emplace_back(ele); + if (i == -1) + break; + currentPos = i + 1; + } + +} \ No newline at end of file diff --git a/src/wcc.cpp b/src/wcc.cpp index f9739f6..9c58890 100644 --- a/src/wcc.cpp +++ b/src/wcc.cpp @@ -1,14 +1,20 @@ #include #include +#include +#include #include "include/file.h" #include "include/usage.h" +#include "include/string_utils.h" +#include "include/wxml.h" using namespace std; -int main(int argc, char **argv) { +int main(int argc, const char **argv) { + + printf("argc: %d\n", argc); string gwxMark = "$gwx"; - string blankStr = " "; + string splitMarkStr = " "; bool hasConfigParam = false; string configPathLocation; vector paramList; @@ -32,28 +38,31 @@ int main(int argc, char **argv) { // 有配置文件,从配置文件解析 if (hasConfigParam) { - int ret = readFile(configPathLocation, configData); + int ret = readFile(configPathLocation.c_str(), configData); string line; if (0 == ret) { - getNextArg(line, configData, '\n'); + line = getNextArg(configData, "\n"); paramList.emplace_back(line); } } int mark = 0; - bool end = false; + bool isReadFromStdin = false; bool version = false; bool hasXCParam = false; - string xcParam; - bool hasCallbackParam = false; - string callbackParam; + bool hasCompleteCodeParam = false; + bool hasLL = false; + string xc_Or_completeCode_Param; string outputFileName; - vector temp; + vector temp; + vector splitedData; + map mapData1; + map fileData; for (int i = 0; i < paramList.size(); i++) { string param = paramList[i]; if (param[0] != '-') { // 不是参数名,跳过 - temp.push_back(param[0]); + temp.push_back(param); continue; } @@ -80,8 +89,8 @@ int main(int argc, char **argv) { continue; } if (i + 1 < paramList.size()) { - temp.push_back(param[2]); - end = true; + temp.push_back(paramList[i + 1]); + isReadFromStdin = true; } break; case 'v': @@ -98,7 +107,7 @@ int main(int argc, char **argv) { if(param[2] == 'c' && i < paramList.size()) { hasXCParam = true; if(paramList[i + 1][0] != '-') { - xcParam.assign(paramList[i + 1]); + xc_Or_completeCode_Param.assign(paramList[i + 1]); i++; } continue; @@ -106,12 +115,11 @@ int main(int argc, char **argv) { break; case 'c': // -cc: output compelete code for custom component - // -cb [callback.js...] /* code */ if(param[2] == 'c' && i + 1 < paramList.size()) { - hasCallbackParam = true; + hasCompleteCodeParam = true; if(paramList[i + 1][0] != '-') { - callbackParam.assign(paramList[i + 1]); + xc_Or_completeCode_Param.assign(paramList[i + 1]); i++; } continue; @@ -153,9 +161,257 @@ int main(int argc, char **argv) { default: break; } + // switch end + + if (param == "--split") { + if (i + 1 < paramList.size()) { + splitMarkStr = paramList[i + 1]; + i++; + continue; + } + } + + // -cb + if(param[1] == 'c' && param[2] == 'b') { + string callbackFile = paramList[i + 1]; + string callbackData; + readFile(callbackFile.c_str(), callbackData); + if (!callbackData.empty()) { + mapData1["life_cycle_callback_content"] = callbackData; + } + } + else { + if(!param.compare("--pm")) { + // 参数是--pm + if (i + 1 < paramList.size()) { + mapData1["plain_text_marker"] = paramList[i + 1]; + continue; + } + } + if (param[1] == 'l' && param[2] == 'l') { + // -ll + if (param[3] != 'w') { + // 不是 -llw + if (param[3] != 'a') { + // 不是 -lla + printf("Error: expected -llw or -lla, but got %s\n", param.c_str()); + return -1; + } + } + string splitMark; + if (!splitMarkStr.compare(" ")) { + // 空格 + splitMark = ","; + }else { + // 不是空格 + splitMark = splitMarkStr; + } + split(splitedData, paramList[i + 1], splitMark); + hasLL = true; + } + } } - + if (version) { + std::string versionInfo; + WXML::Compiler::GetVersionInfo(versionInfo, "global"); + if (!outputFileName.empty()) { + FILE *f; + f = fopen(outputFileName.c_str(), "w"); + fprintf(f, "%s\n", versionInfo.c_str()); + fclose(f); + } + } + if (temp.empty()) { + usage(argc, argv); + return 0; + } + + if (isReadFromStdin) { + string content; + readFile(0, content); + fileData[temp[0]] = content; + } + else { + + // 读取文件内容 + for (int i = 0; i < temp.size(); i++) + { + string content; + readFile(temp[i].c_str(), content); + fileData[temp[i]] = content; + } + + } + + if (true) { + string data; + 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++) + { + string data1 = getNextArg(xc_Or_completeCode_Param, splitMarkStr); + data = getNextArg(xc_Or_completeCode_Param, splitMarkStr); + unsigned long long jCount = strtoull(&data[0], 0, 10); + vector list; + for (unsigned long long i = 0; i < jCount; i++) + { + string data2 = getNextArg(xc_Or_completeCode_Param, splitMarkStr); + list.push_back(data2); + vector::iterator it = find(splitedData.begin(), splitedData.end(), data2); + if (it == splitedData.end()) { + splitedData.push_back(data2); + } + } + auto fileContent = fileData.lower_bound(data1); + if (fileContent == fileData.end()) { + // fileData.ins(data1, 5) + } + //TODO... + + } + + } + + // + if (hasLL) { + for (int i = 0; i < 999; i++) + { + /* code */ + } + map outputMap; + const char off_5403C3[] = {'s','\0','e','\0'}; + int compilerResult = 0; + // compilerResult = WXML::Compiler::CompileLazy( + // &v107, + // (int *)v111, + // outputMap, + // &v101, + // &v121, + // v126, + // (int *)&v92, + // &v105, + // v53, + // (int)gwxMark, + // mark, + // 10, + // &off_5403C3[2], + // off_5403C3, + // "gg", + // "e_", + // "d_", + // "p_", + // "\0", + // "boxofchocolate", + // "$gdwx", + // "f_"); + // while() + + // if() + if (1) { + string helperCode; + WXML::Compiler::WXMLHelperCode(helperCode); + string data = "var __wxAppData=__wxAppData||{};var __wxAppCode__=__wxAppCode__||{};var global=global||{};var __WXML_GLOBAL__=" + "__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_init:undefined,total_ops:0};var Component=Comp" + "onent||function(){};var definePlugin=definePlugin||function(){};var requirePlugin=requirePlugin||function(){};" + "var Behavior=Behavior||function(){};var __vd_version_info__=__vd_version_info__||{};var __GWX_GLOBAL__=__GWX_G" + "LOBAL__||{};var __globalThis=(typeof __vd_version_info__!=='undefined'&&typeof __vd_version_info__.globalThis!" + "=='undefined')?__vd_version_info__.globalThis:(typeof window!=='undefined'?window:globalThis);"; + data = data + helperCode; + outputMap["__COMMON__"] = data; + } + else { + string helperCode; + WXML::Compiler::WXMLHelperCode(helperCode); + string commonData = "var __wxAppData=__wxAppData||{};var __wxAppCode__=__wxAppCode__||{};var global=global||{};var __WXML_GLOBAL__=" + "__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_init:undefined,total_ops:0};var Component=Comp" + "onent||function(){};var definePlugin=definePlugin||function(){};var requirePlugin=requirePlugin||function(){};" + "var Behavior=Behavior||function(){};var __vd_version_info__=__vd_version_info__||{};var __GWX_GLOBAL__=__GWX_G" + "LOBAL__||{};var __globalThis=(typeof __vd_version_info__!=='undefined'&&typeof __vd_version_info__.globalThis!" + "=='undefined')?__vd_version_info__.globalThis:(typeof window!=='undefined'?window:globalThis);"; + commonData += helperCode; + commonData = commonData.append(outputMap["__COMMON__"]); + + outputMap["__COMMON__"] = commonData; + } + + string dep = ";var __WXML_DEP__=__WXML_DEP__||{};"; + // TODO: 起始并不是0 + for (string j = ""; ; ) + { + /* code */ + if (j == "") break; + + if (j[11] != j[10]) { + stringstream dep; + dep << "__WXML_DEP__[\""; + dep << "\"]=["; + + for (int k = 0; k < 10; k++) + { + /* code */ + dep << "\""; + dep << "\","; + } + + dep << "];"; + } + } + // ??? + outputMap["__COMMON__"].append(""); + if (compilerResult) { + // CompileLazy出现异常 + // 标准错误输出 + fprintf(stderr, "Error %d: %s\n", 1, "123"); + } + else { + FILE *f = stdout; + if (!outputFileName.empty()) + f = fopen(outputFileName.c_str(), "w"); + // DictToJsonString + // DictToJsonString + fprintf(f, " {\"generateFunctionContent\":%s,\"generateFunctionName\":%s} ", "", ""); + fclose(f); + } + + } + else { + const char off_5403C3[] = { 's', '\0', 'e', '\0' }; + int compilerResult = 0; + // compilerResult = WXML::Compiler::Compile( + // v3, + // &v107, + // (int *)v111, + // (unsigned __int8 **)v113, + // v126, + // &v105, + // v53, + // (int *)gwxMark, + // mark, + // 10, + // off_5403C3[2], // off_5403C3[2] + // off_5403C3, // off_5403C3 + // "gg", // "gg" + // "e_", // "e_" + // "d_", // "d_" + // "p_", // "p_" + // '\0', // '\0' + // "boxofchocolate", // "boxofchocolate" + // "$gdwx", // "$gdwx" + // "f_"); // "f_" + FILE *f; + if (compilerResult) { + f = stderr; + fprintf(f, "%s\n", "error..."); + }else { + f = stdout; + if (!outputFileName.empty()) { + f = fopen(outputFileName.c_str(), "w"); + } + fprintf(f, "%s\n", "result..."); + fclose(f); + } + } return 0; } \ No newline at end of file diff --git a/src/wcc/usage.cpp b/src/wcc/usage.cpp index 204db81..1bf2847 100644 --- a/src/wcc/usage.cpp +++ b/src/wcc/usage.cpp @@ -1,7 +1,7 @@ #include //----- (00401726) -------------------------------------------------------- -int usage(int argc, const char **argv) +int usage(int argc, const char **argv) { printf("Wechat WXML Compiler, version %s\n", "v0.5vv_20200413_syb_scopedata"); printf( diff --git a/src/wxml/compiler.cpp b/src/wxml/compiler.cpp index c652fc9..046eece 100644 --- a/src/wxml/compiler.cpp +++ b/src/wxml/compiler.cpp @@ -1,9 +1,18 @@ #include "../include/wxml.h" #include "../include/define.h" +#include namespace WXML{ - void Compiler::GetVersionInfo(int a1, int *a2) { - std::ostream& result = std::cout; + + Compiler::Compiler(/* args */) + { + } + + Compiler::~Compiler() + { + } + void Compiler::GetVersionInfo(std::string &a1, std::string a2) { + std::stringstream result; result << "/*"; result << "v0.5vv_20200413_syb_scopedata"; result << "*/"; @@ -14,6 +23,7 @@ namespace WXML{ result << "';"; result << a2; result << ".__wcc_version_info__={\"customComponents\":true,\"fixZeroRpx\":true,\"propValueDeepCopy\":false};"; + result.str(a1); } void Compiler::WXMLHelperCode(std::string &result) { result.assign(aIfThisThisGUnd); diff --git a/src/wxml/dom_lib.cpp b/src/wxml/dom_lib.cpp index e69de29..d51a3ca 100644 --- a/src/wxml/dom_lib.cpp +++ b/src/wxml/dom_lib.cpp @@ -0,0 +1,14 @@ + +#include "../include/wxml.h" + +namespace WXML { + + + DOMLib::DOMLib(/* args */) + { + } + + DOMLib::~DOMLib() + { + } +} \ No newline at end of file diff --git a/src/wxml/expr_lib/tokenizer.cpp b/src/wxml/expr_lib/tokenizer.cpp index e69de29..e306d6b 100644 --- a/src/wxml/expr_lib/tokenizer.cpp +++ b/src/wxml/expr_lib/tokenizer.cpp @@ -0,0 +1,14 @@ +#include "../../include/wxml.h" + +namespace WXML { + namespace EXPRLib { + + Tokenizer::Tokenizer(/* args */) + { + } + + Tokenizer::~Tokenizer() + { + } + } +} \ No newline at end of file diff --git a/src/wxml/rewrite.cpp b/src/wxml/rewrite.cpp new file mode 100644 index 0000000..982ba99 --- /dev/null +++ b/src/wxml/rewrite.cpp @@ -0,0 +1,14 @@ + +#include "../include/wxml.h" + +namespace WXML { + + + Rewrite::Rewrite(/* args */) + { + } + + Rewrite::~Rewrite() + { + } +} \ No newline at end of file diff --git a/test/wcc.cpp b/test/wcc.cpp index c1c7840..1057f66 100644 --- a/test/wcc.cpp +++ b/test/wcc.cpp @@ -46,7 +46,7 @@ int main(int argc, const char **argv, const char **envp) int v41; // edx char v43; // [esp+1h] [ebp-38Bh] char v44; // [esp+2h] [ebp-38Ah] - char v45; // [esp+3h] [ebp-389h] + char isReadFromStdin; // [esp+3h] [ebp-389h] const char **innerArgv; // [esp+4h] [ebp-388h] int innerArgc; // [esp+8h] [ebp-384h] FILE *v48; // [esp+Ch] [ebp-380h] @@ -90,13 +90,13 @@ int main(int argc, const char **argv, const char **envp) void **v86; // [esp+68h] [ebp-324h] BYREF void **v87; // [esp+6Ch] [ebp-320h] int v88; // [esp+70h] [ebp-31Ch] - _DWORD *fileList; // [esp+74h] [ebp-318h] BYREF + _DWORD *paramList; // [esp+74h] [ebp-318h] BYREF int v90; // [esp+78h] [ebp-314h] int v91; // [esp+7Ch] [ebp-310h] void **v92; // [esp+80h] [ebp-30Ch] BYREF int v93; // [esp+84h] [ebp-308h] int v94; // [esp+88h] [ebp-304h] - char *v95; // [esp+8Ch] [ebp-300h] BYREF + char *xc_Or_completeCode_Param; // [esp+8Ch] [ebp-300h] BYREF int v96; // [esp+90h] [ebp-2FCh] char v97; // [esp+94h] [ebp-2F8h] BYREF char *configPathData; // [esp+A4h] [ebp-2E8h] BYREF @@ -144,7 +144,7 @@ int main(int argc, const char **argv, const char **envp) char *v140; // [esp+29Ch] [ebp-F0h] BYREF int v141; // [esp+2A0h] [ebp-ECh] int v142[4]; // [esp+2A4h] [ebp-E8h] BYREF - int configPathParamName; // [esp+2B4h] [ebp-D8h] BYREF + int tempData; // [esp+2B4h] [ebp-D8h] BYREF int v144; // [esp+2B8h] [ebp-D4h] char v145[4]; // [esp+2BCh] [ebp-D0h] BYREF char v146[196]; // [esp+2C0h] [ebp-CCh] BYREF @@ -154,7 +154,7 @@ int main(int argc, const char **argv, const char **envp) innerArgc = argc; innerArgv = argv; __main(); - v95 = &v97; + xc_Or_completeCode_Param = &v97; configPathData = &v100; v86 = 0; v87 = 0; @@ -163,7 +163,7 @@ int main(int argc, const char **argv, const char **envp) v97 = 0; v99 = 0; v100 = 0; - fileList = 0; + paramList = 0; v90 = 0; v91 = 0; v92 = 0; @@ -183,14 +183,14 @@ int main(int argc, const char **argv, const char **envp) v106[4] = 0; for ( argcIndex = 1; argcIndex < innerArgc; ++argcIndex ) { - std::string::basic_string((void **)&configPathParamName, "--config-path"); + std::string::basic_string((void **)&tempData, "--config-path"); currentIndex = argcIndex; currentArg = (char *)&innerArgv[argcIndex]; hasConfigParam = 0; - if ( !std::string::compare((int)&configPathParamName, *(char **)currentArg) ) + if ( !std::string::compare((int)&tempData, *(char **)currentArg) ) // 一样 hasConfigParam = argcIndex + 1 < innerArgc; - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); if ( hasConfigParam ) { // 有--config-path参数,下一个参数是路径,跳过 @@ -201,9 +201,9 @@ int main(int argc, const char **argv, const char **envp) else { // 没有--config-path参数 - std::string::basic_string((void **)&configPathParamName, *(char **)currentArg); - std::vector::emplace_back((void **)&fileList, &configPathParamName); - std::string::_M_dispose((void **)&configPathParamName); + std::string::basic_string((void **)&tempData, *(char **)currentArg); + std::vector::emplace_back((void **)¶mList, &tempData); + std::string::_M_dispose((void **)&tempData); } } @@ -217,9 +217,9 @@ int main(int argc, const char **argv, const char **envp) while ( v138 ) { std::string::basic_string((void **)&v140, "\n"); - GetNextArg((int)&configPathParamName, &v137, (int)&v140); - std::vector::emplace_back((void **)&fileList, &configPathParamName); - std::string::_M_dispose((void **)&configPathParamName); + GetNextArg((int)&tempData, &v137, (int)&v140); + std::vector::emplace_back((void **)¶mList, &tempData); + std::string::_M_dispose((void **)&tempData); std::string::_M_dispose((void **)&v140); } std::string::_M_dispose((void **)&v137); @@ -231,13 +231,13 @@ int main(int argc, const char **argv, const char **envp) v44 = 0; mark = 0; v53 = 0; - v55 = -1431655765 * ((v90 - (int)fileList) >> 3); - v45 = 0; + v55 = -1431655765 * ((v90 - (int)paramList) >> 3); + isReadFromStdin = 0; FileNamea = 0; while ( (int)Streama < v55 ) { v67 = 6 * (_DWORD)Streama; - v4 = &fileList[6 * (_DWORD)Streama]; + v4 = ¶mList[6 * (_DWORD)Streama]; v5 = (_BYTE *)*v4; // ASCII 45 => '-' if ( *(_BYTE *)*v4 != '-' /*45*/ ) @@ -274,8 +274,8 @@ int main(int argc, const char **argv, const char **envp) } if ( (int)&Streama->_ptr + 1 < v55 ) { - std::vector::push_back((int)&v86, (int)&fileList[v67 + 6]); - v45 = 1; + std::vector::push_back((int)&v86, (int)¶mList[v67 + 6]); + isReadFromStdin = 1; goto LABEL_84; } break; @@ -295,7 +295,7 @@ int main(int argc, const char **argv, const char **envp) v53 = 1; if ( *(_BYTE *)v89[v67 + 6] != '-'/*45*/ ) { - std::string::_M_assign((int)&v95, (int)&fileList[v67 + 6]); + std::string::_M_assign((int)&xc_Or_completeCode_Param, (int)¶mList[v67 + 6]); v53 = 1; Streama = (FILE *)((char *)Streama + 1); } @@ -310,7 +310,7 @@ int main(int argc, const char **argv, const char **envp) v53 = 0; if ( *(_BYTE *)v89[v67 + 6] != '-'/*45*/ ) { - std::string::_M_assign((int)&v95, (int)&fileList[v67 + 6]); + std::string::_M_assign((int)&xc_Or_completeCode_Param, (int)¶mList[v67 + 6]); v53 = 0; Streama = (FILE *)((char *)Streama + 1); } @@ -323,7 +323,7 @@ int main(int argc, const char **argv, const char **envp) v8 = (FILE *)((char *)&Streama->_ptr + 1); if ( (int)&Streama->_ptr + 1 < v55 ) { - FileNamea = (char *)fileList[v67 + 6]; + FileNamea = (char *)paramList[v67 + 6]; LABEL_72: Streama = v8; goto LABEL_84; @@ -333,7 +333,7 @@ LABEL_72: // gwxMark if ( v5[2] == 'n'/*110*/ && (int)&Streama->_ptr + 1 < v55 ) { - std::string::_M_assign((int)gwxMark, (int)&fileList[v67 + 6]); + std::string::_M_assign((int)gwxMark, (int)¶mList[v67 + 6]); v8 = (FILE *)((char *)&Streama->_ptr + 1); goto LABEL_72; } @@ -348,54 +348,56 @@ LABEL_72: mark |= 0x40u; goto LABEL_84; } - std::string::basic_string((void **)&configPathParamName, "--split"); - v51 = std::operator==((int)&fileList[v67], (int)&configPathParamName); + // switch end + + std::string::basic_string((void **)&tempData, "--split"); + v51 = std::operator==((int)¶mList[v67], (int)&tempData); // 相等 if ( v51 ) v51 = (int)&Streama->_ptr + 1 < v55; - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); if ( v51 ) { Streama = (FILE *)((char *)Streama + 1); - std::string::_M_assign((int)blankStr, (int)&fileList[v67 + 6]); + std::string::_M_assign((int)blankStr, (int)¶mList[v67 + 6]); goto LABEL_84; } - v9 = fileList[6 * (_DWORD)Streama]; + v9 = paramList[6 * (_DWORD)Streama]; if ( *(_BYTE *)(v9 + 1) == 'c'/*99*/ && *(_BYTE *)(v9 + 2) == 'b'/*98*/ ) { LOBYTE(v142[0]) = 0; v140 = (char *)v142; - v10 = (char *)fileList[v67 + 6]; + v10 = (char *)paramList[v67 + 6]; Streama = (FILE *)((char *)Streama + 1); mark |= 0x80u; v141 = 0; ReadFile(v10, (unsigned int *)&v140); if ( v141 ) { - std::string::basic_string((void **)&configPathParamName, "life_cycle_callback_content"); - v11 = std::map::operator[](&v105, &configPathParamName); + std::string::basic_string((void **)&tempData, "life_cycle_callback_content"); + v11 = std::map::operator[](&v105, &tempData); std::string::_M_assign((int)v11, (int)&v140); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); } std::string::_M_dispose((void **)&v140); } else { - if ( !std::string::compare((int)&fileList[v67], "--pm") ) + if ( !std::string::compare((int)¶mList[v67], "--pm") ) { v48 = (FILE *)((char *)&Streama->_ptr + 1); if ( (int)&Streama->_ptr + 1 < v55 ) { - Streamk = (FILE *)&fileList[v67 + 6]; - std::string::basic_string((void **)&configPathParamName, "plain_text_marker"); - v12 = std::map::operator[](&v105, &configPathParamName); + Streamk = (FILE *)¶mList[v67 + 6]; + std::string::basic_string((void **)&tempData, "plain_text_marker"); + v12 = std::map::operator[](&v105, &tempData); std::string::_M_assign((int)v12, (int)Streamk); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); v8 = v48; goto LABEL_72; } } - v49 = fileList[6 * (_DWORD)Streama]; + v49 = paramList[6 * (_DWORD)Streama]; if ( *(_BYTE *)(v49 + 1) == 'l'/*108*/ && *(_BYTE *)(v49 + 2) == 'l'/*108*/ ) { v13 = *(_BYTE *)(v49 + 3); @@ -411,11 +413,11 @@ LABEL_72: v51 = 1; } if ( !std::string::compare((int)blankStr, " ") ) - std::string::basic_string((void **)&configPathParamName, ","); + std::string::basic_string((void **)&tempData, ","); else - std::string::basic_string((char *)&configPathParamName, (int)blankStr); + std::string::basic_string((char *)&tempData, (int)blankStr); Streama = (FILE *)((char *)Streama + 1); - Split((int)&v131, &fileList[v67 + 6], (int)&configPathParamName); + Split((int)&v131, ¶mList[v67 + 6], (int)&tempData); v15 = (void **)v131; v16 = (char *)v92; v131 = 0; @@ -430,19 +432,23 @@ LABEL_72: v133 = 0; std::vector::~vector((void ***)&v140, v17); std::vector::~vector((void ***)&v131, v18); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); v43 = 1; v53 = v51; } } LABEL_84: Streama = (FILE *)((char *)Streama + 1); + } + // for end + + // 查看版本 有-v参数 if ( v44 ) { - std::string::basic_string((void **)&configPathParamName, "global"); - WXML::Compiler::GetVersionInfo((int)&v140, &configPathParamName); - std::string::_M_dispose((void **)&configPathParamName); + std::string::basic_string((void **)&tempData, "global"); + WXML::Compiler::GetVersionInfo((int)&v140, &tempData); + std::string::_M_dispose((void **)&tempData); Streamb = ___acrt_iob_func(1u); if ( FileNamea && *FileNamea ) Streamb = fopen(FileNamea, "w"); @@ -450,6 +456,8 @@ LABEL_84: fclose(Streamb); std::string::_M_dispose((void **)&v140); } + + // v86 temp if ( v86 == v87 ) { v68 = Usage(innerArgc, innerArgv); @@ -467,34 +475,39 @@ LABEL_84: v110[3] = (int)v110; v110[4] = 0; Streamc = 0; - if ( v45 ) + // v86 temp + // v107 fileData + if ( isReadFromStdin ) { - configPathParamName = (int)v145; + tempData = (int)v145; v144 = 0; v145[0] = 0; - ReadFile(0, (unsigned int *)&configPathParamName); + ReadFile(0, (unsigned int *)&tempData); v19 = std::map::operator[](&v107, (int)v86); - std::string::_M_assign((int)v19, (int)&configPathParamName); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_assign((int)v19, (int)&tempData); + std::string::_M_dispose((void **)&tempData); + // v107[v86] = tempData } else { while ( -1431655765 * (((char *)v87 - (char *)v86) >> 3) > (unsigned int)Streamc ) { v145[0] = 0; - configPathParamName = (int)v145; + tempData = (int)v145; v20 = (char *)v86[6 * (_DWORD)Streamc]; v144 = 0; - ReadFile(v20, (unsigned int *)&configPathParamName); + ReadFile(v20, (unsigned int *)&tempData); v21 = std::map::operator[](&v107, (int)&v86[6 * (_DWORD)Streamc]); - std::string::_M_assign((int)v21, (int)&configPathParamName); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_assign((int)v21, (int)&tempData); + std::string::_M_dispose((void **)&tempData); + // v107[v86[6 * (_DWORD)Streamc]] = tempData Streamc = (FILE *)((char *)Streamc + 1); } } if ( v96 ) { - GetNextArg((int)String, (int *)&v95, (int)blankStr); + GetNextArg((int)String, (int *)&xc_Or_completeCode_Param, (int)blankStr); + // char -> unsigned long long v52 = strtoull(String[0], 0, 10); std::string::_M_dispose((void **)String); v131 = 0; @@ -506,28 +519,29 @@ LABEL_84: v140 = (char *)v142; LOBYTE(v142[0]) = 0; memset(String, 0, 12); - GetNextArg((int)v135, (int *)&v95, (int)blankStr); + GetNextArg((int)v135, (int *)&xc_Or_completeCode_Param, (int)blankStr); std::string::operator=((unsigned __int8 **)&v140, (int)v135); std::string::_M_dispose(v135); - GetNextArg((int)v136, (int *)&v95, (int)blankStr); + GetNextArg((int)v136, (int *)&xc_Or_completeCode_Param, (int)blankStr); v50 = strtoull(v136[0], 0, 10); std::string::_M_dispose((void **)v136); for ( Streamd = 0; (int)Streamd < v50; Streamd = (FILE *)((char *)Streamd + 1) ) { v144 = 0; - configPathParamName = (int)v145; + tempData = (int)v145; v145[0] = 0; - GetNextArg((int)&v137, (int *)&v95, (int)blankStr); - std::string::operator=((unsigned __int8 **)&configPathParamName, (int)&v137); + GetNextArg((int)&v137, (int *)&xc_Or_completeCode_Param, (int)blankStr); + std::string::operator=((unsigned __int8 **)&tempData, (int)&v137); std::string::_M_dispose((void **)&v137); - std::vector::push_back((int)String, (int)&configPathParamName); + std::vector::push_back((int)String, (int)&tempData); v69 = v132; if ( v69 == std::find<__gnu_cxx::__normal_iterator>,std::string>( v131, v132, - (int)&configPathParamName) ) - std::vector::push_back((int)&v131, (int)&configPathParamName); - std::string::_M_dispose((void **)&configPathParamName); + (int)&tempData) ) + // v131 splitedData + std::vector::push_back((int)&v131, (int)&tempData); + std::string::_M_dispose((void **)&tempData); } Streame = (FILE *)std::_Rb_tree>,std::_Select1st>>,std::less,std::allocator>>>::lower_bound( &v109, @@ -562,10 +576,10 @@ LABEL_84: std::vector::~vector((void ***)String, v23); std::string::_M_dispose((void **)&v140); } - std::string::basic_string((void **)&configPathParamName, "ALL"); - v24 = std::map>::operator[](&v109, &configPathParamName); + std::string::basic_string((void **)&tempData, "ALL"); + v24 = std::map>::operator[](&v109, &tempData); std::vector::operator=((int)v24, &v131); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); std::vector::~vector((void ***)&v131, v25); } v111[1] = 0; @@ -579,6 +593,8 @@ LABEL_84: v118 = &v116; v119 = &v116; v120 = 0; + + // 有llx参数 if ( v43 ) { v70 = v93; @@ -586,9 +602,9 @@ LABEL_84: { if ( *Streamg->_ptr == 46 && Streamg->_ptr[1] == 47 ) { - std::string::substr(&configPathParamName, Streamg, 2u, 0xFFFFFFFF); - std::string::operator=((unsigned __int8 **)Streamg, (int)&configPathParamName); - std::string::_M_dispose((void **)&configPathParamName); + std::string::substr(&tempData, Streamg, 2u, 0xFFFFFFFF); + std::string::operator=((unsigned __int8 **)Streamg, (int)&tempData); + std::string::_M_dispose((void **)&tempData); } } v122[0] = 0; @@ -596,7 +612,7 @@ LABEL_84: v123 = v122; v124 = v122; v125 = 0; - std::string::basic_string((void **)&configPathParamName, "l_"); + std::string::basic_string((void **)&tempData, "l_"); std::string::basic_string((void **)&v140, "f_"); std::string::basic_string((void **)&v137, "$gdwx"); std::string::basic_string((void **)v136, "boxofchocolate"); @@ -623,16 +639,17 @@ LABEL_84: (int)gwxMark, mark, 10, - (int *)v127, - (int *)v128, - (int *)v129, - (int *)v130, - &v131, - (int *)String, - (int)v135, - (int)v136, - (int)&v137, - (int *)&v140); + (int *)v127, // 'e' + (int *)v128, // const char off_5403C3[] = {'s','\0','e','\0'} + (int *)v129, // "gg" + (int *)v130, // "e_" + &v131, // "d_" + (int *)String, // "p_" + (int)v135, // '\0' + (int)v136, // "boxofchocolate" + (int)&v137, // "$gdwx" + (int *)&v140 // "f_" + ); std::_Rb_tree>,std::_Select1st>>,std::less,std::allocator>>>::~_Rb_tree((int)v126); std::string::_M_dispose(v127); std::string::_M_dispose(v128); @@ -644,7 +661,7 @@ LABEL_84: std::string::_M_dispose((void **)v136); std::string::_M_dispose((void **)&v137); std::string::_M_dispose((void **)&v140); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); std::string::basic_string((void **)&v140, "__COMMON__"); v61 = v117; Streamh = &v116; @@ -682,16 +699,18 @@ LABEL_84: "var Behavior=Behavior||function(){};var __vd_version_info__=__vd_version_info__||{};var __GWX_GLOBAL__=__GWX_G" "LOBAL__||{};var __globalThis=(typeof __vd_version_info__!=='undefined'&&typeof __vd_version_info__.globalThis!" "=='undefined')?__vd_version_info__.globalThis:(typeof window!=='undefined'?window:globalThis);"); - std::operator+(&configPathParamName, &v137, (unsigned int *)&v140); + std::operator+(&tempData, &v137, (unsigned int *)&v140); std::string::basic_string((void **)v136, "__COMMON__"); v33 = (unsigned __int8 **)std::map::operator[](&v115, v136); - std::string::operator=(v33, (int)&configPathParamName); + std::string::operator=(v33, (int)&tempData); + // v115["__COMMON__"] = tempData; std::string::_M_dispose((void **)v136); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); std::string::_M_dispose((void **)&v137); } else { + // v115 outputMap std::string::basic_string((void **)&v140, "__COMMON__"); Streamm = (FILE *)std::map::operator[](&v115, &v140); WXML::Compiler::WXMLHelperCode[abi:cxx11]((void **)v136); @@ -705,18 +724,18 @@ LABEL_84: "=='undefined')?__vd_version_info__.globalThis:(typeof window!=='undefined'?window:globalThis);"); std::operator+(&v137, v135, (unsigned int *)v136); v31 = std::string::append(&v137, (int)Streamm); - std::string::basic_string(&configPathParamName, v31); + std::string::basic_string(&tempData, v31); std::string::basic_string((void **)String, "__COMMON__"); v32 = (unsigned __int8 **)std::map::operator[](&v115, String); - std::string::operator=(v32, (int)&configPathParamName); + std::string::operator=(v32, (int)&tempData); std::string::_M_dispose((void **)String); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); std::string::_M_dispose((void **)&v137); std::string::_M_dispose(v135); std::string::_M_dispose((void **)v136); } std::string::_M_dispose((void **)&v140); - std::basic_stringstream,std::allocator>::basic_stringstream((int)&configPathParamName); + std::basic_stringstream,std::allocator>::basic_stringstream((int)&tempData); std::operator<<>((std::ostream::sentry *)v145, ";var __WXML_DEP__=__WXML_DEP__||{};"); for ( j = v123; ; j = (int *)std::_Rb_tree_increment((int)Streami) ) { @@ -768,12 +787,12 @@ LABEL_84: std::string::_M_dispose((void **)&v137); std::string::_M_dispose((void **)v136); } - std::basic_stringstream,std::allocator>::~basic_stringstream((int)&configPathParamName); + std::basic_stringstream,std::allocator>::~basic_stringstream((int)&tempData); std::_Rb_tree>,std::_Select1st>>,std::less,std::allocator>>>::~_Rb_tree((int)&v121); } else { - std::string::basic_string((void **)&configPathParamName, "l_"); + std::string::basic_string((void **)&tempData, "l_"); std::string::basic_string((void **)&v140, "f_"); std::string::basic_string((void **)&v137, "$gdwx"); std::string::basic_string((void **)v136, "boxofchocolate"); @@ -782,7 +801,7 @@ LABEL_84: std::string::basic_string((void **)&v131, "d_"); std::string::basic_string(v130, "e_"); std::string::basic_string(v129, "gg"); - std::string::basic_string(v128, (char *)off_5403C3); + std::string::basic_string(v128, (char *)off_5403C3); // const char off_5403C3[] = { 's', '\0', 'e', '\0' }; std::string::basic_string(v127, (char *)&off_5403C3[2]); std::_Rb_tree>,std::_Select1st>>,std::less,std::allocator>>>::_Rb_tree( v126, @@ -798,16 +817,16 @@ LABEL_84: (int *)gwxMark, mark, 10, - (int *)v127, - (int *)v128, - (int *)v129, - (int *)v130, - &v131, - (int *)String, - (int)v135, - (int)v136, - (int)&v137, - (int *)&v140); + (int *)v127, // off_5403C3[2] + (int *)v128, // off_5403C3 + (int *)v129, // "gg" + (int *)v130, // "e_" + &v131, // "d_" + (int *)String, // "p_" + (int)v135, // '\0' + (int)v136, // "boxofchocolate" + (int)&v137, // "$gdwx" + (int *)&v140); // "f_" std::_Rb_tree>,std::_Select1st>>,std::less,std::allocator>>>::~_Rb_tree((int)v126); std::string::_M_dispose(v127); std::string::_M_dispose(v128); @@ -819,7 +838,7 @@ LABEL_84: std::string::_M_dispose((void **)v136); std::string::_M_dispose((void **)&v137); std::string::_M_dispose((void **)&v140); - std::string::_M_dispose((void **)&configPathParamName); + std::string::_M_dispose((void **)&tempData); if ( v68 ) { Streaml = (FILE *)v111[0]; @@ -849,7 +868,7 @@ LABEL_153: std::vector::~vector(&v92, v39); std::vector::~vector((void ***)&v89, v40); std::string::_M_dispose((void **)&configPathData); - std::string::_M_dispose((void **)&v95); + std::string::_M_dispose((void **)&xc_Or_completeCode_Param); std::vector::~vector(&v86, v41); return v68; } \ No newline at end of file