feat: 完善DealWxsTag

This commit is contained in:
msojocs 2023-07-18 08:12:51 +08:00
parent 0b2c3371b3
commit d18694c8df
5 changed files with 82 additions and 22 deletions

View File

@ -40,7 +40,7 @@ namespace night
extern std::string std_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 readfile(char const*, std::string &);
void writefile(char const*, std::string &);

View File

@ -381,7 +381,6 @@ namespace WXML
{
private:
/* data */
std::shared_ptr<WXML::DOMLib::WXMLDom> dom; // offset_4 ?
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::vector<WXML::DOMLib::Token> tokenList; // offset_88
@ -391,6 +390,7 @@ namespace WXML
WXML::DOMLib::Token offset_216;
std::string filePath;
public:
std::shared_ptr<WXML::DOMLib::WXMLDom> dom; // offset_72
Parser(/* args */);
~Parser();
void Match();

View File

@ -36,7 +36,7 @@ namespace night
std::string std_v_n = "";
std::string std_v_v_n = "";
void compile_ns(
int compile_ns(
std::string const& a1,
std::string const& a2,
std::string const& a3,
@ -51,7 +51,7 @@ namespace night
night::NSASTParse v39(a1, &v27, &v17);
v17.hamlet();
return 0;
}
void compile_ns_with_sourcemap(

View File

@ -124,8 +124,7 @@ namespace WXML{
data = data.append(v74);
auto v83 = WXML::Compiler::GetFuncId(a11, data);
std::string v72;
night::compile_ns(filePath, v83, v79, v65, v72, 0);
int compilerResult = 1;
int compilerResult = night::compile_ns(filePath, v83, v79, v65, v72, 0);
if (compilerResult)
{
throw compilerResult;
@ -815,23 +814,29 @@ namespace WXML{
int * a6,
std::string& errorMessage)
{
// DealWxsTag - 0
std::string content = a2.GetContent();
int pos = content.find('>', content[4]);
int tokenPos = a2.GetPos();
int pos = content.find('>', tokenPos);
int tokenSize = a2.GetSize();
std::string sub;
if (content[pos - 1] == '/')
{
// 这个尖括号附近是这样的:/>
sub = content.substr(tokenPos + 1, pos + 1 - tokenPos - 6);
sub = content.substr(tokenPos + 4, pos + 1 - tokenPos - 6);
}
else
{
sub = content.substr(tokenPos + 1, pos + 1 - tokenPos - 5);
sub = content.substr(tokenPos + 4, pos + 1 - tokenPos - 5);
}
std::string data = "<fak";
data = data.append(sub);
data = data.append("/>");
/*
....<fak module=
"refresh"/>.....
*/
// DealWxsTag - 5
for (int i = 1; i < a2.offset_8; i++)
{
data = "\n" + data;
@ -842,8 +847,9 @@ namespace WXML{
}
WXML::DOMLib::Parser p;
std::vector<WXML::DOMLib::Token> v50;
bool parseResult = p.Parse(&content[0], errorMessage, filePath, v50);
if (!parseResult)
bool parseResult = p.Parse(data.data(), errorMessage, filePath, v50);
// DealWxsTag - 10
if (parseResult)
{
auto dom = p.GetParsed();
*a6 = a2.offset_8;
@ -857,7 +863,6 @@ namespace WXML{
int v41 = 1;
for (int i = 0; i < a5.length(); i++)
{
/* code */
int v14 = a5[i] - 9;
if (v14 > 0x17u)
{
@ -871,11 +876,59 @@ 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 1;
}
void GetVersionInfo(std::string &a1, std::string a2)
{

View File

@ -10888,6 +10888,7 @@ int __cdecl WXML::Compiler::DealWxsTag(
char v66[196]; // [esp+19Ch] [ebp-23Ch] BYREF
void *v67[94]; // [esp+260h] [ebp-178h] BYREF
// DealWxsTag - 0
lpuexcptc = std::string::find(*a2, '>'/*62*/, (unsigned int)a2[4]);
// a2.find('>')
v40 = (unsigned int)(lpuexcptc + 1);
@ -10901,6 +10902,8 @@ int __cdecl WXML::Compiler::DealWxsTag(
v9 = *a2;
if ( v7 )
{
// int * v8
// v8 -> a2.offset_16
std::string::substr(v55, v9, (unsigned int)(v8 + 1), v40 - (_DWORD)v8 - 6);
std::string::operator=((unsigned __int8 **)v53, (int)v55);
v10 = (void **)v55;
@ -10912,12 +10915,13 @@ int __cdecl WXML::Compiler::DealWxsTag(
v10 = (void **)v56;
}
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);
v11 = std::string::append(v67, (int)v52);
v11 = std::string::append(v67, (int)v52); // "/>"
std::string::basic_string(v56, v11);
v37 = v12;
std::string::_M_dispose(v67);
// DealWxsTag - 5
// a2[2] = a2.offset_8
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);
memset(v50, 0, sizeof(v50));
lpuexcptb = WXML::DOMLib::Parser::Parse((int)v67, (WXML::DOMLib::Parser *)lpuexcpta, (char *)v56[0], (int)a7, a1, v50);
// DealWxsTag - 10
if ( !lpuexcptb )
{
WXML::DOMLib::Parser::GetParsed(&v48, (WXML::DOMLib::Parser *)v67);
@ -10970,13 +10976,14 @@ int __cdecl WXML::Compiler::DealWxsTag(
// for end
// v48 int
// v48 -> p
// v48 + 72 => v48.offset_72
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);
std::string::_M_dispose(v60);
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),
v17 = WXML::DOMLib::Token::ToAttrContent[abi:cxx11]((int)v16),
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_dispose(v64);
v25 = (_BYTE *)*a3;
v26 = (unsigned __int8)(*(_BYTE *)*a3 - 48) > 9u;
v26 = (unsigned __int8)(*(_BYTE *)*a3 - '0'/*48*/) > 9u;
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 )
v27 = *v25 == 95 || (unsigned __int8)(*v25 - 65) <= 0x19u;
v27 = *v25 == '_'/*95*/ || (unsigned __int8)(*v25 - 'A'/*65*/) <= 0x19u;
v26 &= v27;
++v25;
}
if ( v26 )
goto LABEL_35;
goto LABEL_35; // 销毁数据,返回
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>>::basic_stringstream((int)v64);
std::operator+<char>((char *)v63, a1, ":");
std::operator<<<char>((std::ostream::sentry *)v65, v63);