mirror of
https://github.com/msojocs/wx-compiler.git
synced 2025-07-19 00:00:04 +08:00
feat: 增加一些方法
This commit is contained in:
parent
d76457d794
commit
4caf9f2581
@ -11,11 +11,12 @@ add_executable(wcc
|
|||||||
src/wxml/rewrite.cpp
|
src/wxml/rewrite.cpp
|
||||||
src/wxml/name_allocator.cpp
|
src/wxml/name_allocator.cpp
|
||||||
src/wxml/dom_lib/token.cpp
|
src/wxml/dom_lib/token.cpp
|
||||||
|
src/wxml/dom_lib/tokenizer.cpp
|
||||||
|
src/wxml/dom_lib/parser.cpp
|
||||||
src/wxml/compiler.cpp
|
src/wxml/compiler.cpp
|
||||||
src/wxml/dom_lib/str_cache.cpp
|
src/wxml/dom_lib/str_cache.cpp
|
||||||
src/wxml/dom_lib/wxml_dom.cpp
|
src/wxml/dom_lib/wxml_dom.cpp
|
||||||
src/wxml/dom_lib/machine.cpp
|
src/wxml/dom_lib/machine.cpp
|
||||||
src/wxml/dom_lib/parser.cpp
|
|
||||||
src/utils/string_utils.cpp
|
src/utils/string_utils.cpp
|
||||||
src/utils/file.cpp
|
src/utils/file.cpp
|
||||||
)
|
)
|
||||||
@ -27,9 +28,8 @@ add_executable(
|
|||||||
test/resolve_path.cpp
|
test/resolve_path.cpp
|
||||||
src/wxml/dom_lib/common.cpp
|
src/wxml/dom_lib/common.cpp
|
||||||
)
|
)
|
||||||
add_test(
|
add_executable(test1
|
||||||
resolve_test
|
test/test.cpp
|
||||||
resolve_path
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||||
|
@ -6,6 +6,19 @@ v
|
|||||||
| 操作 | 数据 | 备注 |
|
| 操作 | 数据 | 备注 |
|
||||||
|---|---|---- |
|
|---|---|---- |
|
||||||
| v + 0 | data | 字符串内容 |
|
| v + 0 | data | 字符串内容 |
|
||||||
| v + 4 | size() | 字符串长度 |
|
| *(_DWORD *)(v + 4) | size() | 字符串长度 |
|
||||||
|
|
||||||
|
## std::deque
|
||||||
|
|
||||||
|
| 操作 | 数据 | 备注 |
|
||||||
|
|---|---|---- |
|
||||||
|
| (_DWORD *)(a1 + 8) | data | 内容 |
|
||||||
|
| (_DWORD *)(a1 + 16) | begin() | 起始 |
|
||||||
|
| (_DWORD *)(a1 + 32) | end() | 结束 |
|
||||||
|
|
||||||
|
|
||||||
|
## stringstream
|
||||||
|
|
||||||
|
osstream::sentry var
|
||||||
|
|
||||||
|
var + 16 <
|
@ -7,6 +7,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
namespace WXML
|
namespace WXML
|
||||||
{
|
{
|
||||||
@ -71,7 +73,10 @@ namespace WXML
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
std::string str1;
|
int offset_16;
|
||||||
|
int offset_20;
|
||||||
|
bool offset_28;
|
||||||
|
std::string offset_32;
|
||||||
std::string str2;
|
std::string str2;
|
||||||
std::string str3;
|
std::string str3;
|
||||||
public:
|
public:
|
||||||
@ -91,6 +96,21 @@ namespace WXML
|
|||||||
~Token();
|
~Token();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Tokenizer
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/* data */
|
||||||
|
public:
|
||||||
|
Tokenizer(char const*,std::string const&);
|
||||||
|
Tokenizer(/* args */);
|
||||||
|
~Tokenizer();
|
||||||
|
int GetTokens(
|
||||||
|
std::vector<WXML::DOMLib::Token> &,
|
||||||
|
std::string &,
|
||||||
|
std::vector<WXML::DOMLib::Token> &
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -116,10 +136,11 @@ namespace WXML
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
std::string type;
|
|
||||||
bool offset_28;
|
bool offset_28;
|
||||||
int offset_92;
|
int offset_92; // pos1
|
||||||
int offset_96;
|
WXML::DOMLib::Token offset_84; // token
|
||||||
|
int offset_96; // pos2
|
||||||
|
int offset_104; // len
|
||||||
StrCache offset_62;
|
StrCache offset_62;
|
||||||
public:
|
public:
|
||||||
std::string tag;
|
std::string tag;
|
||||||
@ -178,6 +199,9 @@ namespace WXML
|
|||||||
uint a14,
|
uint a14,
|
||||||
std::map<std::string,std::string> * a15
|
std::map<std::string,std::string> * a15
|
||||||
);
|
);
|
||||||
|
void RecordAllPath(void);
|
||||||
|
void Print(int,char const*,std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>> *);
|
||||||
|
void PrintMe(int,char const*,std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>> *);
|
||||||
bool operator==(std::string tag);
|
bool operator==(std::string tag);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -188,6 +212,12 @@ namespace WXML
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
|
WXML::DOMLib::WXMLDom dom;
|
||||||
|
std::deque<std::string> dequeStr;
|
||||||
|
std::vector<WXML::DOMLib::Token> offset_88;
|
||||||
|
int offset_128;
|
||||||
|
std::string offset_328;
|
||||||
|
std::deque<std::shared_ptr<WXML::DOMLib::WXMLDom>> dequeDom;
|
||||||
public:
|
public:
|
||||||
Parser(/* args */);
|
Parser(/* args */);
|
||||||
~Parser();
|
~Parser();
|
||||||
@ -206,7 +236,7 @@ namespace WXML
|
|||||||
);
|
);
|
||||||
|
|
||||||
int Error(char const*, WXML::DOMLib::Token &);
|
int Error(char const*, WXML::DOMLib::Token &);
|
||||||
std::string GetParsed();
|
WXML::DOMLib::WXMLDom GetParsed();
|
||||||
std::string DOM();
|
std::string DOM();
|
||||||
std::string DOMS();
|
std::string DOMS();
|
||||||
std::vector<std::string> ATTR_LIST();
|
std::vector<std::string> ATTR_LIST();
|
||||||
@ -308,20 +338,20 @@ namespace WXML
|
|||||||
|
|
||||||
// void GetFuncId();
|
// void GetFuncId();
|
||||||
void GetVersionInfo(std::string &a1, std::string a2);
|
void GetVersionInfo(std::string &a1, std::string a2);
|
||||||
|
|
||||||
WXML::DOMLib::Parser ParseSource(
|
WXML::DOMLib::Parser ParseSource(
|
||||||
std::string const& content, // 源码?
|
std::string const& content, // 源码?a2
|
||||||
std::string const& fileName, // 文件名?
|
std::string const& fileName, // 文件名? a3
|
||||||
std::string const& , // ?
|
char lineEndMark, // '\n' a4
|
||||||
char lineEndMark, // '\n'
|
std::string const& gwxMark, // gwxMark a5
|
||||||
std::string const& gwxMark, // gwxMark
|
std::string const& fMark, // "f_" a6
|
||||||
std::string & fMark, // "f_"
|
std::map<std::string,std::string> const&, // fileData a7
|
||||||
std::map<std::string,std::string> const&, // fileData
|
std::string&, // 错误信息 a8
|
||||||
std::string&, // 错误信息
|
std::map<std::string, WXML::DOMLib::WXMLDom &>,// map<string, ?> a9
|
||||||
std::map<std::string, WXML::DOMLib::WXMLDom>,// map<string, ?>
|
std::map<std::string,std::string>&,// ??? a10
|
||||||
std::map<std::string,std::string>&,// ???
|
std::map<std::string,int>, // ??? a11
|
||||||
std::map<std::string,int>, // ???
|
bool, // mark指定运算结果是否非0 a12
|
||||||
bool, // mark指定运算结果是否非0
|
bool); // mark指定运算结果是否非0 a13
|
||||||
bool); // mark指定运算结果是否非0
|
|
||||||
int RenderDefine(
|
int RenderDefine(
|
||||||
WXML::DOMLib::WXMLDom &,
|
WXML::DOMLib::WXMLDom &,
|
||||||
std::string const&,
|
std::string const&,
|
||||||
|
156
src/wcc.cpp
156
src/wcc.cpp
@ -10,7 +10,11 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
string gwxMark = "$gwx";
|
string gwxMark = "$gwx";
|
||||||
string splitMarkStr = " ";
|
string splitMarkStr = " ";
|
||||||
@ -23,29 +27,33 @@ int main(int argc, const char **argv) {
|
|||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!string("--config-path").compare(argv[i])) {
|
if (!string("--config-path").compare(argv[i]))
|
||||||
|
{
|
||||||
hasConfigParam = i + 1 < argc;
|
hasConfigParam = i + 1 < argc;
|
||||||
}
|
}
|
||||||
if (hasConfigParam) {
|
if (hasConfigParam)
|
||||||
|
{
|
||||||
// 有--config-path参数,下一个参数是路径,跳过
|
// 有--config-path参数,下一个参数是路径,跳过
|
||||||
i++;
|
i++;
|
||||||
configPathLocation = argv[i];
|
configPathLocation = argv[i];
|
||||||
}else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
paramList.emplace_back(argv[i]);
|
paramList.emplace_back(argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 有配置文件,从配置文件解析
|
// 有配置文件,从配置文件解析
|
||||||
if (hasConfigParam) {
|
if (hasConfigParam)
|
||||||
|
{
|
||||||
int ret = readFile(configPathLocation.c_str(), configData);
|
int ret = readFile(configPathLocation.c_str(), configData);
|
||||||
string line;
|
string line;
|
||||||
if (0 == ret) {
|
if (0 == ret)
|
||||||
|
{
|
||||||
while ((line = getNextArg(configData, "\n")).size() > 0)
|
while ((line = getNextArg(configData, "\n")).size() > 0)
|
||||||
{
|
{
|
||||||
paramList.emplace_back(line);
|
paramList.emplace_back(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int mark = 0;
|
int mark = 0;
|
||||||
@ -65,7 +73,8 @@ int main(int argc, const char **argv) {
|
|||||||
for (int i = 0; i < paramList.size(); i++)
|
for (int i = 0; i < paramList.size(); i++)
|
||||||
{
|
{
|
||||||
string param = paramList[i];
|
string param = paramList[i];
|
||||||
if (param[0] != '-') {
|
if (param[0] != '-')
|
||||||
|
{
|
||||||
// 不是参数名,跳过
|
// 不是参数名,跳过
|
||||||
fileList.push_back(param);
|
fileList.push_back(param);
|
||||||
continue;
|
continue;
|
||||||
@ -77,11 +86,13 @@ int main(int argc, const char **argv) {
|
|||||||
case 'd':
|
case 'd':
|
||||||
// output code for debug
|
// output code for debug
|
||||||
/* code */
|
/* code */
|
||||||
if(!param[2]){
|
if (!param[2])
|
||||||
|
{
|
||||||
mark |= 2u;
|
mark |= 2u;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(param[2] == 's') {
|
if (param[2] == 's')
|
||||||
|
{
|
||||||
mark |= 4u;
|
mark |= 4u;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -89,11 +100,13 @@ int main(int argc, const char **argv) {
|
|||||||
case 's':
|
case 's':
|
||||||
// read from stdin
|
// read from stdin
|
||||||
/* code */
|
/* code */
|
||||||
if(param[2] == 't') {
|
if (param[2] == 't')
|
||||||
|
{
|
||||||
mark |= 8u;
|
mark |= 8u;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i + 1 < paramList.size()) {
|
if (i + 1 < paramList.size())
|
||||||
|
{
|
||||||
fileList.push_back(paramList[i + 1]);
|
fileList.push_back(paramList[i + 1]);
|
||||||
isReadFromStdin = true;
|
isReadFromStdin = true;
|
||||||
continue;
|
continue;
|
||||||
@ -111,9 +124,11 @@ int main(int argc, const char **argv) {
|
|||||||
case 'x':
|
case 'x':
|
||||||
// -xc output simplified code for custom component
|
// -xc output simplified code for custom component
|
||||||
/* code */
|
/* code */
|
||||||
if(param[2] == 'c' && i + 1 < paramList.size()) {
|
if (param[2] == 'c' && i + 1 < paramList.size())
|
||||||
|
{
|
||||||
hasXCParam = true;
|
hasXCParam = true;
|
||||||
if(paramList[i + 1][0] != '-') {
|
if (paramList[i + 1][0] != '-')
|
||||||
|
{
|
||||||
xc_Or_completeCode_Param.assign(paramList[i + 1]);
|
xc_Or_completeCode_Param.assign(paramList[i + 1]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -123,9 +138,11 @@ int main(int argc, const char **argv) {
|
|||||||
case 'c':
|
case 'c':
|
||||||
// -cc: output compelete code for custom component
|
// -cc: output compelete code for custom component
|
||||||
/* code */
|
/* code */
|
||||||
if(param[2] == 'c' && i + 1 < paramList.size()) {
|
if (param[2] == 'c' && i + 1 < paramList.size())
|
||||||
|
{
|
||||||
hasCompleteCodeParam = true;
|
hasCompleteCodeParam = true;
|
||||||
if(paramList[i + 1][0] != '-') {
|
if (paramList[i + 1][0] != '-')
|
||||||
|
{
|
||||||
xc_Or_completeCode_Param.assign(paramList[i + 1]);
|
xc_Or_completeCode_Param.assign(paramList[i + 1]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -136,7 +153,8 @@ int main(int argc, const char **argv) {
|
|||||||
// -o: output destination (default stdout)
|
// -o: output destination (default stdout)
|
||||||
// -om XComponentDefine
|
// -om XComponentDefine
|
||||||
/* code */
|
/* code */
|
||||||
if (i + 1 < paramList.size()) {
|
if (i + 1 < paramList.size())
|
||||||
|
{
|
||||||
outputFileName = paramList[i + 1];
|
outputFileName = paramList[i + 1];
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
@ -145,7 +163,8 @@ int main(int argc, const char **argv) {
|
|||||||
case 'g':
|
case 'g':
|
||||||
// -gn gwxMark
|
// -gn gwxMark
|
||||||
/* code */
|
/* code */
|
||||||
if (param[2] == 'n' && i + 1 < paramList.size()) {
|
if (param[2] == 'n' && i + 1 < paramList.size())
|
||||||
|
{
|
||||||
gwxMark.assign(paramList[i + 1]);
|
gwxMark.assign(paramList[i + 1]);
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
@ -175,8 +194,10 @@ int main(int argc, const char **argv) {
|
|||||||
}
|
}
|
||||||
// switch end
|
// switch end
|
||||||
|
|
||||||
if (param == "--split") {
|
if (param == "--split")
|
||||||
if (i + 1 < paramList.size()) {
|
{
|
||||||
|
if (i + 1 < paramList.size())
|
||||||
|
{
|
||||||
splitMarkStr = paramList[i + 1];
|
splitMarkStr = paramList[i + 1];
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
@ -184,27 +205,35 @@ int main(int argc, const char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -cb
|
// -cb
|
||||||
if(param[1] == 'c' && param[2] == 'b') {
|
if (param[1] == 'c' && param[2] == 'b')
|
||||||
|
{
|
||||||
string callbackFile = paramList[i + 1];
|
string callbackFile = paramList[i + 1];
|
||||||
string callbackData;
|
string callbackData;
|
||||||
readFile(callbackFile.c_str(), callbackData);
|
readFile(callbackFile.c_str(), callbackData);
|
||||||
if (!callbackData.empty()) {
|
if (!callbackData.empty())
|
||||||
|
{
|
||||||
mapData1["life_cycle_callback_content"] = callbackData;
|
mapData1["life_cycle_callback_content"] = callbackData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if(!param.compare("--pm")) {
|
{
|
||||||
|
if (!param.compare("--pm"))
|
||||||
|
{
|
||||||
// 参数是--pm
|
// 参数是--pm
|
||||||
if (i + 1 < paramList.size()) {
|
if (i + 1 < paramList.size())
|
||||||
|
{
|
||||||
mapData1["plain_text_marker"] = paramList[i + 1];
|
mapData1["plain_text_marker"] = paramList[i + 1];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (param[1] == 'l' && param[2] == 'l') {
|
if (param[1] == 'l' && param[2] == 'l')
|
||||||
|
{
|
||||||
// -ll
|
// -ll
|
||||||
if (param[3] != 'w') {
|
if (param[3] != 'w')
|
||||||
|
{
|
||||||
// 不是 -llw
|
// 不是 -llw
|
||||||
if (param[3] != 'a') {
|
if (param[3] != 'a')
|
||||||
|
{
|
||||||
// 不是 -lla
|
// 不是 -lla
|
||||||
printf("Error: expected -llw or -lla, but got %s\n", param.c_str());
|
printf("Error: expected -llw or -lla, but got %s\n", param.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
@ -212,10 +241,13 @@ int main(int argc, const char **argv) {
|
|||||||
isLLA = true;
|
isLLA = true;
|
||||||
}
|
}
|
||||||
string splitMark;
|
string splitMark;
|
||||||
if (!splitMarkStr.compare(" ")) {
|
if (!splitMarkStr.compare(" "))
|
||||||
|
{
|
||||||
// 空格
|
// 空格
|
||||||
splitMark = ",";
|
splitMark = ",";
|
||||||
}else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// 不是空格
|
// 不是空格
|
||||||
splitMark = splitMarkStr;
|
splitMark = splitMarkStr;
|
||||||
}
|
}
|
||||||
@ -227,10 +259,12 @@ int main(int argc, const char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version) {
|
if (version)
|
||||||
|
{
|
||||||
std::string versionInfo;
|
std::string versionInfo;
|
||||||
WXML::Compiler::GetVersionInfo(versionInfo, "global");
|
WXML::Compiler::GetVersionInfo(versionInfo, "global");
|
||||||
if (!outputFileName.empty()) {
|
if (!outputFileName.empty())
|
||||||
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
f = fopen(outputFileName.c_str(), "w");
|
f = fopen(outputFileName.c_str(), "w");
|
||||||
fprintf(f, "%s\n", versionInfo.c_str());
|
fprintf(f, "%s\n", versionInfo.c_str());
|
||||||
@ -238,17 +272,20 @@ int main(int argc, const char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileList.empty()) {
|
if (fileList.empty())
|
||||||
|
{
|
||||||
usage(argc, argv);
|
usage(argc, argv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReadFromStdin) {
|
if (isReadFromStdin)
|
||||||
|
{
|
||||||
string content;
|
string content;
|
||||||
readFile(0, content);
|
readFile(0, content);
|
||||||
fileContentMap[fileList[0]] = content;
|
fileContentMap[fileList[0]] = content;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
|
|
||||||
// 读取文件内容
|
// 读取文件内容
|
||||||
for (int i = 0; i < fileList.size(); i++)
|
for (int i = 0; i < fileList.size(); i++)
|
||||||
@ -257,7 +294,6 @@ int main(int argc, const char **argv) {
|
|||||||
readFile(fileList[i].c_str(), content);
|
readFile(fileList[i].c_str(), content);
|
||||||
fileContentMap[fileList[i]] = content;
|
fileContentMap[fileList[i]] = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 此if条件x64dbg得出
|
// 此if条件x64dbg得出
|
||||||
@ -313,7 +349,7 @@ int main(int argc, const char **argv) {
|
|||||||
map<string, string> outputMap1;
|
map<string, string> outputMap1;
|
||||||
map<string, string> outputMap2;
|
map<string, string> outputMap2;
|
||||||
map<string, vector<string>> vecFileContentMap2;
|
map<string, vector<string>> vecFileContentMap2;
|
||||||
const char off_5403C3[] = {'s','\0','e','\0'};
|
const char off_5403C3[] = {'s', '\0', 'e', '\0'};
|
||||||
int compilerResult = 0;
|
int compilerResult = 0;
|
||||||
string errorMessage;
|
string errorMessage;
|
||||||
|
|
||||||
@ -340,7 +376,16 @@ int main(int argc, const char **argv) {
|
|||||||
"boxofchocolate",
|
"boxofchocolate",
|
||||||
"$gdwx",
|
"$gdwx",
|
||||||
"f_");
|
"f_");
|
||||||
// while()
|
// while(!outputMap1.empty())
|
||||||
|
// {
|
||||||
|
// /**
|
||||||
|
// * v60可能值: 0xF30D70:0xF30DB8:"miniprogram_npm/miniprogram-recycle-view/recycle-view"
|
||||||
|
// */
|
||||||
|
// // if(v60 == "__COMMON__")
|
||||||
|
// // {
|
||||||
|
|
||||||
|
// // }
|
||||||
|
// }
|
||||||
|
|
||||||
// if()
|
// if()
|
||||||
if (1)
|
if (1)
|
||||||
@ -374,10 +419,11 @@ int main(int argc, const char **argv) {
|
|||||||
|
|
||||||
string dep = ";var __WXML_DEP__=__WXML_DEP__||{};";
|
string dep = ";var __WXML_DEP__=__WXML_DEP__||{};";
|
||||||
// TODO: 起始并不是0
|
// TODO: 起始并不是0
|
||||||
for (string j = ""; ; )
|
for (string j = "";;)
|
||||||
{
|
{
|
||||||
/* code */
|
/* code */
|
||||||
if (j == "") break;
|
if (j == "")
|
||||||
|
break;
|
||||||
|
|
||||||
if (j[11] != j[10])
|
if (j[11] != j[10])
|
||||||
{
|
{
|
||||||
@ -397,12 +443,14 @@ int main(int argc, const char **argv) {
|
|||||||
}
|
}
|
||||||
// ???
|
// ???
|
||||||
outputMap1["__COMMON__"].append("");
|
outputMap1["__COMMON__"].append("");
|
||||||
if (compilerResult) {
|
if (compilerResult)
|
||||||
|
{
|
||||||
// CompileLazy出现异常
|
// CompileLazy出现异常
|
||||||
// 标准错误输出
|
// 标准错误输出
|
||||||
fprintf(stderr, "Error %d: %s\n", 1, "123");
|
fprintf(stderr, "Error %d: %s\n", 1, "123");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
FILE *f = stdout;
|
FILE *f = stdout;
|
||||||
if (!outputFileName.empty())
|
if (!outputFileName.empty())
|
||||||
f = fopen(outputFileName.c_str(), "w");
|
f = fopen(outputFileName.c_str(), "w");
|
||||||
@ -411,10 +459,10 @@ int main(int argc, const char **argv) {
|
|||||||
fprintf(f, " {\"generateFunctionContent\":%s,\"generateFunctionName\":%s} ", "", "");
|
fprintf(f, " {\"generateFunctionContent\":%s,\"generateFunctionName\":%s} ", "", "");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
const char off_5403C3[] = { 's', '\0', 'e', '\0' };
|
{
|
||||||
|
const char off_5403C3[] = {'s', '\0', 'e', '\0'};
|
||||||
int compilerResult = 0;
|
int compilerResult = 0;
|
||||||
// compilerResult = WXML::Compiler::Compile(
|
// compilerResult = WXML::Compiler::Compile(
|
||||||
// v3,
|
// v3,
|
||||||
@ -438,17 +486,27 @@ int main(int argc, const char **argv) {
|
|||||||
// "$gdwx", // "$gdwx"
|
// "$gdwx", // "$gdwx"
|
||||||
// "f_"); // "f_"
|
// "f_"); // "f_"
|
||||||
FILE *f;
|
FILE *f;
|
||||||
if (compilerResult) {
|
if (compilerResult)
|
||||||
|
{
|
||||||
f = stderr;
|
f = stderr;
|
||||||
fprintf(f, "%s\n", "error...");
|
fprintf(f, "%s\n", "error...");
|
||||||
}else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
f = stdout;
|
f = stdout;
|
||||||
if (!outputFileName.empty()) {
|
if (!outputFileName.empty())
|
||||||
|
{
|
||||||
f = fopen(outputFileName.c_str(), "w");
|
f = fopen(outputFileName.c_str(), "w");
|
||||||
}
|
}
|
||||||
fprintf(f, "%s\n", "result...");
|
fprintf(f, "%s\n", "result...");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
std::cerr << e.what() << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -41,24 +41,22 @@ namespace WXML{
|
|||||||
for (auto it = fileContentMap.begin(); it != fileContentMap.end(); it++)
|
for (auto it = fileContentMap.begin(); it != fileContentMap.end(); it++)
|
||||||
{
|
{
|
||||||
/* code */
|
/* code */
|
||||||
int parseResult = 0;
|
// WXML::DOMLib::Parser parseResult = ParseSource(
|
||||||
// parseResult = WXML::Compiler::ParseSource(
|
// it->second, // 源码?a2
|
||||||
// it->second, // 源码?
|
// it->first, // 文件名 a3
|
||||||
// it->first, // 文件名
|
// lineEndMark, // '\n' a4
|
||||||
// "\n",// ?
|
// gwxMark, // gwxMark a5
|
||||||
// lineEndMark, // '\n'
|
// fMark, // "f_" a6
|
||||||
// gwxMark, // gwxMark
|
// fileContentMap, // fileContentMap a7
|
||||||
// fMark, // "f_"
|
// errorMessage, // 错误信息 a8
|
||||||
// fileContentMap, // fileContentMap
|
// &v304, // map<string, WXML::DOMLib::WXMLDom> a9
|
||||||
// errorMessage, // 错误信息
|
// &v309, // ??? a10
|
||||||
// &v304, // map<string, ?>
|
// &v311, // ??? a11
|
||||||
// &v309, // ???
|
// (mark & 4) != 0, // a11 -> mark a12
|
||||||
// &v311, // ???
|
// (mark & 0x20) != 0); // a13
|
||||||
// (mark & 4) != 0, // a11 -> mark
|
// if (parseResult) {
|
||||||
// (mark & 0x20) != 0);
|
// return parseResult;
|
||||||
if (parseResult) {
|
// }
|
||||||
return parseResult;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
std::shared_ptr<std::stringstream> v301_localCommonStream1; // v301
|
std::shared_ptr<std::stringstream> v301_localCommonStream1; // v301
|
||||||
ssDataMap["__COMMON__"] = v301_localCommonStream1;
|
ssDataMap["__COMMON__"] = v301_localCommonStream1;
|
||||||
@ -147,33 +145,34 @@ namespace WXML{
|
|||||||
}
|
}
|
||||||
|
|
||||||
WXML::DOMLib::Parser ParseSource(
|
WXML::DOMLib::Parser ParseSource(
|
||||||
std::string const& fileName, // 文件名?
|
std::string const& fileName, // 文件名?a2
|
||||||
std::string const& content, // 源码?
|
std::string const& content, // 源码?a3
|
||||||
char lineEndMark, // '\n'
|
char lineEndMark, // '\n' a4
|
||||||
std::string const& gwxMark, // gwxMark
|
std::string const& gwxMark, // gwxMark a5
|
||||||
std::string const& fMark, // "f_"
|
std::string const& fMark, // "f_" a6
|
||||||
std::map<std::string,std::string> const&, // fileContentMap
|
std::map<std::string,std::string> const&, // fileContentMap a7
|
||||||
std::string& errorMessage, // 错误信息
|
std::string& errorMessage, // 错误信息 a8
|
||||||
std::map<std::string,WXML::DOMLib::WXMLDom> result,// map<string, ?>
|
std::map<std::string, WXML::DOMLib::WXMLDom> result,// map<string, ?> a9
|
||||||
std::map<std::string,std::string>& map1,// ???
|
std::map<std::string,std::string>& map1,// ??? a10
|
||||||
std::map<std::string,int> map2, // ???
|
std::map<std::string,int> map2, // ??? a11
|
||||||
bool b1, // mark指定运算结果是否非0
|
bool b1, // mark指定运算结果是否非0 a12
|
||||||
bool b2) // mark指定运算结果是否非0
|
bool b2) // mark指定运算结果是否非0 a13
|
||||||
{
|
{
|
||||||
WXML::DOMLib::Parser pResult;
|
WXML::DOMLib::Parser pResult;
|
||||||
bool isWxml = fileName.substr(fileName.length() - 5) == ".wxml";
|
bool isWxml = fileName.substr(fileName.length() - 5) == ".wxml";
|
||||||
if (isWxml)
|
if (isWxml)
|
||||||
{
|
{
|
||||||
// parse
|
// parse
|
||||||
int parseResult = 0;
|
bool parseResult = false;
|
||||||
// pResult.Parse();
|
WXML::DOMLib::Parser v50;
|
||||||
if (parseResult)
|
std::vector<WXML::DOMLib::Token> tokenList; // v102
|
||||||
throw "";
|
parseResult = v50.Parse(content.c_str(), errorMessage, fileName, tokenList);
|
||||||
|
|
||||||
if (!parseResult)
|
if (parseResult)
|
||||||
{
|
{
|
||||||
// GetParsed
|
// GetParsed
|
||||||
// result[fileName] = ""
|
// WXML::DOMLib::WXMLDom parseDom = v50.GetParsed();
|
||||||
|
// result[fileName] = parseDom;
|
||||||
int a;
|
int a;
|
||||||
int b;
|
int b;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -22,12 +22,30 @@ namespace WXML
|
|||||||
}
|
}
|
||||||
bool Parser::Parse(
|
bool Parser::Parse(
|
||||||
char const* fileContent,
|
char const* fileContent,
|
||||||
std::string &,
|
std::string & a4,
|
||||||
std::string const&,
|
std::string const& a5,
|
||||||
std::vector<WXML::DOMLib::Token> &
|
std::vector<WXML::DOMLib::Token> & a6
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return true;
|
this->dequeStr.clear();
|
||||||
|
this->dequeDom.clear();
|
||||||
|
this->offset_128 = 4;
|
||||||
|
this->offset_328.assign(a5);
|
||||||
|
WXML::DOMLib::Tokenizer v15(fileContent, a5);
|
||||||
|
int ret = v15.GetTokens(this->offset_88, a4, a6);
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
std::shared_ptr<WXML::DOMLib::WXMLDom> domPtr;
|
||||||
|
dom.tag = "root";
|
||||||
|
domPtr.get()->tag = "root";
|
||||||
|
dequeDom.push_back(domPtr);
|
||||||
|
// DOMS
|
||||||
}
|
}
|
||||||
|
return ret == 0;
|
||||||
|
}
|
||||||
|
// WXML::DOMLib::WXMLDom Parser::GetParsed()
|
||||||
|
// {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,6 +24,16 @@ namespace WXML
|
|||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
std::string Token::ToString()
|
||||||
|
{
|
||||||
|
std::string v4 = "";
|
||||||
|
if (!this->offset_28)
|
||||||
|
{
|
||||||
|
v4 = this->offset_32.substr(this->offset_16, this->offset_20);
|
||||||
|
this->offset_28 = true;
|
||||||
|
}
|
||||||
|
return v4;
|
||||||
|
}
|
||||||
|
|
||||||
bool Token::IsMatch(char const&)
|
bool Token::IsMatch(char const&)
|
||||||
{
|
{
|
||||||
|
28
src/wxml/dom_lib/tokenizer.cpp
Normal file
28
src/wxml/dom_lib/tokenizer.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "../../include/wxml.h"
|
||||||
|
|
||||||
|
namespace WXML
|
||||||
|
{
|
||||||
|
namespace DOMLib
|
||||||
|
{
|
||||||
|
|
||||||
|
Tokenizer::Tokenizer(char const*,std::string const&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Tokenizer::Tokenizer(/* args */)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Tokenizer::~Tokenizer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
int Tokenizer::GetTokens(
|
||||||
|
std::vector<WXML::DOMLib::Token> &,
|
||||||
|
std::string &,
|
||||||
|
std::vector<WXML::DOMLib::Token> &
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -158,30 +158,30 @@ namespace WXML {
|
|||||||
std::string sc = WXML::Rewrite::ToStringCode(a2);
|
std::string sc = WXML::Rewrite::ToStringCode(a2);
|
||||||
a6 << sc << ":" << this->tag << ":" << this->offset_92 << ":" << this->offset_96 << "\")";
|
a6 << sc << ":" << this->tag << ":" << this->offset_92 << ":" << this->offset_96 << "\")";
|
||||||
}
|
}
|
||||||
if (this->type == "TEXTNODE")
|
if (this->tag == "TEXTNODE")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
if (this->type == "wx-define"
|
if (this->tag == "wx-define"
|
||||||
||this->type == "wx-import"
|
||this->tag == "wx-import"
|
||||||
||this->type == "import"
|
||this->tag == "import"
|
||||||
||this->type == "template")
|
||this->tag == "template")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
if (this->type == "wx-repeat")
|
if (this->tag == "wx-repeat")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
if (this->type == "block")
|
if (this->tag == "block")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
if (this->type == "include")
|
if (this->tag == "include")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
if (this->type == "wx-template")
|
if (this->tag == "wx-template")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -200,6 +200,101 @@ namespace WXML {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void WXMLDom::RecordAllPath(void)
|
||||||
|
{
|
||||||
|
if(this->tag == "import" || this->tag == "include")
|
||||||
|
{
|
||||||
|
std::string v13 = "src";
|
||||||
|
int v8 = this->offset_12.count(v13);
|
||||||
|
if (v8)
|
||||||
|
{
|
||||||
|
std::string attr = this->offset_12[v13].ToAttrContent();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void WXMLDom::Print(int,char const*,std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>> *)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void WXMLDom::PrintMe(
|
||||||
|
int a2,
|
||||||
|
char const* a3,
|
||||||
|
std::stringstream* a4)
|
||||||
|
{
|
||||||
|
std::stringstream v34;
|
||||||
|
std::stringstream *v4 = &v34;
|
||||||
|
if (a4)
|
||||||
|
{
|
||||||
|
v4 = a4;
|
||||||
|
}
|
||||||
|
if (v4->tellp() != 0)
|
||||||
|
{
|
||||||
|
printf("%s", a3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*v4 << a3;
|
||||||
|
}
|
||||||
|
for (int i = 0; ; i++)
|
||||||
|
{
|
||||||
|
/* code */
|
||||||
|
if ( i >= a2)
|
||||||
|
break;
|
||||||
|
if (v4->tellp())
|
||||||
|
{
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*v4 << " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (v4->tellp())
|
||||||
|
{
|
||||||
|
printf("pos: %d, %d, tag: %s, ", this->offset_92, this->offset_96, this->tag.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*v4 << "pos: " << this->offset_92 << ", " << this->offset_96 << " tag: " << this->tag << ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->tag == "TEXTNODE")
|
||||||
|
{
|
||||||
|
if (v4->tellp() != 0)
|
||||||
|
{
|
||||||
|
printf("attr: ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*v4 << "attr: ";
|
||||||
|
}
|
||||||
|
// TODO: this + 60是什么?
|
||||||
|
// for (size_t i = 0; i < count; i++)
|
||||||
|
// {
|
||||||
|
// /* code */
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(v4->tellp() != 0)
|
||||||
|
{
|
||||||
|
//TODO: this+84是什么?
|
||||||
|
printf(
|
||||||
|
"pos: %d, %d, len: %d, %s",
|
||||||
|
this->offset_92,
|
||||||
|
this->offset_96,
|
||||||
|
this->offset_104,
|
||||||
|
"TODO..."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*v4 << "pos: " << this->offset_92
|
||||||
|
<< ", " << this->offset_96 << ", len: " << this->offset_104
|
||||||
|
<< ", ";
|
||||||
|
// *v4 << this->offset_84;
|
||||||
|
}
|
||||||
|
}
|
||||||
bool WXMLDom::operator==(std::string tag)
|
bool WXMLDom::operator==(std::string tag)
|
||||||
{
|
{
|
||||||
return this->tag.compare(tag) == 0;
|
return this->tag.compare(tag) == 0;
|
||||||
|
20
test/test.cpp
Normal file
20
test/test.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char const *argv[])
|
||||||
|
{
|
||||||
|
std::deque<std::string> que;
|
||||||
|
que.push_back("123");
|
||||||
|
int i = 0;
|
||||||
|
while (que.begin() != que.end())
|
||||||
|
{
|
||||||
|
que.pop_back();
|
||||||
|
cout << "count: " << ++i << endl;
|
||||||
|
if (i > 100) break;
|
||||||
|
}
|
||||||
|
que.clear();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -23007,7 +23007,7 @@ void __usercall WXML::DOMLib::Parser::DOM(_DWORD *a1@<ecx>, WXML::DOMLib::Parser
|
|||||||
WXML::DOMLib::Parser::Error(exception, (WXML::DOMLib::Parser *)a1, "unexpected tag", 0);
|
WXML::DOMLib::Parser::Error(exception, (WXML::DOMLib::Parser *)a1, "unexpected tag", 0);
|
||||||
__cxa_throw(
|
__cxa_throw(
|
||||||
exception,
|
exception,
|
||||||
(struct type_info *)&`typeinfo for'WXML::DOMLib::ParseException,
|
(struct type_info *)&`typeinfo for WXML::DOMLib::ParseException,
|
||||||
WXML::DOMLib::ParseException::~ParseException);
|
WXML::DOMLib::ParseException::~ParseException);
|
||||||
}
|
}
|
||||||
++a1[25];
|
++a1[25];
|
||||||
@ -23056,7 +23056,7 @@ void __usercall WXML::DOMLib::Parser::DOM(_DWORD *a1@<ecx>, WXML::DOMLib::Parser
|
|||||||
(WXML::DOMLib::Token *)&v45);
|
(WXML::DOMLib::Token *)&v45);
|
||||||
__cxa_throw(
|
__cxa_throw(
|
||||||
v31,
|
v31,
|
||||||
(struct type_info *)&`typeinfo for'WXML::DOMLib::ParseException,
|
(struct type_info *)&`typeinfo for WXML::DOMLib::ParseException,
|
||||||
WXML::DOMLib::ParseException::~ParseException);
|
WXML::DOMLib::ParseException::~ParseException);
|
||||||
}
|
}
|
||||||
++a1[25];
|
++a1[25];
|
||||||
@ -23083,7 +23083,7 @@ void __usercall WXML::DOMLib::Parser::DOM(_DWORD *a1@<ecx>, WXML::DOMLib::Parser
|
|||||||
WXML::DOMLib::Parser::Error(v30, (WXML::DOMLib::Parser *)a1, v41, 0);
|
WXML::DOMLib::Parser::Error(v30, (WXML::DOMLib::Parser *)a1, v41, 0);
|
||||||
__cxa_throw(
|
__cxa_throw(
|
||||||
v30,
|
v30,
|
||||||
(struct type_info *)&`typeinfo for'WXML::DOMLib::ParseException,
|
(struct type_info *)&`typeinfo for WXML::DOMLib::ParseException,
|
||||||
WXML::DOMLib::ParseException::~ParseException);
|
WXML::DOMLib::ParseException::~ParseException);
|
||||||
}
|
}
|
||||||
++a1[25];
|
++a1[25];
|
||||||
@ -23515,7 +23515,7 @@ int __cdecl WXML::DOMLib::WXMLDom::DealSingleTokenToOps(
|
|||||||
std::string::_M_dispose(&Block);
|
std::string::_M_dispose(&Block);
|
||||||
__cxa_throw(
|
__cxa_throw(
|
||||||
exception,
|
exception,
|
||||||
(struct type_info *)&`typeinfo for'WXML::DOMLib::RenderException,
|
(struct type_info *)&`typeinfo for WXML::DOMLib::RenderException,
|
||||||
WXML::DOMLib::RenderException::~RenderException);
|
WXML::DOMLib::RenderException::~RenderException);
|
||||||
}
|
}
|
||||||
if ( a8 )
|
if ( a8 )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user