perf: 兼容std11

This commit is contained in:
msojocs 2023-09-22 23:20:14 +08:00
parent f9054fc8a7
commit c770d0a758
8 changed files with 35 additions and 824 deletions

View File

@ -1,7 +1,13 @@
cmake_minimum_required(VERSION 3.0.0) cmake_minimum_required(VERSION 3.0.0)
project(wx_complier VERSION 0.1.0 LANGUAGES C CXX) project(wx_complier VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# set (CMAKE_CXX_STANDARD 14)
# set(CMAKE_VERBOSE_MAKEFILE ON)
# message("before: ${CMAKE_CXX_FLAGS_DEBUG}")
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O1")
# message("after: ${CMAKE_CXX_FLAGS_DEBUG}")
include(CTest) include(CTest)
enable_testing() enable_testing()

View File

@ -42,10 +42,10 @@ namespace WXML
{ {
bool inited = false; bool inited = false;
int *nextPos; int *nextPos;
int canAccept[266]; uint8_t *canAccept;
}; };
int accept(int *,int *[266],int &,char const*); int accept(int *,uint8_t *[266],int &,char const*);
int acceptID(char const*,int &); int acceptID(char const*,int &);
int acceptStr(char const*,int &); int acceptStr(char const*,int &);
int acceptNum(char const*,int &); int acceptNum(char const*,int &);

View File

@ -134,7 +134,7 @@ namespace WXSS
std::vector<std::shared_ptr<CSSSyntaxTree>> offset_120; std::vector<std::shared_ptr<CSSSyntaxTree>> offset_120;
std::shared_ptr<std::string> offset_132; // 类型未确定,不是布尔值 std::shared_ptr<std::string> offset_132; // 类型未确定,不是布尔值
std::shared_ptr<std::string> offset_140; std::shared_ptr<std::string> offset_140;
std::shared_ptr<std::string[3]> offset_148; std::shared_ptr<std::array<std::string, 3>> offset_148;
std::shared_ptr<Token> offset_156; std::shared_ptr<Token> offset_156;
int offset_164 = 0; int offset_164 = 0;
int offset_168 = 0; int offset_168 = 0;

View File

@ -137,7 +137,6 @@ namespace WXML
if (!this->offset_24) if (!this->offset_24)
{ {
this->offset_24 = true; this->offset_24 = true;
std::map<std::string,std::vector<WXML::EXPRLib::BNF>> map1 = this->ret[1];
int root; int root;
std::vector<std::string> keyList; std::vector<std::string> keyList;

View File

@ -6,826 +6,26 @@ namespace WXML
namespace RPX namespace RPX
{ {
// 0x0051FE20 // 0x0051FE20
int id_nextPos[0x850u]; int id_nextPos[0x850u];
Table id = { uint8_t id_accept[] = {0x0,0x1,0x24,0x48,0x65,0x61,0x64,0x55,0x52,0x4c,0x24,0x20,0x24,0x49,0x64,0x24,0x20,0x30,0x5f,0x5f,0x66,0x69,0x6c,0x65,0x5f,0x5f,0x0,0x0,0x0,0x0,0x24,0x48,0x65,0x61,0x64,0x55,0x52,0x4c,0x24,0x20,0x24,0x49,0x64,0x24,0x20,0x30,0x5f,0x5f,0x66,0x69,0x6c,0x65,0x5f,0x5f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x48,0x65,0x61,0x64,0x55,0x52,0x4c,0x24,0x20,0x24,0x49,0x64,0x24,0x20,0x30,0x5f,0x5f,0x66,0x69,0x6c,0x65,0x5f,0x5f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x54,0xf6,0x50,0x0,0x5c,0xf6,0x50,0x0,0x3,0xf6,0x50,0x0,0xa,0xf6,0x50,0x0,0x15,0xf6,0x50,0x0,0x28,0xf6,0x50,0x0,0x65,0xf6,0x50,0x0,0x6f,0xf6,0x50,0x0,0x7e,0xf6,0x50,0x0,0x8a,0xf6,0x50,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
false, Table id;
id_nextPos,
{1210319104,
1432641893,
539249746,
610552100,
1600073760,
1701603686,
24415,
1210318848,
1432641893,
539249746,
610552100,
1600073760,
1701603686,
24415,
0,
1210318848,
1432641893,
539249746,
610552100,
1600073760,
1701603686,
24415,
0,
-162267136,
-161742768,
-167575472,
-167116720,
-166395824,
-165150640,
-161152944,
-160497584,
-159514544,
-158728112,
80,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0}};
// 0x0051E520 // 0x0051E520
int str_nextPos[0x18F0u]; int str_nextPos[0x18F0u];
Table str = { uint8_t str_accept[] = {0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0x24,0x48,0x65,0x61,0x64,0x55,0x52,0x4c,0x24,0x20,0x24,0x49,0x64,0x24,0x20,0x30,0x5f,0x5f,0x66,0x69,0x6c,0x65,0x5f,0x5f,0x0,0x0,0x0,0x0,0x24,0x48,0x65,0x61,0x64,0x55,0x52,0x4c,0x24,0x20,0x24,0x49,0x64,0x24,0x20,0x30,0x5f,0x5f,0x66,0x69,0x6c,0x65,0x5f,0x5f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x48,0x65,0x61,0x64,0x55,0x52,0x4c,0x24,0x20,0x24,0x49,0x64,0x24,0x20,0x30,0x5f,0x5f,0x66,0x69,0x6c,0x65,0x5f,0x5f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x54,0xf6,0x50,0x0,0x5c,0xf6,0x50,0x0,0x3,0xf6,0x50,0x0,0xa,0xf6,0x50,0x0,0x15,0xf6,0x50,0x0,0x28,0xf6,0x50,0x0,0x65,0xf6,0x50,0x0,0x6f,0xf6,0x50,0x0,0x7e,0xf6,0x50,0x0,0x8a,0xf6,0x50,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
false, Table str;
str_nextPos,
{0,
16777472,
1634027556,
1280464228,
1227104292,
807412836,
1768316767,
1600087404,
0,
1634027556,
1280464228,
1227104292,
807412836,
1768316767,
1600087404,
0,
0,
1634027556,
1280464228,
1227104292,
807412836,
1768316767,
1600087404,
0,
0,
5305940,
5305948,
5305859,
5305866,
5305877,
5305896,
5305957,
5305967,
5305982,
5305994,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0}};
// 0x0051D040 // 0x0051D040
int num_nextPos[0x14C8u]; int num_nextPos[0x14C8u];
Table num = { uint8_t num_accept[] = {0x0,0x0,0x1,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0x24,0x48,0x65,0x61,0x64,0x55,0x52,0x4c,0x24,0x20,0x24,0x49,0x64,0x24,0x20,0x30,0x5f,0x5f,0x66,0x69,0x6c,0x65,0x5f,0x5f,0x0,0x0,0x0,0x0,0x24,0x48,0x65,0x61,0x64,0x55,0x52,0x4c,0x24,0x20,0x24,0x49,0x64,0x24,0x20,0x30,0x5f,0x5f,0x66,0x69,0x6c,0x65,0x5f,0x5f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x48,0x65,0x61,0x64,0x55,0x52,0x4c,0x24,0x20,0x24,0x49,0x64,0x24,0x20,0x30,0x5f,0x5f,0x66,0x69,0x6c,0x65,0x5f,0x5f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x54,0xf6,0x50,0x0,0x5c,0xf6,0x50,0x0,0x3,0xf6,0x50,0x0,0xa,0xf6,0x50,0x0,0x15,0xf6,0x50,0x0,0x28,0xf6,0x50,0x0,0x65,0xf6,0x50,0x0,0x6f,0xf6,0x50,0x0,0x7e,0xf6,0x50,0x0,0x8a,0xf6,0x50,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
false, Table num;
num_nextPos,
{65536,
1,
0,
16777472,
1634027556,
1280464228,
1227104292,
807412836,
1768316767,
1600087404,
0,
1634027556,
1280464228,
1227104292,
807412836,
1768316767,
1600087404,
0,
0,
1634027556,
1280464228,
1227104292,
807412836,
1768316767,
1600087404,
0,
0,
5305940,
5305948,
5305859,
5305866,
5305877,
5305896,
5305957,
5305967,
5305982,
5305994,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0}};
/** /**
* TODO: * TODO:
*/ */
int accept(int *a1, int a2[266], int &a3, char const *a4) int accept(int *a1, uint8_t a2[266], int &a3, char const *a4)
{ {
int v4 = 0; int v4 = 0;
int v7 = 0; int v7 = 0;
@ -852,6 +52,8 @@ namespace WXML
{ {
if (!id.inited) if (!id.inited)
{ {
id.nextPos = id_nextPos;
id.canAccept = id_accept;
// 0x0051FE20 // 0x0051FE20
memset(id.nextPos, 255, 0x850u); memset(id.nextPos, 255, 0x850u);
int v2 = 0; int v2 = 0;
@ -885,6 +87,8 @@ namespace WXML
{ {
if (!str.inited) if (!str.inited)
{ {
str.nextPos = str_nextPos;
str.canAccept = str_accept;
// 0x0051E520 // 0x0051E520
memset(str.nextPos, 255, 0x18F0u); memset(str.nextPos, 255, 0x18F0u);
@ -909,6 +113,8 @@ namespace WXML
{ {
if (!num.inited) if (!num.inited)
{ {
num.nextPos = num_nextPos;
num.canAccept = num_accept;
// 0x0051D040 // 0x0051D040
memset(num.nextPos, 255, 0x18F0u); memset(num.nextPos, 255, 0x18F0u);
int v2 = 0; int v2 = 0;

View File

@ -98,7 +98,7 @@ namespace WXSS
auto cur = this->offset_120[i]; auto cur = this->offset_120[i];
if (cur->offset_0 == "SELECTORS") if (cur->offset_0 == "SELECTORS")
{ {
auto v148 = this->offset_148.get(); auto v148 = *this->offset_148;
std::string v14 = v148[0].substr(2, v148[0].length() - 7); std::string v14 = v148[0].substr(2, v148[0].length() - 7);
std::string v15 = WXML::Rewrite::ToStringCode2(v14); std::string v15 = WXML::Rewrite::ToStringCode2(v14);
v15.insert(0, "[is=\""); v15.insert(0, "[is=\"");
@ -125,7 +125,7 @@ namespace WXSS
else else
{ {
cur->RenderCode(a2, true); cur->RenderCode(a2, true);
auto v148 = this->offset_148.get(); auto v148 = *this->offset_148;
std::string v14 = v148[0].substr(2, v148[0].length() - 7); std::string v14 = v148[0].substr(2, v148[0].length() - 7);
auto v15 = WXML::Rewrite::ToStringCode2(v14); auto v15 = WXML::Rewrite::ToStringCode2(v14);
v15.insert(0, "[is=\""); v15.insert(0, "[is=\"");

View File

@ -203,7 +203,7 @@ namespace WXSS
{ {
std::stringstream v31; std::stringstream v31;
v31 << ";wxcs_fileinfo: "; v31 << ";wxcs_fileinfo: ";
v31 << a2->offset_148[0]; v31 << (*a2->offset_148)[0];
v31 << " " << v25->offset_24.offset_20; v31 << " " << v25->offset_24.offset_20;
v31 << " " << v25->offset_24.offset_24 << ";"; v31 << " " << v25->offset_24.offset_24 << ";";
@ -314,7 +314,7 @@ namespace WXSS
auto v10 = *j; auto v10 = *j;
*v5 = v10->offset_24; *v5 = v10->offset_24;
std::shared_ptr<std::string> str(new std::string()); std::shared_ptr<std::string> str(new std::string());
*str = a2->offset_148[0]; *str = (*a2->offset_148)[0];
a2->offset_156->offset_4 = str; a2->offset_156->offset_4 = str;
return 1; return 1;
} }
@ -326,7 +326,7 @@ namespace WXSS
auto v10 = *j; auto v10 = *j;
*v5 = v10->offset_24; *v5 = v10->offset_24;
std::shared_ptr<std::string> str(new std::string()); std::shared_ptr<std::string> str(new std::string());
*str = a2->offset_148[0]; *str = (*a2->offset_148)[0];
a2->offset_156->offset_4 = str; a2->offset_156->offset_4 = str;
return 1; return 1;
} }
@ -402,7 +402,7 @@ namespace WXSS
auto v10 = *j; auto v10 = *j;
*v5 = v10->offset_24; *v5 = v10->offset_24;
std::shared_ptr<std::string> str(new std::string()); std::shared_ptr<std::string> str(new std::string());
*str = a2->offset_148[0]; *str = (*a2->offset_148)[0];
a2->offset_156->offset_4 = str; a2->offset_156->offset_4 = str;
return 1; return 1;
} }
@ -414,7 +414,7 @@ namespace WXSS
auto v10 = *j; auto v10 = *j;
*v5 = v10->offset_24; *v5 = v10->offset_24;
std::shared_ptr<std::string> str(new std::string()); std::shared_ptr<std::string> str(new std::string());
*str = a2->offset_148[0]; *str = (*a2->offset_148)[0];
a2->offset_156->offset_4 = str; a2->offset_156->offset_4 = str;
return 1; return 1;
} }
@ -462,7 +462,7 @@ namespace WXSS
} }
} }
std::shared_ptr<std::string> str(new std::string()); std::shared_ptr<std::string> str(new std::string());
*str = a2->offset_148[0]; *str = (*a2->offset_148)[0];
a2->offset_156->offset_4 = str; a2->offset_156->offset_4 = str;
return 1; return 1;
@ -474,7 +474,7 @@ namespace WXSS
std::string lit = a2->offset_24.GetLiteral(); std::string lit = a2->offset_24.GetLiteral();
std::string v10; std::string v10;
auto la = a2->offset_24.offset_24; auto la = a2->offset_24.offset_24;
int v5 = WXML::Rewrite::RewriteImg(lit, v10, a2->offset_148[0], a2->offset_24.offset_20, la); int v5 = WXML::Rewrite::RewriteImg(lit, v10, (*a2->offset_148)[0], a2->offset_24.offset_20, la);
if (!v5) if (!v5)
{ {
return 1; return 1;

View File

@ -60,9 +60,9 @@ namespace WXSS
this->offset_8.push_back(v104); this->offset_8.push_back(v104);
// Parse - 15 // Parse - 15
std::shared_ptr<std::string[3]> v9(new std::string[3]()); std::shared_ptr<std::array<std::string, 3>> v9(new std::array<std::string, 3>());
v9[0].assign(a3); (*v9)[0].assign(a3);
v9[1].assign(a5); (*v9)[1].assign(a5);
std::shared_ptr<WXSS::Token> v14(new WXSS::Token()); std::shared_ptr<WXSS::Token> v14(new WXSS::Token());
v14->offset_4.reset(new std::string()); v14->offset_4.reset(new std::string());
*v14->offset_4 = a3; *v14->offset_4 = a3;