mirror of
https://github.com/msojocs/wx-compiler.git
synced 2025-07-19 00:00:04 +08:00
feat: 完善DealWxsTag
This commit is contained in:
parent
0b2c3371b3
commit
d18694c8df
@ -40,7 +40,7 @@ namespace night
|
|||||||
extern std::string std_v_n;
|
extern std::string std_v_n;
|
||||||
extern std::string std_v_v_n;
|
extern std::string std_v_v_n;
|
||||||
|
|
||||||
void compile_ns(std::string const&,std::string const&,std::string const&,uint,std::string&,bool);
|
int compile_ns(std::string const&,std::string const&,std::string const&,uint,std::string&,bool);
|
||||||
void compile_ns_with_sourcemap(std::string const&,std::string const&,std::string const&,std::string const&,uint,std::string&,std::string&);
|
void compile_ns_with_sourcemap(std::string const&,std::string const&,std::string const&,std::string const&,uint,std::string&,std::string&);
|
||||||
void readfile(char const*, std::string &);
|
void readfile(char const*, std::string &);
|
||||||
void writefile(char const*, std::string &);
|
void writefile(char const*, std::string &);
|
||||||
|
@ -381,7 +381,6 @@ namespace WXML
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
std::shared_ptr<WXML::DOMLib::WXMLDom> dom; // offset_4 ?
|
|
||||||
std::deque<std::string> dequeStr;// offset_8
|
std::deque<std::string> dequeStr;// offset_8
|
||||||
std::deque<std::shared_ptr<WXML::DOMLib::WXMLDom>> dequeDom; // offset_48 int a1 + 48, _DWORD * a1 + 12
|
std::deque<std::shared_ptr<WXML::DOMLib::WXMLDom>> dequeDom; // offset_48 int a1 + 48, _DWORD * a1 + 12
|
||||||
std::vector<WXML::DOMLib::Token> tokenList; // offset_88
|
std::vector<WXML::DOMLib::Token> tokenList; // offset_88
|
||||||
@ -391,6 +390,7 @@ namespace WXML
|
|||||||
WXML::DOMLib::Token offset_216;
|
WXML::DOMLib::Token offset_216;
|
||||||
std::string filePath;
|
std::string filePath;
|
||||||
public:
|
public:
|
||||||
|
std::shared_ptr<WXML::DOMLib::WXMLDom> dom; // offset_72
|
||||||
Parser(/* args */);
|
Parser(/* args */);
|
||||||
~Parser();
|
~Parser();
|
||||||
void Match();
|
void Match();
|
||||||
|
@ -36,7 +36,7 @@ namespace night
|
|||||||
std::string std_v_n = "";
|
std::string std_v_n = "";
|
||||||
std::string std_v_v_n = "";
|
std::string std_v_v_n = "";
|
||||||
|
|
||||||
void compile_ns(
|
int compile_ns(
|
||||||
std::string const& a1,
|
std::string const& a1,
|
||||||
std::string const& a2,
|
std::string const& a2,
|
||||||
std::string const& a3,
|
std::string const& a3,
|
||||||
@ -51,7 +51,7 @@ namespace night
|
|||||||
night::NSASTParse v39(a1, &v27, &v17);
|
night::NSASTParse v39(a1, &v27, &v17);
|
||||||
|
|
||||||
v17.hamlet();
|
v17.hamlet();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void compile_ns_with_sourcemap(
|
void compile_ns_with_sourcemap(
|
||||||
|
@ -124,8 +124,7 @@ namespace WXML{
|
|||||||
data = data.append(v74);
|
data = data.append(v74);
|
||||||
auto v83 = WXML::Compiler::GetFuncId(a11, data);
|
auto v83 = WXML::Compiler::GetFuncId(a11, data);
|
||||||
std::string v72;
|
std::string v72;
|
||||||
night::compile_ns(filePath, v83, v79, v65, v72, 0);
|
int compilerResult = night::compile_ns(filePath, v83, v79, v65, v72, 0);
|
||||||
int compilerResult = 1;
|
|
||||||
if (compilerResult)
|
if (compilerResult)
|
||||||
{
|
{
|
||||||
throw compilerResult;
|
throw compilerResult;
|
||||||
@ -815,23 +814,29 @@ namespace WXML{
|
|||||||
int * a6,
|
int * a6,
|
||||||
std::string& errorMessage)
|
std::string& errorMessage)
|
||||||
{
|
{
|
||||||
|
// DealWxsTag - 0
|
||||||
std::string content = a2.GetContent();
|
std::string content = a2.GetContent();
|
||||||
int pos = content.find('>', content[4]);
|
|
||||||
int tokenPos = a2.GetPos();
|
int tokenPos = a2.GetPos();
|
||||||
|
int pos = content.find('>', tokenPos);
|
||||||
int tokenSize = a2.GetSize();
|
int tokenSize = a2.GetSize();
|
||||||
std::string sub;
|
std::string sub;
|
||||||
if (content[pos - 1] == '/')
|
if (content[pos - 1] == '/')
|
||||||
{
|
{
|
||||||
// 这个尖括号附近是这样的:/>
|
// 这个尖括号附近是这样的:/>
|
||||||
sub = content.substr(tokenPos + 1, pos + 1 - tokenPos - 6);
|
sub = content.substr(tokenPos + 4, pos + 1 - tokenPos - 6);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sub = content.substr(tokenPos + 1, pos + 1 - tokenPos - 5);
|
sub = content.substr(tokenPos + 4, pos + 1 - tokenPos - 5);
|
||||||
}
|
}
|
||||||
std::string data = "<fak";
|
std::string data = "<fak";
|
||||||
data = data.append(sub);
|
data = data.append(sub);
|
||||||
data = data.append("/>");
|
data = data.append("/>");
|
||||||
|
/*
|
||||||
|
....<fak module=
|
||||||
|
"refresh"/>.....
|
||||||
|
*/
|
||||||
|
// DealWxsTag - 5
|
||||||
for (int i = 1; i < a2.offset_8; i++)
|
for (int i = 1; i < a2.offset_8; i++)
|
||||||
{
|
{
|
||||||
data = "\n" + data;
|
data = "\n" + data;
|
||||||
@ -842,8 +847,9 @@ namespace WXML{
|
|||||||
}
|
}
|
||||||
WXML::DOMLib::Parser p;
|
WXML::DOMLib::Parser p;
|
||||||
std::vector<WXML::DOMLib::Token> v50;
|
std::vector<WXML::DOMLib::Token> v50;
|
||||||
bool parseResult = p.Parse(&content[0], errorMessage, filePath, v50);
|
bool parseResult = p.Parse(data.data(), errorMessage, filePath, v50);
|
||||||
if (!parseResult)
|
// DealWxsTag - 10
|
||||||
|
if (parseResult)
|
||||||
{
|
{
|
||||||
auto dom = p.GetParsed();
|
auto dom = p.GetParsed();
|
||||||
*a6 = a2.offset_8;
|
*a6 = a2.offset_8;
|
||||||
@ -857,7 +863,6 @@ namespace WXML{
|
|||||||
int v41 = 1;
|
int v41 = 1;
|
||||||
for (int i = 0; i < a5.length(); i++)
|
for (int i = 0; i < a5.length(); i++)
|
||||||
{
|
{
|
||||||
/* code */
|
|
||||||
int v14 = a5[i] - 9;
|
int v14 = a5[i] - 9;
|
||||||
if (v14 > 0x17u)
|
if (v14 > 0x17u)
|
||||||
{
|
{
|
||||||
@ -871,10 +876,58 @@ namespace WXML{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO....
|
int v39 = dom->offset_72[0]->offset_48.count("src");
|
||||||
|
if (v39)
|
||||||
|
{
|
||||||
|
auto v16 = dom->offset_72[0]->offset_48["src"];
|
||||||
|
a4 = v16.ToAttrContent();
|
||||||
|
}
|
||||||
|
if (!v39 || v41)
|
||||||
|
{
|
||||||
|
auto v42 = dom->offset_72[0]->offset_48;
|
||||||
|
if (v42.count("module"))
|
||||||
|
{
|
||||||
|
auto v23 = v42["module"];
|
||||||
|
std::string v24 = v23.ToAttrContent();
|
||||||
|
a3.assign(v24);
|
||||||
|
// 检查字符串命名格式是否正确
|
||||||
|
for (auto &&i : v24)
|
||||||
|
{
|
||||||
|
bool v27 = i - 'a' <= 0x19u || i - '0' <= 9u;
|
||||||
|
if (!v27)
|
||||||
|
{
|
||||||
|
v27 = i == '_' || i - 'A' <= 0x19u;
|
||||||
|
}
|
||||||
|
if (!v27)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << filePath << ":" << a2.offset_8 << ":" << a2.offset_12 << ":" << errorMessage;
|
||||||
|
ss << "invalid module name, [0-9a-zA-Z_] allowed only";
|
||||||
|
errorMessage = ss.str();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << filePath << ":" << a2.offset_8 << ":" << a2.offset_12 << ":" << errorMessage;
|
||||||
|
ss << "module expected in wxs tag";
|
||||||
|
errorMessage = ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << filePath << ":" << a2.offset_8 << ":" << a2.offset_12 << ":" << errorMessage;
|
||||||
|
ss << "wxs tag with src don't need any content";
|
||||||
|
errorMessage = ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetVersionInfo(std::string &a1, std::string a2)
|
void GetVersionInfo(std::string &a1, std::string a2)
|
||||||
|
@ -10888,6 +10888,7 @@ int __cdecl WXML::Compiler::DealWxsTag(
|
|||||||
char v66[196]; // [esp+19Ch] [ebp-23Ch] BYREF
|
char v66[196]; // [esp+19Ch] [ebp-23Ch] BYREF
|
||||||
void *v67[94]; // [esp+260h] [ebp-178h] BYREF
|
void *v67[94]; // [esp+260h] [ebp-178h] BYREF
|
||||||
|
|
||||||
|
// DealWxsTag - 0
|
||||||
lpuexcptc = std::string::find(*a2, '>'/*62*/, (unsigned int)a2[4]);
|
lpuexcptc = std::string::find(*a2, '>'/*62*/, (unsigned int)a2[4]);
|
||||||
// a2.find('>')
|
// a2.find('>')
|
||||||
v40 = (unsigned int)(lpuexcptc + 1);
|
v40 = (unsigned int)(lpuexcptc + 1);
|
||||||
@ -10901,6 +10902,8 @@ int __cdecl WXML::Compiler::DealWxsTag(
|
|||||||
v9 = *a2;
|
v9 = *a2;
|
||||||
if ( v7 )
|
if ( v7 )
|
||||||
{
|
{
|
||||||
|
// int * v8
|
||||||
|
// v8 -> a2.offset_16
|
||||||
std::string::substr(v55, v9, (unsigned int)(v8 + 1), v40 - (_DWORD)v8 - 6);
|
std::string::substr(v55, v9, (unsigned int)(v8 + 1), v40 - (_DWORD)v8 - 6);
|
||||||
std::string::operator=((unsigned __int8 **)v53, (int)v55);
|
std::string::operator=((unsigned __int8 **)v53, (int)v55);
|
||||||
v10 = (void **)v55;
|
v10 = (void **)v55;
|
||||||
@ -10912,12 +10915,13 @@ int __cdecl WXML::Compiler::DealWxsTag(
|
|||||||
v10 = (void **)v56;
|
v10 = (void **)v56;
|
||||||
}
|
}
|
||||||
std::string::_M_dispose(v10);
|
std::string::_M_dispose(v10);
|
||||||
std::string::basic_string((char *)v67, (int)v51);
|
std::string::basic_string((char *)v67, (int)v51); // "<fak"
|
||||||
std::string::append(v67, (int)v53);
|
std::string::append(v67, (int)v53);
|
||||||
v11 = std::string::append(v67, (int)v52);
|
v11 = std::string::append(v67, (int)v52); // "/>"
|
||||||
std::string::basic_string(v56, v11);
|
std::string::basic_string(v56, v11);
|
||||||
v37 = v12;
|
v37 = v12;
|
||||||
std::string::_M_dispose(v67);
|
std::string::_M_dispose(v67);
|
||||||
|
// DealWxsTag - 5
|
||||||
// a2[2] = a2.offset_8
|
// a2[2] = a2.offset_8
|
||||||
for ( lpuexcpt = 1; (int)a2[2] > lpuexcpt; ++lpuexcpt )
|
for ( lpuexcpt = 1; (int)a2[2] > lpuexcpt; ++lpuexcpt )
|
||||||
{
|
{
|
||||||
@ -10935,6 +10939,8 @@ int __cdecl WXML::Compiler::DealWxsTag(
|
|||||||
WXML::DOMLib::Parser::Parser((WXML::DOMLib::Parser *)v37);
|
WXML::DOMLib::Parser::Parser((WXML::DOMLib::Parser *)v37);
|
||||||
memset(v50, 0, sizeof(v50));
|
memset(v50, 0, sizeof(v50));
|
||||||
lpuexcptb = WXML::DOMLib::Parser::Parse((int)v67, (WXML::DOMLib::Parser *)lpuexcpta, (char *)v56[0], (int)a7, a1, v50);
|
lpuexcptb = WXML::DOMLib::Parser::Parse((int)v67, (WXML::DOMLib::Parser *)lpuexcpta, (char *)v56[0], (int)a7, a1, v50);
|
||||||
|
|
||||||
|
// DealWxsTag - 10
|
||||||
if ( !lpuexcptb )
|
if ( !lpuexcptb )
|
||||||
{
|
{
|
||||||
WXML::DOMLib::Parser::GetParsed(&v48, (WXML::DOMLib::Parser *)v67);
|
WXML::DOMLib::Parser::GetParsed(&v48, (WXML::DOMLib::Parser *)v67);
|
||||||
@ -10970,13 +10976,14 @@ int __cdecl WXML::Compiler::DealWxsTag(
|
|||||||
// for end
|
// for end
|
||||||
|
|
||||||
// v48 int
|
// v48 int
|
||||||
|
// v48 -> p
|
||||||
// v48 + 72 => v48.offset_72
|
// v48 + 72 => v48.offset_72
|
||||||
v38 = (_DWORD *)(**(_DWORD **)(v48 + 72) + 48);
|
v38 = (_DWORD *)(**(_DWORD **)(v48 + 72) + 48);
|
||||||
std::string::basic_string(v60, (char *)off_547B7D);
|
std::string::basic_string(v60, (char *)off_547B7D); // src
|
||||||
v39 = std::map<std::string,WXML::DOMLib::Token>::count(v38, (int)v60);
|
v39 = std::map<std::string,WXML::DOMLib::Token>::count(v38, (int)v60);
|
||||||
std::string::_M_dispose(v60);
|
std::string::_M_dispose(v60);
|
||||||
if ( !v39
|
if ( !v39
|
||||||
|| (std::string::basic_string(v64, (char *)off_547B7D),
|
|| (std::string::basic_string(v64, (char *)off_547B7D), // src
|
||||||
v16 = std::map<std::string,WXML::DOMLib::Token>::operator[]((_DWORD *)(**(_DWORD **)(v48 + 72) + 48), v64),
|
v16 = std::map<std::string,WXML::DOMLib::Token>::operator[]((_DWORD *)(**(_DWORD **)(v48 + 72) + 48), v64),
|
||||||
v17 = WXML::DOMLib::Token::ToAttrContent[abi:cxx11]((int)v16),
|
v17 = WXML::DOMLib::Token::ToAttrContent[abi:cxx11]((int)v16),
|
||||||
std::string::_M_assign(a4, v17),
|
std::string::_M_assign(a4, v17),
|
||||||
@ -10995,17 +11002,17 @@ int __cdecl WXML::Compiler::DealWxsTag(
|
|||||||
std::string::_M_assign((int)a3, v24);
|
std::string::_M_assign((int)a3, v24);
|
||||||
std::string::_M_dispose(v64);
|
std::string::_M_dispose(v64);
|
||||||
v25 = (_BYTE *)*a3;
|
v25 = (_BYTE *)*a3;
|
||||||
v26 = (unsigned __int8)(*(_BYTE *)*a3 - 48) > 9u;
|
v26 = (unsigned __int8)(*(_BYTE *)*a3 - '0'/*48*/) > 9u;
|
||||||
while ( (_BYTE *)(*a3 + a3[1]) != v25 )
|
while ( (_BYTE *)(*a3 + a3[1]) != v25 )
|
||||||
{
|
{
|
||||||
v27 = (unsigned __int8)(*v25 - 97) <= 0x19u || (unsigned __int8)(*v25 - 48) <= 9u;
|
v27 = (unsigned __int8)(*v25 - 'a'/*97*/) <= 0x19u || (unsigned __int8)(*v25 - '0'/*48*/) <= 9u;
|
||||||
if ( !v27 )
|
if ( !v27 )
|
||||||
v27 = *v25 == 95 || (unsigned __int8)(*v25 - 65) <= 0x19u;
|
v27 = *v25 == '_'/*95*/ || (unsigned __int8)(*v25 - 'A'/*65*/) <= 0x19u;
|
||||||
v26 &= v27;
|
v26 &= v27;
|
||||||
++v25;
|
++v25;
|
||||||
}
|
}
|
||||||
if ( v26 )
|
if ( v26 )
|
||||||
goto LABEL_35;
|
goto LABEL_35; // 销毁数据,返回
|
||||||
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream((int)v64);
|
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream((int)v64);
|
||||||
std::operator+<char>((char *)v63, a1, ":");
|
std::operator+<char>((char *)v63, a1, ":");
|
||||||
std::operator<<<char>((std::ostream::sentry *)v65, v63);
|
std::operator<<<char>((std::ostream::sentry *)v65, v63);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user