feat: 复现一堆函数类

This commit is contained in:
msojocs 2023-06-11 11:26:22 +08:00
parent 396b2d11ad
commit 3a5c0992bc
23 changed files with 2740 additions and 212 deletions

26
.vscode/settings.json vendored
View File

@ -45,12 +45,32 @@
"streambuf": "cpp",
"typeinfo": "cpp",
"cstring": "cpp",
"map": "cpp"
"map": "cpp",
"set": "cpp"
},
"cmake.debugConfig": {
"cwd": "/mnt/d/Work/WeChatProjects/miniprogram-demo/miniprogram",
"args": [
"-llw",
"111,222"
"\"-d\"",
"\"--split\"",
"\">_<109\"",
"\"-xc\"",
"\"9>_<109./miniprogram_npm/miniprogram-barrage/index.wxml>_<1090>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<1090>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<1090>_<109./miniprogram_npm/wxml-to-canvas/index.wxml>_<1090>_<109./page/API/index.wxml>_<1091>_<109set-tab-bar>_<109./page/API/components/set-tab-bar/set-tab-bar.wxml>_<1090>_<109./page/cloud/index.wxml>_<1090>_<109./page/component/index.wxml>_<1090>_<109./page/extend/index.wxml>_<1090\"",
"\"-lla\"",
"\"./miniprogram_npm/miniprogram-barrage/index>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<109./miniprogram_npm/wxml-to-canvas/index>_<109./page/API/index>_<109./page/API/components/set-tab-bar/set-tab-bar>_<109./page/cloud/index>_<109./page/component/index>_<109./page/extend/index\"",
"\"./miniprogram_npm/miniprogram-barrage/index.wxml\"",
"\"./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml\"",
"\"./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml\"",
"\"./miniprogram_npm/wxml-to-canvas/index.wxml\"",
"\"./page/API/index.wxml\"",
"\"./page/API/components/set-tab-bar/set-tab-bar.wxml\"",
"\"./page/cloud/index.wxml\"",
"\"./page/common/foot.wxml\"",
"\"./page/common/head.wxml\"",
"\"./page/component/index.wxml\"",
"\"./page/extend/index.wxml\"",
"\"-gn\"",
"\"\\$gwx1\""
]
}
}

View File

@ -14,6 +14,15 @@ add_executable(wcc
add_executable(wcsc
src/wcsc.cpp
)
add_executable(
resolve_path
test/resolve_path.cpp
src/wxml/dom_lib/common.cpp
)
add_test(
resolve_test
resolve_path
)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})

View File

@ -4,6 +4,6 @@
#include <vector>
std::string& trim(std::string &s);
void split(std::vector<std::string> result, std::string source, std::string mark);
void split(std::vector<std::string> &result, std::string source, std::string mark);
#endif

View File

@ -6,27 +6,171 @@
#include <map>
#include <vector>
namespace WXML{
class Compiler
namespace WXML
{
namespace DOMLib
{
private:
/* data */
public:
Compiler(/* args */);
~Compiler();
/**
* int
*/
bool AttrsCompartor(int a1, int a2);
/**
*
*/
std::string joinString(std::vector<std::string>& str, char split);
std::vector<std::string> splitString(std::string const& str, char split);
std::string resolvePath(std::string const&, std::string const&);
class WXMLDom
{
private:
/* data */
public:
WXMLDom(/* args */);
~WXMLDom();
void Error();
};
class Token
{
private:
/* data */
std::string str1;
std::string str2;
std::string str3;
public:
Token(/* args */);
Token(WXML::DOMLib::Token&&);
Token(WXML::DOMLib::Token const&);
std::string ToString();
int ToAttrContent();
bool IsValidVariableName(std::string const&);
bool IsMatch(char const&);
bool GetTemplateContent(std::string const&, std::string&);
~Token();
};
static std::string CompileLazy(
class Parser
{
private:
/* data */
public:
Parser(/* args */);
~Parser();
void Match();
/**
* wxml tag
* view |
*/
bool IsValidTag(std::string &);
WXML::DOMLib::Token Peek();
bool Parse(char const*fileContent, // Str
std::string &, // a4
std::string const&, // a5
std::vector<WXML::DOMLib::Token> & // a6
);
int Error(char const*, WXML::DOMLib::Token &);
std::string GetParsed();
std::string DOM();
std::string DOMS();
std::vector<std::string> ATTR_LIST();
std::string ATTR();
};
};
namespace Compiler
{
int CompileLazy(
std::map<std::string,std::string> const& fileContent,
std::string& errorMessage, // 错误信息
std::map<std::string,std::string>& outputMap, // 输出1
std::map<std::string,std::string>& dict, // 输出2
std::map<std::string, std::vector<std::string>>,
std::map<std::string, std::vector<std::string>>, // vecFileContentMap
std::vector<std::string> const&, // splitedData
std::map<std::string,std::string> const&, // mapData1
bool, // isLLA
std::string const&, // gwxMark
uint, // mark
char, // '\n'
std::string const&, // 'e'
std::string const&, // const char off_5403C3[] = {'s','\0','e','\0'}
std::string const&, // "gg"
std::string const&, // "e_"
std::string const&, // "d_"
std::string const&, // "p_"
std::string const&, // '\0'
std::string const&, // "boxofchocolate"
std::string const&, // "$gdwx"
std::string const& // "f_"
);
std::string Compile(
std::map<std::string,std::string> const&,
std::string&,
std::map<std::string,std::string>&,
std::map<std::string,std::string>&,
std::map<std::string, std::vector<std::string>, std::less<std::string>, std::allocator<std::pair<const std::string, std::vector<std::string>>>>,
std::map<std::string, std::vector<std::string>>,
std::allocator<std::pair<const std::string, std::string>>,
std::allocator<std::string> const&,
std::string const&,
std::map<std::string,std::string> const&,
bool,
std::string const& gwxMark,
uint mark,
char lineEndMark,
std::string const&,
std::string const& ,
std::string const& ggMark,
std::string const& eMark,
std::string const& dMark,
std::string const& pMark,
std::string const& endMark,
std::string const& boxMark,
std::string const& gdwxMark,
std::string const& fMark);
int DealWxsTag(
std::string const&,
std::string &,
std::string&,
std::string&,
std::string&,
int &,
std::string&
);
// void GetFuncId();
void GetVersionInfo(std::string &a1, std::string a2);
int ParseSource(
std::string const& content, // 源码?
std::string const& fileName, // 文件名?
std::string const& , //
char lineEndMark, // '\n'
std::string const& gwxMark, // gwxMark
std::string & fMark, // "f_"
std::map<std::string,std::string> const&, // fileData
std::string&, // 错误信息
std::map<std::string, WXML::DOMLib::WXMLDom>,// map<string, ?>
std::map<std::string,std::string>&,// ???
std::map<std::string,int>, // ???
bool, // mark指定运算结果是否非0
bool); // mark指定运算结果是否非0
int RenderDefine(
WXML::DOMLib::WXMLDom &,
std::string const&,
std::map<std::string,std::string> &,
std::string&,
std::stringstream &,
std::map<std::string,std::string> const&,
bool,
uint,
char,
std::string const&,
@ -39,26 +183,11 @@ namespace WXML{
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);
std::string const&
);
void WXMLHelperCode(std::string &result);
};
class DOMLib
{
private:
/* data */
const char *szWXIFControlAttrs[4] = { "wx-if", "wx:if", "wx:elif", "wx:else" }; // weak
public:
DOMLib(/* args */);
~DOMLib();
};
class Rewrite
{
@ -67,7 +196,7 @@ namespace WXML{
public:
Rewrite(/* args */);
~Rewrite();
};
@ -81,6 +210,26 @@ namespace WXML{
Tokenizer(/* args */);
~Tokenizer();
};
class ExprSyntaxTree
{
private:
/* data */
public:
ExprSyntaxTree(/* args */);
~ExprSyntaxTree();
};
class Token
{
private:
/* data */
public:
Token(/* args */);
~Token();
static const char * GetTokenName(const char **a1);
};
} // namespace EXPRLib

View File

@ -42,10 +42,10 @@ int readFile (const char* fileName, std::string &result) {
*
* @param line
* @param data
* @param lineEndMark \n
* @param splitdMark
*/
std::string getNextArg(std::string &data, std::string const & lineEndMark) {
int pos = data.find(lineEndMark, 0);
std::string getNextArg(std::string &data, std::string const & splitMark) {
int pos = data.find(splitMark, 0);
std::string lineData;
if (pos == -1) {
lineData.assign(data);
@ -53,7 +53,7 @@ std::string getNextArg(std::string &data, std::string const & lineEndMark) {
}
else {
lineData = data.substr(0, pos);
data = data.substr(pos);
data = data.substr(pos + splitMark.length());
}
trim(lineData);
return lineData;

View File

@ -13,16 +13,16 @@ std::string& trim(std::string &s)
}
void split(std::vector<std::string> result, std::string source, std::string mark) {
void split(std::vector<std::string> &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);
std::string ele = source.substr(currentPos, i - currentPos);
trim(ele);
result.emplace_back(ele);
if (i == -1)
break;
currentPos = i + 1;
currentPos = i + mark.length();
}
}

View File

@ -2,6 +2,7 @@
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include "include/file.h"
#include "include/usage.h"
#include "include/string_utils.h"
@ -11,8 +12,6 @@ using namespace std;
int main(int argc, const char **argv) {
printf("argc: %d\n", argc);
string gwxMark = "$gwx";
string splitMarkStr = " ";
bool hasConfigParam = false;
@ -20,6 +19,7 @@ int main(int argc, const char **argv) {
vector<string> paramList;
string configData;
// 第一个参数是程序路径,忽略
for (int i = 1; i < argc; i++)
{
@ -50,19 +50,21 @@ int main(int argc, const char **argv) {
bool version = false;
bool hasXCParam = false;
bool hasCompleteCodeParam = false;
bool isLLA = false;
bool hasLL = false;
string xc_Or_completeCode_Param;
string outputFileName;
vector<string> temp;
vector<string> fileList;
vector<string> splitedData;
map<string, string> mapData1;
map<string, string> fileData;
map<string, string> fileContentMap;
map<string, vector<string>> vecFileContentMap;
for (int i = 0; i < paramList.size(); i++)
{
string param = paramList[i];
if (param[0] != '-') {
// 不是参数名,跳过
temp.push_back(param);
fileList.push_back(param);
continue;
}
@ -89,8 +91,9 @@ int main(int argc, const char **argv) {
continue;
}
if (i + 1 < paramList.size()) {
temp.push_back(paramList[i + 1]);
fileList.push_back(paramList[i + 1]);
isReadFromStdin = true;
continue;
}
break;
case 'v':
@ -100,11 +103,12 @@ int main(int argc, const char **argv) {
mark |= 0x10u;
else
version = true;
continue;
break;
case 'x':
// -xc output simplified code for custom component
/* code */
if(param[2] == 'c' && i < paramList.size()) {
if(param[2] == 'c' && i + 1 < paramList.size()) {
hasXCParam = true;
if(paramList[i + 1][0] != '-') {
xc_Or_completeCode_Param.assign(paramList[i + 1]);
@ -132,6 +136,7 @@ int main(int argc, const char **argv) {
if (i + 1 < paramList.size()) {
outputFileName = paramList[i + 1];
i++;
continue;
}
break;
case 'g':
@ -140,22 +145,26 @@ int main(int argc, const char **argv) {
if (param[2] == 'n' && i + 1 < paramList.size()) {
gwxMark.assign(paramList[i + 1]);
i++;
continue;
}
break;
case 'p':
/* code */
mark |= 0x20u;
continue;
break;
case 't':
/* code */
mark |= 1u;
continue;
break;
case 'i':
/* code */
mark |= 0x40u;
continue;
break;
default:
@ -197,6 +206,7 @@ int main(int argc, const char **argv) {
printf("Error: expected -llw or -lla, but got %s\n", param.c_str());
return -1;
}
isLLA = true;
}
string splitMark;
if (!splitMarkStr.compare(" ")) {
@ -206,7 +216,9 @@ int main(int argc, const char **argv) {
// 不是空格
splitMark = splitMarkStr;
}
// 分割 -llw -lla 接下来的一个参数
split(splitedData, paramList[i + 1], splitMark);
i++;
hasLL = true;
}
}
@ -223,7 +235,7 @@ int main(int argc, const char **argv) {
}
}
if (temp.empty()) {
if (fileList.empty()) {
usage(argc, argv);
return 0;
}
@ -231,69 +243,84 @@ int main(int argc, const char **argv) {
if (isReadFromStdin) {
string content;
readFile(0, content);
fileData[temp[0]] = content;
fileContentMap[fileList[0]] = content;
}
else {
// 读取文件内容
for (int i = 0; i < temp.size(); i++)
for (int i = 0; i < fileList.size(); i++)
{
string content;
readFile(temp[i].c_str(), content);
fileData[temp[i]] = content;
readFile(fileList[i].c_str(), content);
fileContentMap[fileList[i]] = content;
}
}
if (true) {
// 此if条件x64dbg得出
if (!xc_Or_completeCode_Param.empty())
{
string data;
string arg2;
vector<string> list;
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);
string arg1 = getNextArg(xc_Or_completeCode_Param, splitMarkStr);
data = getNextArg(xc_Or_completeCode_Param, splitMarkStr);
unsigned long long jCount = strtoull(&data[0], 0, 10);
vector<string> list;
for (unsigned long long i = 0; i < jCount; i++)
{
string data2 = getNextArg(xc_Or_completeCode_Param, splitMarkStr);
list.push_back(data2);
vector<string>::iterator it = find(splitedData.begin(), splitedData.end(), data2);
if (it == splitedData.end()) {
splitedData.push_back(data2);
arg2 = getNextArg(xc_Or_completeCode_Param, splitMarkStr);
list.push_back(arg2);
auto it = vecFileContentMap.find(arg2);
if (it == vecFileContentMap.end())
{
list.push_back(arg2);
}
}
auto fileContent = fileData.lower_bound(data1);
if (fileContent == fileData.end()) {
// fileData.ins(data1, 5)
// TODO: 还有问题
auto it = vecFileContentMap.lower_bound(arg1);
if (it == vecFileContentMap.end() || arg1 < it->first)
{
vector<string> d;
vecFileContentMap.emplace(arg1, d);
}
//TODO...
}
vecFileContentMap["ALL"] = list;
}
//
if (hasLL) {
for (int i = 0; i < 999; i++)
if (hasLL)
{
// 处理文件路径
for (int i = 0; i < splitedData.size(); i++)
{
/* code */
string path = splitedData[i];
if (path[0] == '.' && path[1] == '/')
{
// 以"./"开头,去掉前两个字符
splitedData[i] = path.substr(2);
}
}
map<string, string> outputMap;
const char off_5403C3[] = {'s','\0','e','\0'};
int compilerResult = 0;
string errorMessage;
// compilerResult = WXML::Compiler::CompileLazy(
// &v107,
// (int *)v111,
// fileContentMap,
// errorMessage,
// outputMap,
// &v101,
// &v121,
// v126,
// (int *)&v92,
// &v105,
// v53,
// (int)gwxMark,
// vecFileContentMap, // vecFileContentMap
// splitedData,
// mapData1,
// isLLA,
// gwxMark,
// mark,
// 10,
// &off_5403C3[2],
@ -309,7 +336,8 @@ int main(int argc, const char **argv) {
// while()
// if()
if (1) {
if (1)
{
string helperCode;
WXML::Compiler::WXMLHelperCode(helperCode);
string data = "var __wxAppData=__wxAppData||{};var __wxAppCode__=__wxAppCode__||{};var global=global||{};var __WXML_GLOBAL__="
@ -321,7 +349,8 @@ int main(int argc, const char **argv) {
data = data + helperCode;
outputMap["__COMMON__"] = data;
}
else {
else
{
string helperCode;
WXML::Compiler::WXMLHelperCode(helperCode);
string commonData = "var __wxAppData=__wxAppData||{};var __wxAppCode__=__wxAppCode__||{};var global=global||{};var __WXML_GLOBAL__="
@ -343,7 +372,8 @@ int main(int argc, const char **argv) {
/* code */
if (j == "") break;
if (j[11] != j[10]) {
if (j[11] != j[10])
{
stringstream dep;
dep << "__WXML_DEP__[\"";
dep << "\"]=[";
@ -389,7 +419,7 @@ int main(int argc, const char **argv) {
// v53,
// (int *)gwxMark,
// mark,
// 10,
// '\n',
// off_5403C3[2], // off_5403C3[2]
// off_5403C3, // off_5403C3
// "gg", // "gg"

View File

@ -4,28 +4,281 @@
namespace WXML{
Compiler::Compiler(/* args */)
namespace Compiler
{
}
int CompileLazy(
std::map<std::string,std::string> const& fileContentMap,
std::string& errorMessage, // 错误信息
std::map<std::string,std::string>& outputMap, // 输出
std::map<std::string,std::string>& dict, // 输出
std::map<std::string, std::vector<std::string>>,
std::map<std::string, std::vector<std::string>>, // vecFileContentMap
std::vector<std::string> const&, // splitedData
std::map<std::string,std::string> const&, // mapData1
bool, // 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&, // "gg"
std::string const&, // "e_"
std::string const&, // "d_"
std::string const&, // "p_"
std::string const& strEndMark, // '\0'
std::string const& boxMark, // "boxofchocolate"
std::string const& gdwxMark, // "$gdwx"
std::string const& fMark // "f_"
)
{
for (auto it = fileContentMap.begin(); it != fileContentMap.end(); it++)
{
/* code */
int parseResult = 0;
// parseResult = WXML::Compiler::ParseSource(
// it->second, // 源码?
// it->first, // 文件名
// "\n",//
// lineEndMark, // '\n'
// gwxMark, // gwxMark
// fMark, // "f_"
// fileContentMap, // fileContentMap
// errorMessage, // 错误信息
// &v304, // map<string, ?>
// &v309, // ???
// &v311, // ???
// (mark & 4) != 0, // a11 -> mark
// (mark & 0x20) != 0);
if (parseResult) {
return parseResult;
}
}
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 = "<fak";
data = data.append(sub);
data = data.append("/>");
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);
return 0;
}
Compiler::~Compiler()
{
}
void Compiler::GetVersionInfo(std::string &a1, std::string a2) {
std::stringstream result;
result << "/*";
result << "v0.5vv_20200413_syb_scopedata";
result << "*/";
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);
}
void Compiler::WXMLHelperCode(std::string &result) {
result.assign(aIfThisThisGUnd);
}
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 ParseSource(
std::string const& content, // 源码?
std::string const& fileName, // 文件名?
char lineEndMark, // '\n'
std::string const& gwxMark, // gwxMark
std::string& fMark, // "f_"
std::map<std::string,std::string> const&, // fileContentMap
std::string& errorMessage, // 错误信息
std::map<std::string,WXML::DOMLib::WXMLDom> result,// map<string, ?>
std::map<std::string,std::string>& map1,// ???
std::map<std::string,int> map2, // ???
bool b1, // mark指定运算结果是否非0
bool b2) // mark指定运算结果是否非0
{
bool isWxml = fileName.substr(fileName.length() - 5) == ".wxml";
if (isWxml)
{
// parse
int parseResult = 0;
if (parseResult)
return parseResult;
if (!parseResult)
{
// GetParsed
// result[fileName] = ""
int a;
int b;
std::stringstream ss;
if (a != b)
{
ss << "f_['";
// ss << ToStringCode(fileName);
ss << "']={};";
ss << lineEndMark;
}
for (int i = 0; i < 99; i++)
{
/* code */
int dealResult = 0;
std::string t;
// dealResult = DealWxsTag(fileName, , t);
if (dealResult)
{
// 非0
return dealResult;
}
ss << fMark;
ss << "['";
//ss << ToStringCode(fileName);
ss << "']['";
//ss << ToStringCode(t);
ss << "'] =";
int r = 1;
if (r)
{
std::string ret;
// PathCombine(fileName, ??, ret);
if (ret[0] == '/')
{
ret = '.' + ret;
}
if (/*??? && */ (gwxMark == "$gwx" || b2))
{
std::stringstream errs;
errs << fileName;
errs << ":";
// errs << v65; // 行号?
errs << ":";
// errs << v66[28 * i + 3];
errs << ":";
// errs << v76; // 文件的某种路径
errs << " not found from ";
errs << fileName;
errorMessage = errs.str();
// 清空
errs.clear();
return 1;
}
ss << "f_['";
// ss << ToStringCode(v81);
ss << "'] || ";
ss << "nv_require(\"";
// ss << ToStringCode("p_" + v81);
ss << "\");";
ss << lineEndMark;
ss << fMark;
ss << "['";
// ss << ToStringCode(fileName);
ss << "']['";
// ss << ToStringCode(v74);
ss << "']();";
ss << lineEndMark;
}
else
{
std::string data = "m_" + fileName;
data = data.append(":");
data = data.append(t);
// GetFuncId
// compile_ns
int compilerResult = 1;
if (compilerResult)
{
return compilerResult;
}
ss << "nv_require(\"";
std::string m = "m_" + fileName;
m = m.append(":");
// m = m.append(v74);
// ss << ToStringCode(m);
ss << "\");";
ss << lineEndMark;
// ss << v72;
ss << lineEndMark;
}
}
std::string code = ss.str();
if (1)
{
map1[fileName].assign(code);
}
}
}
else if(fileName.substr(fileName.length() - 4) == ".wxs")
{
std::string p = "p_" + fileName;
// GetFuncId(map2)
// compile_ns
int compilerResultCode = 0;
if (compilerResultCode) {
errorMessage.assign("error...");
return compilerResultCode;
}
else
{
std::stringstream code;
code << "f_['";
// code << ToStringCode(fileName);
code << "'] = nv_require(";
code << '"';
// code << ToStringCode("p_" + fileName);
code << "\");";
code << lineEndMark;
// code << compileResultData;
code << lineEndMark;
std::string strCode = code.str();
map1[fileName] = strCode;
}
}
return 0;
}
void WXMLHelperCode(std::string &result)
{
result.assign(aIfThisThisGUnd);
}
} // namespace Compiler
}

View File

@ -1,14 +0,0 @@
#include "../include/wxml.h"
namespace WXML {
DOMLib::DOMLib(/* args */)
{
}
DOMLib::~DOMLib()
{
}
}

View File

@ -0,0 +1,78 @@
#include "../../include/wxml.h"
namespace WXML
{
namespace DOMLib
{
bool AttrsCompartor(int a1, int a2)
{
return a1 < a2;
}
std::string joinString(std::vector<std::string>& data, char split)
{
std::stringstream ss;
for (int i = 0; i < data.size(); i++)
{
ss << data[i];
if (i != data.size() - 1)
ss << split;
}
return ss.str();
}
std::vector<std::string> splitString(std::string const& str, char split)
{
int pos = 0;
std::vector<std::string> result;
for (int i = str.find(split, pos); i != -1; i = str.find(split, pos))
{
auto sub = str.substr(pos, i - pos);
result.emplace_back(sub);
pos = i + 1;
}
result.emplace_back(str.substr(pos));
return result;
}
std::string resolvePath(std::string const& path1, std::string const& path2)
{
std::string result;
if (path2[0] != '/')
{
auto p1Split = splitString(path1, '/');
auto p2Split = splitString(path2, '/');
// 把文件名pop出去
p1Split.pop_back();
for (int i = 0; i < p2Split.size(); i++)
{
if (p2Split[i] == "..")
{
p1Split.pop_back();
}else if(p2Split[i] != "\0" && p2Split[i] != ".")
{
p1Split.push_back(p2Split[i]);
}
}
result = joinString(p1Split, '/');
}
if (path1[0] == '.' && path2[0] == '/')
{
result = "." + path2;
}
if (
// v5 <= 4 ||
result.substr(result.size() - 5) != ".wxml"
)
{
result.append(".wxml");
}
return result;
}
}
}

View File

@ -0,0 +1,19 @@
#include "../../include/wxml.h"
namespace WXML
{
namespace EXPRLib
{
ExprSyntaxTree::ExprSyntaxTree(/* args */)
{
}
ExprSyntaxTree::~ExprSyntaxTree()
{
}
}
}

View File

@ -0,0 +1,24 @@
#include "../../include/wxml.h"
#include <cstring>
namespace WXML
{
namespace DOMLib
{
const char *szWXIFControlAttrs[4] = { "wx-if", "wx:if", "wx:elif", "wx:else" }; // weak
Parser::Parser(/* args */)
{
}
Parser::~Parser()
{
}
bool Parser::IsValidTag(std::string & tag)
{
return tag.compare("wx-") != 0;
}
}
}

View File

View File

@ -0,0 +1,27 @@
#include "../../include/wxml.h"
namespace WXML
{
namespace DOMLib
{
Token::Token(/* args */)
{
}
Token::Token(WXML::DOMLib::Token&& token)
{
}
Token::~Token()
{
}
bool IsMatch(char const&)
{
return true;
}
}
}

View File

@ -0,0 +1,18 @@
#include "../../include/wxml.h"
namespace WXML {
namespace DOMLib
{
WXMLDom::WXMLDom(/* args */)
{
}
WXMLDom::~WXMLDom()
{
}
}
}

View File

@ -0,0 +1,45 @@
#include "../../include/wxml.h"
namespace WXML
{
namespace EXPRLib
{
Token::Token(/* args */)
{
}
Token::~Token()
{
}
const char * Token::GetTokenName(const char **a1)
{
const char *result; // eax
result = *a1;
switch ( (unsigned int)*a1 )
{
case 0u:
result = (const char *)(a1 + 1);
break;
case 1u:
result = "$DECIMAL";
break;
case 2u:
result = "$STRING";
break;
case 3u:
result = "$VAR";
break;
case 4u:
result = "$KEYWORD";
break;
default:
return result;
}
return result;
}
}
}

4
test/cmd.txt Normal file
View File

@ -0,0 +1,4 @@
"-d" "--split" ">_<109" "-xc" "9>_<109./miniprogram_npm/miniprogram-barrage/index.wxml>_<1090>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml>_<1090>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml>_<1090>_<109./miniprogram_npm/wxml-to-canvas/index.wxml>_<1090>_<109./page/API/index.wxml>_<1091>_<109set-tab-bar>_<109./page/API/components/set-tab-bar/set-tab-bar.wxml>_<1090>_<109./page/cloud/index.wxml>_<1090>_<109./page/component/index.wxml>_<1090>_<109./page/extend/index.wxml>_<1090" "-lla" "./miniprogram_npm/miniprogram-barrage/index>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-item>_<109./miniprogram_npm/miniprogram-recycle-view/recycle-view>_<109./miniprogram_npm/wxml-to-canvas/index>_<109./page/API/index>_<109./page/API/components/set-tab-bar/set-tab-bar>_<109./page/cloud/index>_<109./page/component/index>_<109./page/extend/index" "./miniprogram_npm/miniprogram-barrage/index.wxml" "./miniprogram_npm/miniprogram-recycle-view/recycle-item.wxml" "./miniprogram_npm/miniprogram-recycle-view/recycle-view.wxml" "./miniprogram_npm/wxml-to-canvas/index.wxml" "./page/API/index.wxml" "./page/API/components/set-tab-bar/set-tab-bar.wxml" "./page/cloud/index.wxml" "./page/common/foot.wxml" "./page/common/head.wxml" "./page/component/index.wxml" "./page/extend/index.wxml" "-gn" "$gwx"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,421 @@
//----- (00405522) --------------------------------------------------------
struct _Unwind_Exception *__usercall WXML::Compiler::ParseSource@<eax>(
WXML::DOMLib::Parser *a1@<edi>,
int *a2, // 文件名
char **a3,
char a4, // '\n'
int a5, // gwxMark
int *a6, // "f_"
_DWORD *a7, // fileData
int *a8, // 错误信息
_DWORD *a9, // map<string, ?>
_DWORD *a10,// ???
_DWORD *a11,// ???
int a12, // bool
char a13) // bool
{
char *v13; // eax
std::ostream::sentry *v14; // eax
std::ostream::sentry *v15; // eax
std::ostream::sentry *v16; // eax
std::ostream::sentry *v17; // eax
std::ostream::sentry *v18; // eax
std::ostream::sentry *v19; // eax
std::ostream::sentry *v20; // eax
std::ostream::sentry *v21; // eax
std::ostream::sentry *v22; // eax
std::ostream::sentry *v23; // eax
std::ostream::sentry *v24; // eax
std::ostream::sentry *v25; // eax
std::ostream::sentry *v26; // eax
std::ostream::sentry *v27; // eax
std::ostream::sentry *v28; // eax
std::ostream::sentry *v29; // eax
std::ostream::sentry *v30; // eax
std::ostream::sentry *v31; // eax
void **v32; // ecx
_DWORD *v33; // eax
_DWORD *v34; // eax
_DWORD *v35; // eax
_DWORD *v36; // eax
std::ostream::sentry *v37; // eax
std::ostream::sentry *v38; // eax
std::ostream::sentry *v39; // eax
char *v40; // eax
std::ostream::sentry *v41; // eax
std::ostream::sentry *v42; // eax
std::ostream::sentry *v43; // eax
std::ostream::sentry *v44; // eax
std::ostream::sentry *v45; // eax
std::ostream::sentry *v46; // eax
char *v47; // eax
WXML::DOMLib::Parser *v49; // [esp+0h] [ebp-478h]
unsigned int i; // [esp+2Ch] [ebp-44Ch]
std::ostream::sentry *v51; // [esp+30h] [ebp-448h]
bool v52; // [esp+30h] [ebp-448h]
std::ostream::sentry *v53; // [esp+30h] [ebp-448h]
std::ostream::sentry *v54; // [esp+30h] [ebp-448h]
int v55; // [esp+34h] [ebp-444h]
std::ostream::sentry *v56; // [esp+34h] [ebp-444h]
std::ostream::sentry *v57; // [esp+34h] [ebp-444h]
std::ostream::sentry *v58; // [esp+34h] [ebp-444h]
std::ostream::sentry *v59; // [esp+34h] [ebp-444h]
std::ostream::sentry *v60; // [esp+34h] [ebp-444h]
std::ostream::sentry *v61; // [esp+34h] [ebp-444h]
std::ostream::sentry *v62; // [esp+34h] [ebp-444h]
bool lpuexcpta; // [esp+38h] [ebp-440h]
struct _Unwind_Exception *lpuexcpt; // [esp+38h] [ebp-440h]
int v65; // [esp+70h] [ebp-408h] BYREF
int **v66; // [esp+74h] [ebp-404h] BYREF
int **v67; // [esp+78h] [ebp-400h]
int v68; // [esp+7Ch] [ebp-3FCh]
char *v69; // [esp+80h] [ebp-3F8h] BYREF
int v70; // [esp+84h] [ebp-3F4h]
char v71; // [esp+88h] [ebp-3F0h] BYREF
int v72[2]; // [esp+98h] [ebp-3E0h] BYREF
char v73; // [esp+A0h] [ebp-3D8h] BYREF
void *v74[2]; // [esp+B0h] [ebp-3C8h] BYREF
char v75; // [esp+B8h] [ebp-3C0h] BYREF
int v76; // [esp+C8h] [ebp-3B0h] BYREF
int v77; // [esp+CCh] [ebp-3ACh]
char v78; // [esp+D0h] [ebp-3A8h] BYREF
void *v79[2]; // [esp+E0h] [ebp-398h] BYREF
char v80; // [esp+E8h] [ebp-390h] BYREF
int v81[2]; // [esp+F8h] [ebp-380h] BYREF
char v82; // [esp+100h] [ebp-378h] BYREF
void *v83[6]; // [esp+110h] [ebp-368h] BYREF
int v84[2]; // [esp+128h] [ebp-350h] BYREF
char v85; // [esp+130h] [ebp-348h] BYREF
int v86[6]; // [esp+140h] [ebp-338h] BYREF
int v87[6]; // [esp+158h] [ebp-320h] BYREF
int v88[2]; // [esp+170h] [ebp-308h] BYREF
char v89[4]; // [esp+178h] [ebp-300h] BYREF
char v90[196]; // [esp+17Ch] [ebp-2FCh] BYREF
int v91; // [esp+240h] [ebp-238h] BYREF
volatile signed __int32 *v92; // [esp+244h] [ebp-234h] BYREF
char v93[4]; // [esp+248h] [ebp-230h] BYREF
char v94[196]; // [esp+24Ch] [ebp-22Ch] BYREF
int v95[2]; // [esp+310h] [ebp-168h] BYREF
char v96[4]; // [esp+318h] [ebp-160h] BYREF
char v97[348]; // [esp+31Ch] [ebp-15Ch] BYREF
// copy from param
WXML::DOMLib::Parser *a1@<edi>,
int *a2, // 文件名
char **a3,
char a4, // '\n'
int a5, // gwxMark
int *a6, // "f_"
_DWORD *a7, // fileData
int *a8, // 错误信息
_DWORD *a9, // map<string, ?>
_DWORD *a10,// ???
_DWORD *a11,// ???
int a12, // bool
char a13; // bool
// copy from param
// 判断文件拓展名是否为 wxml
std::string::substr(v95, a2, a2[1] - 5, 0xFFFFFFFF);
lpuexcpta = std::operator==<char>((int)v95, ".wxml");
std::string::_M_dispose((void **)v95);
if ( lpuexcpta )
{
// wxml文件
v66 = 0;
v67 = 0;
v68 = 0;
WXML::DOMLib::Parser::Parser(v49);
lpuexcpt = (struct _Unwind_Exception *)WXML::DOMLib::Parser::Parse(
(int)v95, // 存放结果?
a1, // 源码?
*a3, //
(int)a8,// 错误信息
(int)a2, // 文件名
&v66
);
// Parse返回值0正常
if ( !lpuexcpt )
{
WXML::DOMLib::Parser::GetParsed(&v91, (WXML::DOMLib::Parser *)v95);
// v91 = v95.GetParsed()
// a2 文件名?
v13 = std::map<std::string,zcc::shared_ptr<WXML::DOMLib::WXMLDom>>::operator[](a9, (int)a2);
// a9[a2] a9[fileName]
*(_DWORD *)v13 = v91;
// a9[a2] a9[fileName] = v91
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator=((volatile signed __int32 **)v13 + 1, v92);
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count(&v92);
v70 = 0;
v69 = &v71;
v71 = 0;
v72[0] = (int)&v73;
v72[1] = 0;
v73 = 0;
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream((int)v88);
if ( v66 != v67 )
{
v51 = std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v89, "f_['");
WXML::Rewrite::ToStringCode((int)&v91, a2);
v14 = std::operator<<<char>(v51, &v91);
v15 = std::operator<<<std::char_traits<char>>(v14, "']={};");
std::operator<<<std::char_traits<char>>(v15, a4);
std::string::_M_dispose((void **)&v91);
}
for ( i = 0; -1227133513 * (((char *)v67 - (char *)v66) >> 4) > i; ++i )
{
v74[1] = 0;
v79[0] = &v80;
v81[0] = (int)&v82;
v74[0] = &v75;
v76 = (int)&v78;
v75 = 0;
v77 = 0;
v78 = 0;
v79[1] = 0;
v80 = 0;
v81[1] = 0;
v82 = 0;
v55 = WXML::Compiler::DealWxsTag((int)a2, &v66[28 * i], v74, (int)&v76, (int)v79, &v65, a8);
if ( v55 )
goto LABEL_20;
// // copy from param
// WXML::DOMLib::Parser *a1@<edi>,
// int *a2, // 文件名
// char **a3,
// char a4, // '\n'
// int a5, // gwxMark
// int *a6, // "f_"
// _DWORD *a7, // fileData
// int *a8, // 错误信息
// _DWORD *a9, // map<string, ?>
// _DWORD *a10,// ???
// _DWORD *a11,// ???
// int a12, // bool
// char a13; // bool
// // copy from param
v16 = std::operator<<<char>((std::ostream::sentry *)v89, a6);
v56 = std::operator<<<std::char_traits<char>>(v16, "['");
WXML::Rewrite::ToStringCode((int)v87, a2);
v17 = std::operator<<<char>(v56, v87);
v57 = std::operator<<<std::char_traits<char>>(v17, "']['");
WXML::Rewrite::ToStringCode((int)&v91, (int *)v74);
v18 = std::operator<<<char>(v57, &v91);
std::operator<<<std::char_traits<char>>(v18, "'] =");
std::string::_M_dispose((void **)&v91);
std::string::_M_dispose((void **)v87);
if ( v77 )
{
MMBizWxaAppComm::PathCombine(a2, &v76, (unsigned int *)v81);
if ( *(_BYTE *)v81[0] == '/' /*47*/ )
{
std::operator+<char>((int)v86, '.'/*46*/, (int)v81);
std::string::operator=((unsigned __int8 **)v81, (int)v86);
std::string::_M_dispose((void **)v86);
}
if ( a7 + 1 == std::_Rb_tree<std::string,std::pair<std::string const,std::string>,std::_Select1st<std::pair<std::string const,std::string>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::string>>>::find(
a7,
(int)v81)
&& (std::operator==<char>(a5, "$gwx") || a13) )
{
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream((int)&v91);
v19 = std::operator<<<char>((std::ostream::sentry *)v93, a2);
std::operator<<<std::char_traits<char>>(v19, ":");
v20 = (std::ostream::sentry *)std::ostream::operator<<(v65);
std::operator<<<std::char_traits<char>>(v20, ":");
v21 = (std::ostream::sentry *)std::ostream::operator<<(v66[28 * i + 3]);
v22 = std::operator<<<std::char_traits<char>>(v21, ":");
v23 = std::operator<<<char>(v22, &v76);
v24 = std::operator<<<std::char_traits<char>>(v23, " not found from ");
// a2 fileName
std::operator<<<char>(v24, a2);
std::stringbuf::str((int)v87, (int)v94);
// v87.str(v94)
// a8 errorMessage
std::string::operator=((unsigned __int8 **)a8, (int)v87);
std::string::_M_dispose((void **)v87);
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::~basic_stringstream((int)&v91);
v55 = 1;
LABEL_20:
std::string::_M_dispose((void **)v81);
std::string::_M_dispose(v79);
std::string::_M_dispose((void **)&v76);
std::string::_M_dispose(v74);
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::~basic_stringstream((int)v88);
std::string::_M_dispose((void **)v72);
std::string::_M_dispose((void **)&v69);
lpuexcpt = (struct _Unwind_Exception *)v55;
goto LABEL_24;
}
v58 = std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v89, "f_['");
WXML::Rewrite::ToStringCode((int)&v91, v81);
v25 = std::operator<<<char>(v58, &v91);
std::operator<<<std::char_traits<char>>(v25, "'] || ");
std::string::_M_dispose((void **)&v91);
v59 = std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v89, "nv_require(\"");
std::operator+<char>((int)v87, "p_", (int)v81);
WXML::Rewrite::ToStringCode((int)&v91, v87);
v26 = std::operator<<<char>(v59, &v91);
v27 = std::operator<<<std::char_traits<char>>(v26, "\");");
// lineEnd '\n'
std::operator<<<std::char_traits<char>>(v27, a4);
std::string::_M_dispose((void **)&v91);
std::string::_M_dispose((void **)v87);
v28 = std::operator<<<char>((std::ostream::sentry *)v89, a6);
v60 = std::operator<<<std::char_traits<char>>(v28, "['");
WXML::Rewrite::ToStringCode((int)v87, a2);
v29 = std::operator<<<char>(v60, v87);
v61 = std::operator<<<std::char_traits<char>>(v29, "']['");
WXML::Rewrite::ToStringCode((int)&v91, (int *)v74);
v30 = std::operator<<<char>(v61, &v91);
v31 = std::operator<<<std::char_traits<char>>(v30, "']();");
std::operator<<<std::char_traits<char>>(v31, a4);
std::string::_M_dispose((void **)&v91);
v32 = (void **)v87;
}
else
{
// // copy from param
// WXML::DOMLib::Parser *a1@<edi>,
// int *a2, // 文件名
// char **a3,
// char a4, // '\n'
// int a5, // gwxMark
// int *a6, // "f_"
// _DWORD *a7, // fileData
// int *a8, // 错误信息
// _DWORD *a9, // map<string, ?>
// _DWORD *a10,// ???
// _DWORD *a11,// ???
// int a12, // bool
// char a13; // bool
// // copy from param
std::operator+<char>((int)v86, "m_", (int)a2);
v33 = std::string::append(v86, ":");
std::string::basic_string(v87, v33);
v34 = std::string::append(v87, (int)v74);
std::string::basic_string(&v91, v34);
WXML::Compiler::GetFuncId(v83, a11, (int)&v91);
std::string::_M_dispose((void **)&v91);
std::string::_M_dispose((void **)v87);
std::string::_M_dispose((void **)v86);
v55 = night::compile_ns((int)a2, (int)v83, (int)v79, v65, (unsigned int *)v72, 0);
if ( v55 )
{
std::string::_M_assign((int)a8, (int)v72);
std::string::_M_dispose(v83);
goto LABEL_20;
}
v62 = std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v89, "nv_require(\"");
std::operator+<char>((int)v84, "m_", (int)a2);
v35 = std::string::append(v84, ":");
std::string::basic_string(v86, v35);
v36 = std::string::append(v86, (int)v74);
std::string::basic_string(v87, v36);
WXML::Rewrite::ToStringCode((int)&v91, v87);
v37 = std::operator<<<char>(v62, &v91);
v38 = std::operator<<<std::char_traits<char>>(v37, "\");");
std::operator<<<std::char_traits<char>>(v38, a4);
std::string::_M_dispose((void **)&v91);
std::string::_M_dispose((void **)v87);
std::string::_M_dispose((void **)v86);
std::string::_M_dispose((void **)v84);
v39 = std::operator<<<char>((std::ostream::sentry *)v89, v72);
std::operator<<<std::char_traits<char>>(v39, a4);
v32 = v83;
}
std::string::_M_dispose(v32);
std::string::_M_dispose((void **)v81);
std::string::_M_dispose(v79);
std::string::_M_dispose((void **)&v76);
std::string::_M_dispose(v74);
}
std::stringbuf::str((int)&v91, (int)v90);
// v90 = v91.str()
std::string::operator=((unsigned __int8 **)&v69, (int)&v91);
std::string::_M_dispose((void **)&v91);
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::~basic_stringstream((int)v88);
std::string::_M_dispose((void **)v72);
if ( v70 )
{
v40 = std::map<std::string,std::string>::operator[](a10, (int)a2);
std::string::_M_assign((int)v40, (int)&v69);
}
std::string::_M_dispose((void **)&v69);
}
LABEL_24:
WXML::DOMLib::Parser::~Parser((int)v95);
std::vector<WXML::DOMLib::Token>::~vector((void **)&v66);
}
else
{
std::string::substr(v95, a2, a2[1] - 4, 0xFFFFFFFF);
v52 = std::operator==<char>((int)v95, ".wxs");
std::string::_M_dispose((void **)v95);
lpuexcpt = 0;
if ( v52 )
{
// // copy from param
// WXML::DOMLib::Parser *a1@<edi>,
// int *a2, // 文件名
// char **a3,
// char a4, // '\n'
// int a5, // gwxMark
// int *a6, // "f_"
// _DWORD *a7, // fileData
// int *a8, // 错误信息
// _DWORD *a9, // map<string, ?>
// _DWORD *a10,// ???
// _DWORD *a11,// ???
// int a12, // bool
// char a13; // bool
// // copy from param
v84[0] = (int)&v85;
v84[1] = 0;
v85 = 0;
std::operator+<char>((int)v95, "p_", (int)a2);
WXML::Compiler::GetFuncId((void **)v86, a11, (int)v95);
std::string::_M_dispose((void **)v95);
lpuexcpt = (struct _Unwind_Exception *)night::compile_ns((int)a2, (int)v86, (int)a3, 1, (unsigned int *)v84, 0);
if ( lpuexcpt )
{
std::string::_M_assign((int)a8, (int)v84);
}
else
{
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream((int)v95);
v53 = std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v96, "f_['");
WXML::Rewrite::ToStringCode((int)v87, a2);
v41 = std::operator<<<char>(v53, v87);
v42 = std::operator<<<std::char_traits<char>>(v41, "'] = nv_require(");
v54 = std::operator<<<std::char_traits<char>>(v42, '"'/*34*/);
std::operator+<char>((int)v88, "p_", (int)a2);
WXML::Rewrite::ToStringCode((int)&v91, v88);
v43 = std::operator<<<char>(v54, &v91);
v44 = std::operator<<<std::char_traits<char>>(v43, '"'/*34*/);
v45 = std::operator<<<std::char_traits<char>>(v44, ");");
std::operator<<<std::char_traits<char>>(v45, a4);
std::string::_M_dispose((void **)&v91);
std::string::_M_dispose((void **)v88);
std::string::_M_dispose((void **)v87);
// v84 compile_ns结果
v46 = std::operator<<<char>((std::ostream::sentry *)v96, v84);
std::operator<<<std::char_traits<char>>(v46, a4);
std::stringbuf::str((int)&v91, (int)v97);
v47 = std::map<std::string,std::string>::operator[](a10, (int)a2);
std::string::operator=((unsigned __int8 **)v47, (int)&v91);
std::string::_M_dispose((void **)&v91);
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::~basic_stringstream((int)v95);
}
std::string::_M_dispose((void **)v86);
std::string::_M_dispose((void **)v84);
}
}
return lpuexcpt;
}
// 40561E: variable 'v49' is possibly undefined

14
test/resolve_path.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
#include "../src/include/wxml.h"
using namespace std;
int main(void)
{
printf("test....\n");
string a = "./page/API/components/set-tab-bar/set-tab-bar.wxml";
string b = "../../../common/head.wxml";
string result = WXML::DOMLib::resolvePath(a, b);
printf("%s\n", result.c_str());
return 0;
}

Binary file not shown.

View File

@ -410,8 +410,10 @@ LABEL_72:
v68 = -1;
goto LABEL_153;
}
// -lla
v51 = 1;
}
// -lla 或 -llw
if ( !std::string::compare((int)blankStr, " ") )
std::string::basic_string((void **)&tempData, ",");
else
@ -598,10 +600,12 @@ LABEL_84:
if ( v43 )
{
v70 = v93;
// 处理文件路径
for ( Streamg = (FILE *)v92; Streamg != (FILE *)v70; Streamg = (FILE *)((char *)Streamg + 24) )
{
if ( *Streamg->_ptr == 46 && Streamg->_ptr[1] == 47 )
if ( *Streamg->_ptr == 46 /*.*/ && Streamg->_ptr[1] == 47 /*/*/ )
{
// 以"./"开头,去掉前两个字符
std::string::substr(&tempData, Streamg, 2u, 0xFFFFFFFF);
std::string::operator=((unsigned __int8 **)Streamg, (int)&tempData);
std::string::_M_dispose((void **)&tempData);
@ -627,18 +631,18 @@ LABEL_84:
v126,
(int)&v109);
v68 = (int)WXML::Compiler::CompileLazy(
&v107,
&v107, // fileData std::map<std::string,std::string> (file -> content)
(int *)v111,
&v115,
&v101,
&v115, // outputMap std::map<std::string,std::string>
&v101, // dict map<string, string>
&v121,
v126,
(int *)&v92,
&v105,
v53,
(int *)&v92, // splitedData
&v105, // mapData1
v53, // isLLA
(int)gwxMark,
mark,
10,
10, // asci -> '\n'
(int *)v127, // 'e'
(int *)v128, // const char off_5403C3[] = {'s','\0','e','\0'}
(int *)v129, // "gg"

View File

@ -8983,6 +8983,7 @@ int GetNextArg(int a1, int *a2, int a3)
std::string::operator=((unsigned __int8 **)v6, (int)v8);
std::string::_M_dispose(v8);
std::string::substr(v9, a2, (unsigned int)lpuexcpt + *(_DWORD *)(a3 + 4), 0xFFFFFFFF);
// v9 = a2.substr(lpuexcpt)
std::string::operator=((unsigned __int8 **)a2, (int)v9);
std::string::_M_dispose(v9);
}
@ -9088,6 +9089,7 @@ int __cdecl Split(int a1, int *a2, int a3)
{
v5 = i;
std::string::substr(v7, a2, (unsigned int)lpuexcpt, i - (_DWORD)lpuexcpt);
// v7 = a2.substr(lpuexcpt, i - lpuexcpt)
Trim((int)v8, (int)v7);
std::vector<std::string>::emplace_back<std::string>((void **)a1, v8);
std::string::_M_dispose(v8);
@ -10815,7 +10817,13 @@ void __fastcall std::deque<std::string>::~deque(int a1)
// 404665: variable 'v3' is possibly undefined
//----- (0040469D) --------------------------------------------------------
int __cdecl WXML::Compiler::DealWxsTag(int a1, int **a2, _DWORD *a3, int a4, int a5, _DWORD *a6, int *a7)
int __cdecl WXML::Compiler::DealWxsTag(
int a1,
int **a2,
_DWORD *a3,
int a4, int a5,
_DWORD *a6,
int *a7)
{
bool v7; // zf
int *v8; // eax
@ -10878,14 +10886,15 @@ int __cdecl WXML::Compiler::DealWxsTag(int a1, int **a2, _DWORD *a3, int a4, int
char v66[196]; // [esp+19Ch] [ebp-23Ch] BYREF
void *v67[94]; // [esp+260h] [ebp-178h] BYREF
lpuexcptc = std::string::find(*a2, 62, (unsigned int)a2[4]);
lpuexcptc = std::string::find(*a2, '>'/*62*/, (unsigned int)a2[4]);
// a2.find('>')
v40 = (unsigned int)(lpuexcptc + 1);
std::string::basic_string(v51, "<fak");
std::string::basic_string(v52, "/>");
v53[0] = &v54;
v54 = 0;
v53[1] = 0;
v7 = *(_BYTE *)std::string::at(*a2, (unsigned int)(lpuexcptc - 1)) == 47;
v7 = *(_BYTE *)std::string::at(*a2, (unsigned int)(lpuexcptc - 1)) == '/'/*47*/;
v8 = a2[4];
v9 = *a2;
if ( v7 )
@ -13180,28 +13189,28 @@ LABEL_118:
//----- (0040A124) --------------------------------------------------------
struct _Unwind_Exception *__cdecl WXML::Compiler::CompileLazy(
_DWORD *a1,
int *a2,
_DWORD *a3,
_DWORD *a4,
_DWORD *a1, // fileData
int *a2, // 错误信息
_DWORD *a3, // 输出1
_DWORD *a4, // 输出2
_DWORD *a5,
_DWORD *a6,
int *a7,
_DWORD *a8,
char a9,
int a10,
int a11,
char a12,
int *a13,
int *a14,
int *a15,
int *a16,
int *a17,
int *a18,
int a19,
int a20,
int a21,
int *a22)
_DWORD *a6, // vecFileContentMap
int *a7,// splitedData
_DWORD *a8,// mapData1
char a9,// isLLA
int a10,// gwxMark
int a11,// mark
char a12,// '\n'
int *a13,// 'e'
int *a14,// const char off_5403C3[] = {'s','\0','e','\0'}
int *a15, // "gg"
int *a16,// "e_"
int *a17,// "d_"
int *a18,// "p_"
int a19, // '\0'
int a20, // "boxofchocolate"
int a21, // "$gdwx"
int *a22) // "f_"
{
volatile signed __int32 **v22; // eax
_DWORD *v23; // eax
@ -13513,7 +13522,30 @@ struct _Unwind_Exception *__cdecl WXML::Compiler::CompileLazy(
char v330[4]; // [esp+248h] [ebp-E0h] BYREF
volatile signed __int32 **v331; // [esp+24Ch] [ebp-DCh]
unsigned int v332; // [esp+254h] [ebp-D4h]
/*
_DWORD *a1, // fileData
int *a2, // 错误信息
_DWORD *a3, // 输出1
_DWORD *a4, // 输出2
_DWORD *a5,
_DWORD *a6, // vecFileContentMap
int *a7,// splitedData
_DWORD *a8,// mapData1
char a9,// isLLA
int a10,// gwxMark
int a11,// mark
char a12,// '\n'
int *a13,// 'e'
int *a14,// const char off_5403C3[] = {'s','\0','e','\0'}
int *a15, // "gg"
int *a16,// "e_"
int *a17,// "d_"
int *a18,// "p_"
int a19, // '\0'
int a20, // "boxofchocolate"
int a21, // "$gdwx"
int *a22) // "f_"
*/
std::_Rb_tree_header::_Rb_tree_header(v302);
std::_Rb_tree_header::_Rb_tree_header(v305);
std::_Rb_tree_header::_Rb_tree_header(v308);
@ -13524,19 +13556,20 @@ struct _Unwind_Exception *__cdecl WXML::Compiler::CompileLazy(
while ( lpuexcpt != v249 )
{
v258 = WXML::Compiler::ParseSource(
v249,
(int *)lpuexcpt + 4,
(char **)lpuexcpt + 10,
a12,
a10,
a22,
a1,
a2,
&v304,
&v309,
&v311,
(a11 & 4) != 0,
v249, // 源码?
(int *)lpuexcpt + 4, // 文件名
(char **)lpuexcpt + 10,//
a12, // '\n'
a10, // gwxMark
a22, // "f_"
a1, // fileData
a2, // 错误信息
&v304, // map<string, ?>
&v309, // ???
&v311, // ???
(a11 & 4) != 0, // a11 -> mark
(a11 & 0x20) != 0);
// 源码解析失败LABEL_187 -> return v258
if ( v258 )
goto LABEL_187;
lpuexcpt = (struct _Unwind_Exception *)std::_Rb_tree_increment((int)lpuexcpt);
@ -13548,7 +13581,9 @@ struct _Unwind_Exception *__cdecl WXML::Compiler::CompileLazy(
v22 = (volatile signed __int32 **)std::map<std::string,zcc::shared_ptr<std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>>>::operator[](
&v301,
&v328);
// v22 = v301["__COMMON__"]
*v22 = (volatile signed __int32 *)jj;
// v301["__COMMON__"] = jj
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator=(v22 + 1, v326);
std::string::_M_dispose((void **)&v328);
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count(&v326);
@ -13557,15 +13592,42 @@ struct _Unwind_Exception *__cdecl WXML::Compiler::CompileLazy(
v327 = 0;
std::string::basic_string((void **)&v328, "__COMMON__");
v23 = std::map<std::string,std::vector<std::string>>::operator[](&v307, &v328);
// v23 = v307["__COMMON__"]
std::vector<std::string>::operator=(v23, &jj);
// v307["__COMMON__"] = jj
std::string::_M_dispose((void **)&v328);
std::vector<std::string>::~vector((void ***)&jj, v24);
std::string::basic_string((void **)&v328, "__COMMON__");
v226 = *std::map<std::string,zcc::shared_ptr<std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>>>::operator[](
&v301,
&v328);
// v226 = v301["__COMMON__"]
std::string::_M_dispose((void **)&v328);
v237 = (WXML::EXPRLib::Parser *)a7[1];
/*
_DWORD *a1, // fileData
int *a2, // 错误信息
_DWORD *a3, // 输出1
_DWORD *a4, // 输出2
_DWORD *a5,
_DWORD *a6, // vecFileContentMap
int *a7,// splitedData
_DWORD *a8,// mapData1
char a9,// isLLA
int a10,// gwxMark
int a11,// mark
char a12,// '\n'
int *a13,// 'e'
int *a14,// const char off_5403C3[] = {'s','\0','e','\0'}
int *a15, // "gg"
int *a16,// "e_"
int *a17,// "d_"
int *a18,// "p_"
int a19, // '\0'
int a20, // "boxofchocolate"
int a21, // "$gdwx"
int *a22) // "f_"
*/
for ( i = *a7; (WXML::EXPRLib::Parser *)i != v237; i += 24 )
{
v222 = operator new(0xD0u);
@ -21684,7 +21746,7 @@ _DWORD *__fastcall WXML::DOMLib::Parser::Peek(_DWORD *a1)
v2 = a1[22];
v3 = a1[25];
if ( v3 < -1227133513 * ((a1[23] - v2) >> 4) )
return (_DWORD *)(v2 + 112 * v3);
return (_DWORD *)(v2 + 112 * v3); // 112 ascii -> 'p'
return result;
}
@ -21749,6 +21811,7 @@ int __cdecl WXML::DOMLib::joinString(int a1, _DWORD *a2, char a3)
(unsigned int)lpuexcpt < -1431655765 * ((a2[1] - *a2) >> 3);
lpuexcpt = (struct _Unwind_Exception *)((char *)lpuexcpt + 1) )
{
// -1431655765 * ((a2[1] - *a2) >> 3 =====> a2.size()
std::operator<<<char>((std::ostream::sentry *)v6, (int *)(24 * (_DWORD)lpuexcpt + *a2));
if ( (struct _Unwind_Exception *)(-1431655765 * ((a2[1] - *a2) >> 3) - 1) != lpuexcpt )
std::operator<<<std::char_traits<char>>((std::ostream::sentry *)v6, a3);
@ -22165,15 +22228,18 @@ int __cdecl WXML::DOMLib::resolvePath(int a1, int *a2, int *a3)
*(_BYTE *)(a1 + 8) = 0;
*(_DWORD *)a1 = a1 + 8;
*(_DWORD *)(a1 + 4) = 0;
if ( *(_BYTE *)*a3 != 47 )
if ( *(_BYTE *)*a3 != '/'/*47*/ )
{
WXML::DOMLib::splitString((int)&v10, a2, 47);
// path1
WXML::DOMLib::splitString((int)&v10, a2, '/'/*47*/);
v11 -= 6;
std::string::_M_dispose(v11);
WXML::DOMLib::splitString((int)v13, a3, 47);
// path2
WXML::DOMLib::splitString((int)v13, a3, '/'/*47*/);
for ( i = 0; i < -1431655765 * ((v13[1] - v13[0]) >> 3); ++i )
{
lpuexcpt = (struct _Unwind_Exception *)(24 * i);
// v13 p2Split
if ( std::operator==<char>(24 * i + v13[0], "..") )
{
v11 -= 6;
@ -22185,13 +22251,13 @@ int __cdecl WXML::DOMLib::resolvePath(int a1, int *a2, int *a3)
std::vector<std::string>::push_back((int)&v10, (int)lpuexcpt + v13[0]);
}
}
WXML::DOMLib::joinString((int)v12, &v10, 47);
WXML::DOMLib::joinString((int)v12, &v10, '/'/*47*/);
std::string::operator=((unsigned __int8 **)a1, (int)v12);
std::string::_M_dispose(v12);
std::vector<std::string>::~vector((void ***)v13, v3);
std::vector<std::string>::~vector(&v10, v4);
}
if ( *(_BYTE *)*a2 == 46 && *(_BYTE *)*a3 == 47 )
if ( *(_BYTE *)*a2 == '.'/*46*/ && *(_BYTE *)*a3 == '/'/*47*/ )
{
std::operator+<char>((int)v13, ".", (int)a3);
std::string::operator=((unsigned __int8 **)a1, (int)v13);
@ -22246,17 +22312,25 @@ void __fastcall WXML::DOMLib::Parser::ATTR(WXML::DOMLib::Parser *a1)
for ( i = 0; v20 > i; ++i )
{
v3 = *(_BYTE *)(v19[4] + *(_DWORD *)v19[0] + i);
if ( (unsigned __int8)((v3 & 0xDF) - 65) > 0x19u && (unsigned __int8)(v3 - 48) > 0xAu && v3 != 95 && v3 != 45 )
if (
// 0xDF -> 1101 1111
(unsigned __int8)((v3 & 0xDF) - 'A'/*65*/) > 25/*0x19u*/ // 超出26个大写字母范围
&& (unsigned __int8)(v3 - '0'/*48*/) > 10 /*0xAu*/ // 不是9可能把(冒号:)考虑进去了
&& v3 != '_'/*95*/ // 不是下划线
&& v3 != '-'/*45*/ // 不是连字符
)
goto LABEL_12;
}
if ( (unsigned int)(v20 - 1) > 0xFFFE )
// 0xFFFE -> 1111 1111 1111 1110
// 确保v20在1-65535之间
if ( (unsigned int)(v20 - 1) > 0xFFFE ) // if (v20 > 0xFFFF)
{
LABEL_12:
exception = __cxa_allocate_exception(0x18u);
WXML::DOMLib::Parser::Error(exception, a1, "unexpected attribute name", 0);
__cxa_throw(
exception,
(struct type_info *)&`typeinfo for'WXML::DOMLib::ParseException,
(struct type_info *)&`typeinfo for WXML::DOMLib::ParseException,
WXML::DOMLib::ParseException::~ParseException);
}
v4 = WXML::DOMLib::Token::ToString[abi:cxx11]((int)v19);
@ -23130,8 +23204,8 @@ void __usercall WXML::DOMLib::Parser::DOMS(WXML::DOMLib::Parser *a1@<ecx>, WXML:
//----- (00422450) --------------------------------------------------------
int __userpurge WXML::DOMLib::Parser::Parse@<eax>(
int a1@<ecx>,
WXML::DOMLib::Parser *a2@<edi>,
char *Str,
WXML::DOMLib::Parser *a2@<edi>,
char *Str, // fileName
int a4,
int a5,
_DWORD *a6)
@ -28161,7 +28235,7 @@ int __thiscall WXML::EXPRLib::Parser::Parse(int this, char **a2, int a3, int a4,
dword_53FCEC = (int)&dword_53FCE0;
dword_53FCF0 = 0;
byte_53FCF4 = 0;
__cxa_guard_release(&`guard variable for'WXML::EXPRLib::TransitTable::GetInstance(void)::ret);
// __cxa_guard_release(&`guard variable for'WXML::EXPRLib::TransitTable::GetInstance(void)::ret);
atexit(__tcf_0_1);
}
WXML::EXPRLib::TransitTable::Init(v41);
@ -190139,7 +190213,7 @@ int main(int argc, const char **argv, const char **envp)
}
break;
case 'v':
if ( v5[2] == 98 )
if ( v5[2] == 'b'/*98*/ )
v60 |= 0x10u;
else
v44 = 1;
@ -190196,7 +190270,7 @@ LABEL_72:
goto LABEL_84;
case 'i':
v60 |= 0x40u;
goto LABEL_84;
goto LABEL_84; // continue;
}
std::string::basic_string((void **)&v143, "--split");
v51 = std::operator==<char>((int)&v89[v67], (int)&v143);
@ -190316,6 +190390,7 @@ LABEL_84:
v110[3] = (int)v110;
v110[4] = 0;
Streamc = 0;
// isReadFromStdin
if ( v45 )
{
v143 = (int)v145;
@ -190341,7 +190416,7 @@ LABEL_84:
Streamc = (FILE *)((char *)Streamc + 1);
}
}
if ( v96 )
if ( v96 ) //if (!xc_Or_completeCode_Param.empty())
{
GetNextArg((int)String, (int *)&v95, (int)v104);
v52 = strtoull(String[0], 0, 10);
@ -190356,7 +190431,10 @@ LABEL_84:
LOBYTE(v142[0]) = 0;
memset(String, 0, 12);
GetNextArg((int)v135, (int *)&v95, (int)v104);
// v95 xc_Or_completeCode_Param, v104 splitMarkStr
// v135 = GetNextArg(v95, v104)
std::string::operator=((unsigned __int8 **)&v140, (int)v135);
// v140 = v135 = GetNextArg(v95, v104)
std::string::_M_dispose(v135);
GetNextArg((int)v136, (int *)&v95, (int)v104);
v50 = strtoull(v136[0], 0, 10);
@ -190367,6 +190445,7 @@ LABEL_84:
v143 = (int)v145;
v145[0] = 0;
GetNextArg((int)&v137, (int *)&v95, (int)v104);
// v137 = GetNextArg(v95, v104)
std::string::operator=((unsigned __int8 **)&v143, (int)&v137);
std::string::_M_dispose((void **)&v137);
std::vector<std::string>::push_back((int)String, (int)&v143);
@ -190375,26 +190454,33 @@ LABEL_84:
v131,
v132,
(int)&v143) )
// v143 arg2
std::vector<std::string>::push_back((int)&v131, (int)&v143);
std::string::_M_dispose((void **)&v143);
}
Streame = (FILE *)std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::lower_bound(
Streame = (FILE *)std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>
::lower_bound(
&v109,
(int)&v140);
// Streame = v109.lower_bound(v140)
// v109 vecFileContentMap
if ( Streame == (FILE *)v110 || (unsigned __int8)std::operator<<char>((int)&v140, (int)&Streame->_file) )
{
Block = operator new(0x34u);
Block = operator new(0x34u); // 34 -> 4
std::string::basic_string((char *)Block + 16, (int)&v140);
Block[10] = 0;
Block[11] = 0;
Block[12] = 0;
Streame = (FILE *)std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::_M_get_insert_hint_unique_pos(
Streame = (FILE *)std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>
::_M_get_insert_hint_unique_pos(
&v109,
Streame,
(int)(Block + 4));
// v109._M_get_insert_hint_unique_pos()
if ( v22 )
{
Streame = (FILE *)std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::_M_insert_node(
Streame = (FILE *)std::_Rb_tree<std::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>
::_M_insert_node(
&v109,
(int)Streame,
v22,
@ -190428,7 +190514,7 @@ LABEL_84:
v118 = &v116;
v119 = &v116;
v120 = 0;
if ( v43 )
if ( v43 ) // hasLL
{
v70 = v93;
for ( Streamg = (FILE *)v92; Streamg != (FILE *)v70; Streamg = (FILE *)((char *)Streamg + 24) )
@ -190460,28 +190546,28 @@ LABEL_84:
v126,
(int)&v109);
v68 = (int)WXML::Compiler::CompileLazy(
&v107,
(int *)v111,
&v115,
&v101,
&v107, // fileContent
(int *)v111, // errorMessage
&v115, // outputMap
&v101, // dict
&v121,
v126,
(int *)&v92,
&v105,
v53,
(int)v103,
v60,
10,
(int *)v127,
(int *)v128,
(int *)v129,
(int *)v130,
&v131,
(int *)String,
(int)v135,
(int)v136,
(int)&v137,
(int *)&v140);
v126, // vecFileContentMap
(int *)&v92, // splitedData
&v105, // mapData1
v53, // isLLA
(int)v103,// gwxMark
v60, // mark
10, // '\n'
(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::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::~_Rb_tree((int)v126);
std::string::_M_dispose(v127);
std::string::_M_dispose(v128);
@ -190644,19 +190730,19 @@ LABEL_84:
v126,
&v105,
v53,
(int *)v103,
v60,
10,
(int *)v127,
(int *)v128,
(int *)v129,
(int *)v130,
&v131,
(int *)String,
(int)v135,
(int)v136,
(int)&v137,
(int *)&v140);
(int *)v103, // gwxMark
v60, // mark
10, // '\n'
(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::string,std::pair<std::string const,std::vector<std::string>>,std::_Select1st<std::pair<std::string const,std::vector<std::string>>>,std::less<std::string>,std::allocator<std::pair<std::string const,std::vector<std::string>>>>::~_Rb_tree((int)v126);
std::string::_M_dispose(v127);
std::string::_M_dispose(v128);