feat: 添加一些方法

This commit is contained in:
msojocs 2023-07-23 22:55:17 +08:00
parent 983bf658a6
commit 4a46920418
4 changed files with 234 additions and 50 deletions

View File

@ -72,8 +72,14 @@ namespace night
std::string offset_156;
night::ns_node * offset_180 = nullptr;
night::ns_node * offset_184 = nullptr;
night::ns_node * offset_188 = nullptr;
night::ns_node * offset_192 = nullptr;
std::vector<night::ns_node *>* offset_196 = nullptr;
bool offset_200 = false;
night::ns_node * offset_204 = nullptr;
night::ns_node * offset_216 = nullptr;
night::ns_node * offset_220 = nullptr;
std::vector<std::vector<night::ns_node *>*> offset_224;
std::vector<night::ns_node *>* offset_228 = nullptr;
ns_node(/* args */);
~ns_node();
@ -250,7 +256,16 @@ namespace night
/* data */
public:
std::string offset_0;
int offset_24;
int offset_28;
std::string offset_32;
int offset_56;
int offset_60;
ns_sourcemap(/* args */);
ns_sourcemap(ns_sourcemap &&);
ns_sourcemap(ns_sourcemap const&);
ns_sourcemap& operator=(ns_sourcemap const&);
ns_sourcemap& operator=(ns_sourcemap &&);
~ns_sourcemap();
};

View File

@ -20,7 +20,8 @@ namespace night
this->compile(a3->offset_180);
std::string v10 = " " + a3->offset_156;
std::string v3 = v10.append(" ");
// this->offset_48 =
this->offset_48 += v3.length();
this->compile(a3->offset_184);
// v10 = v7 + v8;
std::string v4 = "";
@ -29,10 +30,73 @@ namespace night
}
std::string NSCompileJs::compile_call(night::ns_node *a3)
{
return "";
std::string str;
str = this->compile(a3->offset_220);
if ("return" == a3->offset_220->offset_60)
{
auto v3 = a3->offset_224;
for (int i = 0; ; i++)
{
if (i >= v3.size())
break;
auto v4 = v3.at(i);
if (v4->begin() != v4->end())
{
if (
v4->size() != 1
|| (v4->at(0)->offset_0 != night::NS_TYPE_SKIP)
)
{
str += "(\000)\000{"; // 待确认
this->offset_48++;
for (int v19 = 0; v19 < v4->size(); v19++)
{
auto v9 = v4->at(v19);
str += this->compile(v9);
if (v19 + 1 != v4->size())
{
str += ",";
this->offset_48++;
}
}
str += 5580790; // TODO...待确认
this->offset_48++;
}
}
}
}
else
{
for (int i = 0; i < a3->offset_224.size(); i++)
{
str += "(\000)\000{";
this->offset_48++;
auto v12 = a3->offset_224[i];
for (int j = 0; j < v12->size(); j++)
{
str += this->compile(v12->at(j));
if (j + 1 != v12->size())
{
str += ",";
this->offset_48++;
}
}
str += 5580790;
this->offset_48++;
}
}
return str;
}
std::string NSCompileJs::compile_do_while(night::ns_node *a3)
{
std::string str = "";
str += "do";
// 要确认加的长度是str还是"do"的
return "";
}
std::string NSCompileJs::compile_for(night::ns_node *a3)
@ -47,21 +111,50 @@ namespace night
{
return "";
}
std::string NSCompileJs::compile_k_v(night::ns_node *)
std::string NSCompileJs::compile_k_v(night::ns_node * a3)
{
return "";
std::string result = "";
result += this->compile(a3->offset_188) + ":";
this->offset_48++;
result += this->compile(a3->offset_192) + ",";
this->offset_48++;
return result;
}
std::string NSCompileJs::compile_obj_dot(night::ns_node *)
std::string NSCompileJs::compile_obj_dot(night::ns_node * a3)
{
return "";
std::string result = "";
result += this->compile(a3->offset_192);
for (int i = 0; i < a3->offset_196->size(); i++)
{
result += ".";
this->offset_48++;
auto v3 = a3->offset_196->at(i);
result += this->compile(v3);
}
return result;
}
std::string NSCompileJs::compile_obj_property(night::ns_node *)
{
return "";
}
std::string NSCompileJs::compile_obj_self_op(night::ns_node *)
std::string NSCompileJs::compile_obj_self_op(night::ns_node *a3)
{
return "";
std::string result = "";
if (a3->offset_200)
{
result += a3->offset_156;
this->offset_48 += a3->offset_156.length();
result += this->compile(a3->offset_192);
}
else
{
std::string v7 = this->compile(a3->offset_192);
v7.append(a3->offset_156);
result += v7;
this->offset_48 += a3->offset_156.length();
}
return result;
}
std::string NSCompileJs::compile_op_self(night::ns_node *a3)
{
@ -69,6 +162,7 @@ namespace night
for (auto i = a3->offset_196->begin(); i != a3->offset_196->end(); i++)
{
this->compile(*i);
// TODO...
}
return "";
@ -79,24 +173,34 @@ namespace night
}
std::string NSCompileJs::compile_ternary(night::ns_node *a3)
{
std::string result = "";
std::string v6 = this->compile(a3->offset_180);
v6.append(":");
// += v7
result += v6;
this->offset_48++;
this->compile(a3->offset_184);
// += v7
return "";
result += this->compile(a3->offset_184);
return result;
}
std::string NSCompileJs::compile_var(night::ns_node *)
{
return "";
}
std::string NSCompileJs::compile_while(night::ns_node *)
std::string NSCompileJs::compile_while(night::ns_node * a3)
{
return "";
std::string result = "";
std::string v5 = "while(";
result += v5;
this->offset_48 += v5.length();
result += this->compile(a3->offset_204);
result += 5580790;
this->offset_48++;
result += this->compile(a3->offset_216);
return result;
}
std::string NSCompileJs::compile_prog(night::ns_node *a3)
{
std::string result = "";
std::string v9 = a3->offset_108;
if (v9.size() == 0)
{
@ -106,36 +210,37 @@ namespace night
int v6 = 0;
for (auto i = v4->begin(); i != v4->end(); i++)
{
this->compile(*i);
result += this->compile(*i);
v6++;
if (v6 != v4->size())
{
// +=
result += v9;
this->offset_48 += v9.size();
}
}
return "";
return result;
}
std::string NSCompileJs::compile_prog_no_sem(night::ns_node *a3)
{
std::string result = "";
if (night::NS_TYPE_OBJ_BLOCK == a3->offset_0)
{
// +=
result += "(\000)\000{";
this->offset_48++;
}
for (auto i = a3->offset_228->begin(); i != a3->offset_228->end(); i++)
{
this->compile(*i);
// +=
result += this->compile(*i);
}
if (night::NS_TYPE_OBJ_BLOCK == a3->offset_0)
{
// +=
result += 5580790;
this->offset_48++;
}
return "";
return result;
}
std::string NSCompileJs::compile(night::ns_node * a3)
@ -151,13 +256,25 @@ namespace night
{
if (v9 == night::NS_TYPE_BOOL)
{
// TODO...
return "";
night::ns_sourcemap v13;
v13.offset_0.assign(a3->offset_24);
v13.offset_32.assign(a3->offset_60);
v13.offset_24 = a3->offset_48;
v13.offset_28 = a3->offset_52;
v13.offset_56 = a3->offset_48;
v13.offset_60 = a3->offset_48;
this->offset_36.push_back(v13);
std::string v10 = a3->offset_60;
this->offset_48 += v10.length();
return v10;
}
if (v9 == night::NS_TYPE_STR)
{
// TODO...
return "";
std::string v13 = a3->offset_108 + a3->offset_60;
v13.append(a3->offset_108);
this->offset_48 += v13.length();
return v13;
}
if (v9 != night::NS_TYPE_B_TYPE && v9 != night::NS_TYPE_PUNC)
{

View File

@ -6,6 +6,48 @@ namespace night
ns_sourcemap::ns_sourcemap(/* args */)
{
}
ns_sourcemap::ns_sourcemap(ns_sourcemap && src):
offset_0(src.offset_0),
offset_24(src.offset_24),
offset_28(src.offset_28),
offset_32(src.offset_32),
offset_56(src.offset_56),
offset_60(src.offset_60)
{
}
ns_sourcemap::ns_sourcemap(ns_sourcemap const& src):
offset_0(src.offset_0),
offset_24(src.offset_24),
offset_28(src.offset_28),
offset_32(src.offset_32),
offset_56(src.offset_56),
offset_60(src.offset_60)
{
}
ns_sourcemap& ns_sourcemap::operator=(ns_sourcemap const& src)
{
this->offset_0 = src.offset_0;
this->offset_24 = src.offset_24;
this->offset_28 = src.offset_28;
this->offset_32 = src.offset_32;
this->offset_56 = src.offset_56;
this->offset_60 = src.offset_60;
return *this;
}
ns_sourcemap& ns_sourcemap::operator=(ns_sourcemap && src)
{
this->offset_0 = src.offset_0;
this->offset_24 = src.offset_24;
this->offset_28 = src.offset_28;
this->offset_32 = src.offset_32;
this->offset_56 = src.offset_56;
this->offset_60 = src.offset_60;
return *this;
}
ns_sourcemap::~ns_sourcemap()
{

View File

@ -19270,7 +19270,7 @@ char *__thiscall night::NSCompileJs::compile_var[abi:cxx11](char *this, int a2,
std::string::basic_string(lpuexcpta, v10);
__cxa_throw(
lpuexcpta,
(struct type_info *)&`typeinfo for'std::string,
(struct type_info *)&`typeinfo for std::string,
(void (__cdecl *)(void *))std::string::~string);
}
v12 = 0;
@ -19558,16 +19558,16 @@ void **__thiscall night::NSCompileJs::compile[abi:cxx11](void **this, int a2, _D
char *v10; // [esp+68h] [ebp-60h] BYREF
int v11; // [esp+6Ch] [ebp-5Ch]
char v12; // [esp+70h] [ebp-58h] BYREF
char *v13; // [esp+80h] [ebp-48h] BYREF
char *v13; // [esp+80h] [ebp-48h] BYREF v13.offset_0 std::string
int v14; // [esp+84h] [ebp-44h]
char v15[16]; // [esp+88h] [ebp-40h] BYREF
int v16; // [esp+98h] [ebp-30h]
int v17; // [esp+9Ch] [ebp-2Ch]
char *v18; // [esp+A0h] [ebp-28h] BYREF
int v16; // [esp+98h] [ebp-30h] v13.offset_24
int v17; // [esp+9Ch] [ebp-2Ch] v13.offset_28
char *v18; // [esp+A0h] [ebp-28h] BYREF v13.offset_32 std::string
int v19; // [esp+A4h] [ebp-24h]
char v20[16]; // [esp+A8h] [ebp-20h] BYREF
int v21; // [esp+B8h] [ebp-10h]
int v22; // [esp+BCh] [ebp-Ch]
int v21; // [esp+B8h] [ebp-10h] v13.offset_56
int v22; // [esp+BCh] [ebp-Ch] v13.offset_60
if ( !*(_DWORD *)(a2 + 4) )
{
@ -19583,19 +19583,22 @@ void **__thiscall night::NSCompileJs::compile[abi:cxx11](void **this, int a2, _D
{
if ( std::operator==<char>((int)&night::NS_TYPE_BOOL, (int)v9) )
{
v15[0] = 0;
v13 = v15;
v18 = v20;
v13 = v15; // v13.offset_0
v14 = 0;
v15[0] = 0;
v18 = v20;
v16 = 0;
v17 = 0;
v19 = 0;
v20[0] = 0;
v21 = 0;
v22 = 0;
// a3 + 6 -> a3.offset_24
std::string::_M_assign((int)&v13, (int)(a3 + 6));
// v16 -> v13.offset_24
v16 = a3[12];
v17 = a3[13];
// a3 + 15 -> a3.offset_60
std::string::_M_assign((int)&v18, (int)(a3 + 15));
v21 = a3[12];
v22 = *(_DWORD *)(a2 + 48);
@ -19609,6 +19612,7 @@ void **__thiscall night::NSCompileJs::compile[abi:cxx11](void **this, int a2, _D
}
if ( std::operator==<char>((int)&night::NS_TYPE_STR, (int)v9) )
{
// a3.offset_108
std::operator+<char>((char *)&v13, (int)(a3 + 27), (int)(a3 + 15));
v3 = std::string::append(&v13, (int)(a3 + 27));
std::string::basic_string(&v10, v3);
@ -19763,9 +19767,9 @@ int __thiscall night::NSCompileJs::compile_k_v[abi:cxx11](int this, int a2, int
void *v7[6]; // [esp+50h] [ebp-38h] BYREF
void *v8[8]; // [esp+68h] [ebp-20h] BYREF
*(_BYTE *)(this + 8) = 0;
*(_DWORD *)this = this + 8;
*(_DWORD *)(this + 4) = 0;
*(_BYTE *)(this + 8) = 0;
night::NSCompileJs::compile[abi:cxx11](a2, *(_DWORD *)(a3 + 188));
v3 = std::string::append(v7, ":");
std::string::basic_string(v8, v3);
@ -19850,7 +19854,7 @@ _DWORD *__thiscall night::NSCompileJs::compile_for[abi:cxx11](_DWORD *this, int
std::string::basic_string(lpuexcpta, v16);
__cxa_throw(
lpuexcpta,
(struct type_info *)&`typeinfo for'std::string,
(struct type_info *)&`typeinfo for std::string,
(void (__cdecl *)(void *))std::string::~string);
}
v4 = (_DWORD *)std::vector<night::ns_node *>::at(v3, 0);
@ -19894,9 +19898,10 @@ _DWORD *__thiscall night::NSCompileJs::compile_while[abi:cxx11](_DWORD *this, in
void *v5[6]; // [esp+50h] [ebp-38h] BYREF
void *v6[8]; // [esp+68h] [ebp-20h] BYREF
this[1] = 0;
*this = this + 2;
this[1] = 0;
*((_BYTE *)this + 8) = 0;
std::string::basic_string(v5, "while(");
std::string::operator+=(v5);
*(_DWORD *)(a2 + 48) += v5[1];
@ -19922,9 +19927,10 @@ _DWORD *__thiscall night::NSCompileJs::compile_do_while[abi:cxx11](_DWORD *this,
void *v6[6]; // [esp+70h] [ebp-38h] BYREF
void *v7[8]; // [esp+88h] [ebp-20h] BYREF
this[1] = 0;
*this = this + 2;
this[1] = 0;
*((_BYTE *)this + 8) = 0;
std::string::basic_string(v5, "do");
std::string::operator+=(v5);
*(_DWORD *)(a2 + 48) += v5[1];
@ -20054,9 +20060,9 @@ _BYTE *__thiscall night::NSCompileJs::compile_obj_self_op[abi:cxx11](_BYTE *this
void *v7[6]; // [esp+50h] [ebp-38h] BYREF
void *v8[8]; // [esp+68h] [ebp-20h] BYREF
this[8] = 0;
*(_DWORD *)this = this + 8;
*((_DWORD *)this + 1) = 0;
this[8] = 0;
lpuexcpt = (struct _Unwind_Exception *)(a3 + 156);
if ( *(_BYTE *)(a3 + 200) )
{
@ -20278,9 +20284,9 @@ _BYTE *__thiscall night::NSCompileJs::compile_ternary[abi:cxx11](_BYTE *this, in
void *v6[6]; // [esp+50h] [ebp-38h] BYREF
void *v7[8]; // [esp+68h] [ebp-20h] BYREF
this[8] = 0;
*(_DWORD *)this = this + 8;
*((_DWORD *)this + 1) = 0;
this[8] = 0;
night::NSCompileJs::compile[abi:cxx11](a2, *(_DWORD *)(a3 + 180));
v3 = std::string::append(v6, ":");
std::string::basic_string(v7, v3);
@ -20313,6 +20319,7 @@ _DWORD *__thiscall night::NSCompileJs::compile_binary[abi:cxx11](_DWORD *this, i
std::string::basic_string(v8, v3);
std::string::_M_dispose((void **)v10);
*(_DWORD *)(a2 + 48) += v8[1];
night::NSCompileJs::compile[abi:cxx11](a2, *(_DWORD *)(a3 + 184));
std::operator+<char>((char *)v10, (int)v7, (int)v8);
v4 = std::string::append(v10, (int)v9);
@ -20356,9 +20363,9 @@ int __thiscall night::NSCompileJs::compile_call[abi:cxx11](int this, int a2, int
unsigned int lpuexcpta; // [esp+24h] [ebp-64h]
void *v24[8]; // [esp+68h] [ebp-20h] BYREF
*(_BYTE *)(this + 8) = 0;
*(_DWORD *)this = this + 8;
*(_DWORD *)this = this + 8; // std::string
*(_DWORD *)(this + 4) = 0;
*(_BYTE *)(this + 8) = 0;
night::NSCompileJs::compile[abi:cxx11](a2, *(_DWORD *)(a3 + 220));
std::string::operator=((unsigned __int8 **)this, (int)v24);
std::string::_M_dispose(v24);
@ -20382,16 +20389,18 @@ int __thiscall night::NSCompileJs::compile_call[abi:cxx11](int this, int a2, int
v7 = (int *)std::vector<night::ns_node *>::at(*v6, 0),
!std::operator==<char>((int)&night::NS_TYPE_SKIP, *v7)) )
{
std::string::operator+=(asc_5527F4);
std::string::operator+=(asc_5527F4); // "(\000)\000{"
v19 = 0;
++*(_DWORD *)(a2 + 48);
while ( 1 )
{
// v4
v11 = std::vector<std::vector*<night::ns_node *,std::allocator<night::ns_node>>>::at(
*(_DWORD **)(a3 + 224),
lpuexcpt);
if ( v19 >= (*(_DWORD *)(*(_DWORD *)v11 + 4) - **(_DWORD **)v11) >> 2 )
break;
// v4
v8 = (_DWORD **)std::vector<std::vector*<night::ns_node *,std::allocator<night::ns_node>>>::at(
*(_DWORD **)(a3 + 224),
lpuexcpt);
@ -20400,6 +20409,7 @@ int __thiscall night::NSCompileJs::compile_call[abi:cxx11](int this, int a2, int
std::string::operator+=(v24);
std::string::_M_dispose(v24);
v17 = v19 + 1;
// v4
v10 = std::vector<std::vector*<night::ns_node *,std::allocator<night::ns_node>>>::at(
*(_DWORD **)(a3 + 224),
lpuexcpt);
@ -20410,7 +20420,7 @@ int __thiscall night::NSCompileJs::compile_call[abi:cxx11](int this, int a2, int
++*(_DWORD *)(a2 + 48);
v19 = v17;
}
}
} // end while
std::string::operator+=(5580790);
++*(_DWORD *)(a2 + 48);
}
@ -20421,7 +20431,7 @@ int __thiscall night::NSCompileJs::compile_call[abi:cxx11](int this, int a2, int
{
for ( i = 0; i < (*(_DWORD *)(*(_DWORD *)(a3 + 224) + 4) - **(_DWORD **)(a3 + 224)) >> 2; ++i )
{
std::string::operator+=(asc_5527F4);
std::string::operator+=(asc_5527F4); // "(\000)\000{"
lpuexcpta = 0;
++*(_DWORD *)(a2 + 48);
while ( 1 )
@ -20445,7 +20455,7 @@ int __thiscall night::NSCompileJs::compile_call[abi:cxx11](int this, int a2, int
++*(_DWORD *)(a2 + 48);
lpuexcpta = v18;
}
}
} // end while
std::string::operator+=(5580790);
++*(_DWORD *)(a2 + 48);
}
@ -20471,8 +20481,8 @@ _DWORD *__thiscall night::NSCompileJs::compile_prog[abi:cxx11](_DWORD *this, int
if ( !v10 )
std::string::operator=((unsigned int *)&v9, ";");
lpuexcpt = 0;
this[1] = 0;
*this = this + 2;
this[1] = 0;
*((_BYTE *)this + 8) = 0;
while ( 1 )
{
@ -20506,8 +20516,8 @@ _DWORD *__thiscall night::NSCompileJs::compile_prog_no_sem[abi:cxx11](_DWORD *th
unsigned int lpuexcpt; // [esp+14h] [ebp-64h]
void *v8[8]; // [esp+58h] [ebp-20h] BYREF
this[1] = 0;
*this = this + 2;
this[1] = 0;
*((_BYTE *)this + 8) = 0;
if ( std::operator==<char>((int)&night::NS_TYPE_OBJ_BLOCK, a3) )
{