fix: Machine::Feed逻辑

This commit is contained in:
msojocs 2023-07-01 10:10:56 +08:00
parent 4b4d792c92
commit 8fd49dc4c9
5 changed files with 74 additions and 27 deletions

View File

@ -189,7 +189,7 @@ namespace WXML
~Machine();
void Reset(void);
void InitTransitTable(void);
void Feed(char,std::vector<WXML::DOMLib::Token> &,std::string &,std::vector<WXML::DOMLib::Token> &,int);
int Feed(char,std::vector<WXML::DOMLib::Token> &,std::string &,std::vector<WXML::DOMLib::Token> &,int);
};
@ -317,6 +317,7 @@ namespace WXML
bool operator==(std::string tag);
std::string ToCamelStyle(std::string const&);
void AddTestAttr(std::string const&, std::stringstream &, char);
bool HasSpAttrPrefix(void);
};

View File

@ -295,9 +295,8 @@ namespace WXML
this->STT[ (0x5665E0 - 0x00566560)/4] = 3;
}
}
int dword_567960[1000] = {0};
void Machine::Feed(
int Machine::Feed(
char inputChar,
std::vector<WXML::DOMLib::Token> & a3,
std::string &errorMessage,
@ -321,14 +320,15 @@ namespace WXML
v46 = this->TT[257 * v45 + inputChar];
if (!v46)
{
v46 = dword_567960[257 * v45];
v46 = this->TT[ (0x567960 - 0x00567560)/4 + 257 * v45];
if(!v46)
{
std::stringstream ss;
ss << "BAD STATE MACHINE! AT INPUT ";
ss << this->offset_24 << " " << inputChar;
errorMessage = ss.str();
return;
throw errorMessage;
// return;
}
}
if (v46 < 0)
@ -346,7 +346,7 @@ namespace WXML
ss << "unexpected end";
}
errorMessage = ss.str();
return;
throw errorMessage;
}
this->offset_24 = (uint16_t)v46;
if (bittest(&v46, 0x15u)) // 0x15 -> 21
@ -408,11 +408,12 @@ namespace WXML
WXML::DOMLib::Token v49;
v49.offset_8 = this->offset_16;
v49.offset_12 = this->offset_20;
auto t4 = this->offset_4;
this->offset_4 = this->fileLength;
this->offset_20 = this->lineLength;
this->offset_16 = this->lineCount;
v49.offset_16 = this->offset_4;
v49.offset_20 = this->lineLength + 1 - this->offset_4;
v49.offset_16 = t4;
v49.offset_20 = this->fileLength - t4;
int stt = WXML::DOMLib::Machine::STT[v45];
v49.offset_24 = stt;
if (stt == 3)
@ -430,12 +431,14 @@ namespace WXML
offset_4 = fileLength;
offset_20 = lineLength;
}
return;
return 0;
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
return -1;
}
return 0;
}
void Machine::Reset()

View File

@ -210,6 +210,7 @@ namespace WXML
int v17 = 0;
// TODO v18 = *v16 + v43[4];
char* v18 = &v16[0] + token.offset_16;
// offset_20第一次是3
while(token.offset_20 > v17)
{
int v19 = *(uint8_t *)(v18 + v17) - 9;

View File

@ -843,7 +843,7 @@ namespace WXML {
}
if (!hasIf)
{
int v7 = a2 - 1;
int v11 = a2 - 1;
if(this->offset_48.begin() == this->offset_48.end())
{
for (int i = a2 + 1; i < this->offset_48.size(); i++)
@ -857,13 +857,21 @@ namespace WXML {
{
break;
}
// a3[1].find()
// TODO...
if(
a3.end() != std::find(a3.begin(), a3.end(), this->offset_72[i]->offset_0)
|| this->offset_72[i]->offset_72.begin() != this->offset_72[i]->offset_72.end()
)
{
return hasElIf;
}
v11 = i;
}
}
while (v11 >= a2)
this->offset_72.erase(this->offset_72.begin() + v11--);
return true;
}
return true;
}
bool WXMLDom::operator==(std::string tag)
{
@ -891,5 +899,37 @@ namespace WXML {
v15 << " with message: " << a5 << ".";
return v15.str();
}
bool WXMLDom::HasSpAttrPrefix()
{
for (auto i = this->offset_48.begin(); i != this->offset_48.end(); i++)
{
auto v3 = i->first.data();
if (strncmp(v3, "bind", 4u))
{
if ( strncmp(v3, "catch", 5u) )
{
if ( strncmp(v3, "capture-bind", 0xCu) )
{
if ( strncmp(v3, "capture-catch", 0xDu) )
{
if ( i->first != "slot" )
{
if ( strncmp(v3, "wx:", 3u) )
{
if ( strncmp(v3, "mark:", 5u) )
continue;
}
}
}
}
}
}
return true;
}
return false;
}
}
}

View File

@ -27125,7 +27125,7 @@ LABEL_12:
// this
v31 = lpuexcpt;
// offset_0 + 1 lineCount
// offset_0 + 1 fileLength
v32 = *(_DWORD *)lpuexcpt + 1;
// offset_12 + 1 lineLength
v33 = *((_DWORD *)lpuexcpt + 3) + 1;
@ -27139,23 +27139,23 @@ LABEL_12:
v57 = v59;
v61 = v63;
v65 = v67;
// offset_16
// this->offset_16
v35 = *((_DWORD *)v31 + 4);
// offset_0
// v49.offset_0
v49 = 0;
// offset_8 = this->offset_16
// v49.offset_8 = this->offset_16
v51 = v35;
// offset_20
// this->offset_20
v36 = *((_DWORD *)v31 + 5);
// offset_4
// v49.offset_4
v50 = 0;
// token.offset_12 = this->offset_20
v52 = v36;
// this.offset_4
// v37 = this.offset_4
v37 = *((_DWORD *)v31 + 1);
// this.offset_4 = this.offset_4 + 1
// this.offset_4 = this.offset_0 + 1 = this->fileLength
*((_DWORD *)v31 + 1) = v32;
// this.offset_8
// this.offset_8(lineCount)
v38 = *((_DWORD *)v31 + 2);
// this.offset_20 = this.offset_12(lineLength)
*((_DWORD *)v31 + 5) = v33;
@ -27172,9 +27172,9 @@ LABEL_12:
v56 = 0;
v64 = 0;
v60 = -1;
// offset_16 = this->offset_4
// token.offset_16 = this->offset_4
v53 = v37;
// offset_20 = - this->offset_4
// v49.offset_20 = (this->offset_0 + 1)fileLength - this->offset_4
v54 = v34 - v37;
if ( v39 == 3 )
v40 = a5;
@ -52736,10 +52736,12 @@ char __thiscall WXML::DOMLib::WXMLDom::IfHasItsElse(_DWORD *this, signed int a2,
std::string::_M_dispose(v23);
if ( !v18 )
break;
v12 = a3[1];
v12 = a3[1]; // a3.offset_4
if ( v12 != std::find<__gnu_cxx::__normal_iterator<std::string const*,std::vector<std::string>>,std::string>(
*a3,
v12,
*a3, // start
v12, // end
// this->offset_(18 * 4) -> this->offset_72
// this->offset_72[i]
*(_DWORD *)(this[18] + v10))
|| *(_DWORD *)(*(_DWORD *)(this[18] + v10) + 76) != *(_DWORD *)(*(_DWORD *)(this[18] + v10) + 72) )
{