mirror of
https://github.com/msojocs/wx-compiler.git
synced 2025-07-19 00:00:04 +08:00
fix: 逻辑错误
This commit is contained in:
parent
0b07ddabf2
commit
78e5c52474
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -57,10 +57,10 @@
|
||||
"variant": "cpp"
|
||||
},
|
||||
"cmake.debugConfig": {
|
||||
"cwd": "/mnt/d/Work/WeChatProjects/miniprogram-1",
|
||||
"cwd": "/mnt/d/Work/WeChatProjects/tdesign-miniprogram-starter-retail",
|
||||
"args": [
|
||||
"\"--config-path\"",
|
||||
"\"/mnt/d/Work/WeChatProjects/miniprogram-1/wcc/99a9bac3c05fc25dd070298212c4a7d3\""
|
||||
"\"/mnt/d/Work/WeChatProjects/case4-cmd.txt\""
|
||||
]
|
||||
},
|
||||
"cmake.configureSettings": {
|
||||
|
11
changelog.md
11
changelog.md
@ -1,3 +1,14 @@
|
||||
## 🌈 v0.0.3 / 2023-08-31
|
||||
|
||||
🐞 Bug Fixes
|
||||
|
||||
- `NSASTParse::make_call_or_just_expression`: 修复括号缺失的错误
|
||||
- `NSASTParse::ast_obj_op`: 修复比较字符串地址错误
|
||||
- `NSASTParse::ast_call`: 修复忘记赋值的问题
|
||||
|
||||
🚧 Others
|
||||
- 优化发生异常时,没有输出的问题
|
||||
|
||||
## 🌈 v0.0.2 / 2023-08-31
|
||||
|
||||
🚀Features
|
||||
|
@ -543,8 +543,11 @@ namespace night
|
||||
return v6;
|
||||
}
|
||||
|
||||
int ast_dispatch_i = 0;
|
||||
night::ns_node *NSASTParse::ast_dispatch(bool a3)
|
||||
{
|
||||
ast_dispatch_i++;
|
||||
int inner_ast_dispatch_i = ast_dispatch_i;
|
||||
// ast_dispatch - 0
|
||||
auto v42 = this->is_punctuation("(");
|
||||
if (!v42)
|
||||
@ -964,7 +967,7 @@ namespace night
|
||||
v21
|
||||
&& !this->is_op_self(false)
|
||||
&& !this->is_obj_op_self(false)
|
||||
&&this->is_exp(a2)
|
||||
&& this->is_exp(a2)
|
||||
)
|
||||
{
|
||||
auto v3 = this->offset_28->next();
|
||||
@ -1024,14 +1027,16 @@ namespace night
|
||||
return a2;
|
||||
}
|
||||
|
||||
int make_call_or_just_expression_i = 0;
|
||||
night::ns_node *NSASTParse::make_call_or_just_expression(night::ns_node * a2)
|
||||
{
|
||||
make_call_or_just_expression_i++;
|
||||
int inner_make_call_or_just_expression_i = make_call_or_just_expression_i;
|
||||
if (
|
||||
night::NS_TYPE_PROG != a2->offset_0
|
||||
&& night::NS_TYPE_B_TYPE != a2->offset_0
|
||||
&& night::NS_TYPE_KW != a2->offset_0
|
||||
&& night::NS_TYPE_FUNC != a2->offset_0
|
||||
|| a2->offset_132 == ""
|
||||
&& (night::NS_TYPE_FUNC != a2->offset_0 || a2->offset_132 == "")
|
||||
)
|
||||
{
|
||||
if (this->is_punctuation("("))
|
||||
@ -1066,8 +1071,11 @@ namespace night
|
||||
return lb;
|
||||
}
|
||||
|
||||
int ast_obj_dot_i = 0;
|
||||
night::ns_node *NSASTParse::ast_obj_dot(night::ns_node* a2)
|
||||
{
|
||||
ast_obj_dot_i++;
|
||||
int inner_ast_obj_dot_i = ast_obj_dot_i;
|
||||
auto v11 = this->offset_24;
|
||||
auto v9 = v11->gen_girl(night::std_v_n);
|
||||
auto v10 = v11->gen_son(night::NS_TYPE_OBJ_DOT);
|
||||
@ -1096,15 +1104,18 @@ namespace night
|
||||
this->offset_28->err(msg, v7, v8, true);
|
||||
}
|
||||
auto v18 = this->ast_expression_no_comma();
|
||||
v9.vec->push_back(v18);
|
||||
v9.vec->emplace_back(v18);
|
||||
v5 = this->offset_28->peek();
|
||||
|
||||
} while (v5 && "." == v5->offset_60);
|
||||
return v10;
|
||||
}
|
||||
|
||||
int ast_obj_op_i = 0;
|
||||
night::ns_node *NSASTParse::ast_obj_op(night::ns_node* a2)
|
||||
{
|
||||
ast_obj_op_i++;
|
||||
int inner_ast_obj_op_i = ast_obj_op_i;
|
||||
auto v9 = this->offset_24->gen_girl(night::std_v_n);
|
||||
auto v13 = this->offset_24->gen_son(night::NS_TYPE_OBJ_PROPERTY);
|
||||
v13->offset_192 = a2;
|
||||
@ -1134,15 +1145,18 @@ namespace night
|
||||
return this->ast_obj_op_self(v13);
|
||||
}
|
||||
auto v5 = this->offset_28->peek();
|
||||
if (v5 && "." == v5->offset_0)
|
||||
if (v5 && "." == v5->offset_60)
|
||||
{
|
||||
return this->ast_obj_dot(v13);
|
||||
}
|
||||
return v13;
|
||||
}
|
||||
|
||||
int ast_call_i = 0;
|
||||
night::ns_node *NSASTParse::ast_call(night::ns_node* a2)
|
||||
{
|
||||
ast_call_i++;
|
||||
int inner_ast_call_i = ast_call_i;
|
||||
auto v10 = this->offset_24->gen_girl(night::std_v_v_n);
|
||||
auto v15 = this->offset_24->gen_son(night::NS_TYPE_CALL);
|
||||
v15->offset_220 = a2;
|
||||
@ -1172,7 +1186,7 @@ namespace night
|
||||
night::ns_node * v5;
|
||||
if ("[" == v4->offset_60)
|
||||
{
|
||||
this->ast_obj_op(v15);
|
||||
v15 = this->ast_obj_op(v15);
|
||||
v5 = this->is_punctuation("(");
|
||||
}
|
||||
else
|
||||
@ -1465,8 +1479,11 @@ namespace night
|
||||
return lt;
|
||||
}
|
||||
|
||||
long is_punctuation_i = 0;
|
||||
night::ns_node * NSASTParse::is_punctuation(std::string const &a2)
|
||||
{
|
||||
is_punctuation_i++;
|
||||
long inner_is_punctuation_i = is_punctuation_i; // 20906
|
||||
auto v2 = this->offset_28->peek();
|
||||
if (v2)
|
||||
{
|
||||
@ -1753,8 +1770,11 @@ namespace night
|
||||
this->offset_28->err(msg, 0, v6, false);
|
||||
}
|
||||
}
|
||||
int ignore_punc_i = 0;
|
||||
void NSASTParse::ignore_punc(std::string const& a2)
|
||||
{
|
||||
ignore_punc_i++;
|
||||
int inner_ignore_punc_i = ignore_punc_i;
|
||||
if (!this->is_punctuation(a2))
|
||||
{
|
||||
auto node = this->offset_28->peek();
|
||||
|
@ -300,8 +300,12 @@ namespace night
|
||||
this->offset_48++;
|
||||
return result;
|
||||
}
|
||||
|
||||
int compile_obj_dot_i = 0;
|
||||
std::string NSCompileJs::compile_obj_dot(night::ns_node * a3)
|
||||
{
|
||||
compile_obj_dot_i++;
|
||||
int inner_compile_obj_dot_i = compile_obj_dot_i;
|
||||
std::string result = "";
|
||||
result += this->compile(a3->offset_192);
|
||||
for (int i = 0; i < a3->offset_196->size(); i++)
|
||||
@ -314,8 +318,12 @@ namespace night
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int compile_obj_property_i = 0;
|
||||
std::string NSCompileJs::compile_obj_property(night::ns_node *a3)
|
||||
{
|
||||
compile_obj_property_i++;
|
||||
int inner_compile_obj_property_i = compile_obj_property_i; // 3
|
||||
std::string v26 = night::nst_ + std::to_string(this->offset_32);
|
||||
this->offset_32++;
|
||||
|
||||
@ -679,8 +687,11 @@ namespace night
|
||||
return "";
|
||||
}
|
||||
|
||||
int compile_once_i = 0;
|
||||
std::string NSCompileJs::compile_once(std::string &a3, std::vector<std::string> *a4, bool a5)
|
||||
{
|
||||
compile_once_i++;
|
||||
int inner_compile_once_i = compile_once_i;
|
||||
this->offset_28 = a4;
|
||||
a3 = "";
|
||||
night::ns_node* v5 = this->offset_24->top_down();
|
||||
|
@ -60,6 +60,29 @@ describe("[tdesign-miniprogram-starter-retail] wcc - raw", function () {
|
||||
fs.writeFileSync(`${storagePath}/node-output.js`, n);
|
||||
assert.equal(w, n);
|
||||
});
|
||||
it("case3", async function () {
|
||||
const configPath = resolve(__dirname, './tdesign-miniprogram-starter-retail/case3-cmd.txt')
|
||||
const projectPath = path.resolve(
|
||||
__dirname,
|
||||
"../../../projects/tdesign-miniprogram-starter-retail"
|
||||
);
|
||||
const args = [
|
||||
"--config-path",
|
||||
configPath,
|
||||
];
|
||||
const w = (await windows.wcc(args, projectPath)).replace(/\r\n/g, "\n");
|
||||
const n = await linux.wcc(args, projectPath);
|
||||
const storagePath = path.resolve(
|
||||
__dirname,
|
||||
`tdesign-miniprogram-starter-retail/${this.test?.title}`
|
||||
);
|
||||
try {
|
||||
fs.mkdirSync(storagePath, { recursive: true });
|
||||
} catch (error) {}
|
||||
fs.writeFileSync(`${storagePath}/wine-output.js`, w);
|
||||
fs.writeFileSync(`${storagePath}/node-output.js`, n);
|
||||
assert.equal(w, n);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
File diff suppressed because one or more lines are too long
@ -17416,7 +17416,7 @@ _DWORD *__userpurge night::NSASTParse::ast_dispatch@<eax>(_DWORD *a1@<ecx>, nigh
|
||||
std::string::basic_string((char *)v82, (int)&night::NS_TYPE_PUNC);
|
||||
v79[0] = night::NSGod::gen_son(v33, (int)v82);
|
||||
std::string::_M_dispose(v82);
|
||||
std::string::operator=((unsigned int *)v79[0] + 15, (char *)asc_5527F4);
|
||||
std::string::operator=((unsigned int *)v79[0] + 15, (char *)asc_5527F4);// "(\000)\000{"
|
||||
v17 = std::vector<night::ns_node *>::push_back(v44, (char **)v79);
|
||||
night::NSToken::next(a1[7]);
|
||||
v3 = *(_DWORD *)(a1[7] + 4);
|
||||
@ -17437,7 +17437,7 @@ _DWORD *__userpurge night::NSASTParse::ast_dispatch@<eax>(_DWORD *a1@<ecx>, nigh
|
||||
}
|
||||
}
|
||||
std::vector<night::ns_node *>::push_back(v44, (char **)v80);
|
||||
std::string::basic_string(v82, (char *)&asc_5527F4[2]);
|
||||
std::string::basic_string(v82, (char *)&asc_5527F4[2]); // "(\000)\000{"
|
||||
night::NSASTParse::ignore_punc(a1, (int)v82);
|
||||
std::string::_M_dispose(v82);
|
||||
v35 = (void *)a1[6];
|
||||
@ -18010,11 +18010,11 @@ _DWORD *__thiscall night::NSASTParse::ast_call(int *this, int a2)
|
||||
std::string::basic_string(v24, v2);
|
||||
night::NSToken::err((int)lpuexcpta, (int)v24, 0, 0, 0);
|
||||
}
|
||||
std::string::basic_string(v24, (char *)&byte_551F04);
|
||||
std::string::basic_string(v24, (char *)&byte_551F04); // '\0'
|
||||
std::string::basic_string((void **)v23, "ast_expression_no_comma");
|
||||
std::string::basic_string(v22, ",");
|
||||
std::string::basic_string(v21, (char *)&asc_5527F4[2]);
|
||||
std::string::basic_string(v20, (char *)asc_5527F4);
|
||||
std::string::basic_string(v21, (char *)&asc_5527F4[2]); // ')'
|
||||
std::string::basic_string(v20, (char *)asc_5527F4); // '('
|
||||
list_by_parser = night::NSASTParse::make_list_by_parser(this, (int)v20, (int)v21, (int)v22, (int)v23, 0, -1, (int)v24);
|
||||
std::string::_M_dispose(v20);
|
||||
std::string::_M_dispose(v21);
|
||||
@ -18030,7 +18030,7 @@ _DWORD *__thiscall night::NSASTParse::ast_call(int *this, int a2)
|
||||
std::string::_M_dispose(v24);
|
||||
if ( !v9 )
|
||||
break;
|
||||
std::string::basic_string(v24, (char *)&byte_551F04);
|
||||
std::string::basic_string(v24, (char *)&byte_551F04); // '\0'
|
||||
std::string::basic_string((void **)v23, "ast_expression_no_comma");
|
||||
std::string::basic_string(v22, ",");
|
||||
std::string::basic_string(v21, (char *)&asc_5527F4[2]);
|
||||
@ -18078,9 +18078,9 @@ _DWORD *__thiscall night::NSASTParse::make_call_or_just_expression(int *this, _D
|
||||
&& !std::operator==<char>((int)&night::NS_TYPE_B_TYPE, (int)a2)
|
||||
&& !std::operator==<char>((int)&night::NS_TYPE_KW, (int)a2)
|
||||
&& (!std::operator==<char>((int)&night::NS_TYPE_FUNC, (int)a2)
|
||||
|| !(unsigned __int8)std::operator!=<char>((char *)&byte_551F04, (int)(a2 + 33))) )
|
||||
|| !(unsigned __int8)std::operator!=<char>((char *)&byte_551F04, (int)(a2 + 33))) ) // '\0'
|
||||
{
|
||||
std::string::basic_string(v4, (char *)asc_5527F4);
|
||||
std::string::basic_string(v4, (char *)asc_5527F4); // "(\000)\000{"
|
||||
if ( night::NSASTParse::is_punctuation(this, (int)v4) )
|
||||
a2 = night::NSASTParse::ast_call(this, (int)a2);
|
||||
std::string::_M_dispose(v4);
|
||||
@ -19261,7 +19261,7 @@ struct _Unwind_Exception *__fastcall night::NSASTParse::ast_var(_DWORD *a1)
|
||||
std::vector<night::ns_node *>::push_back(v16, &v24);
|
||||
}
|
||||
|
||||
v4 = a1[7];
|
||||
v4 = a1[7]; // int v4
|
||||
v5 = *(_DWORD *)(v4 + 4);
|
||||
v10 = *(_DWORD *)(v5 + 52);
|
||||
v12 = *(_DWORD *)(v5 + 56);
|
||||
@ -19295,6 +19295,7 @@ struct _Unwind_Exception *__fastcall night::NSASTParse::ast_var(_DWORD *a1)
|
||||
std::string::basic_string((char *)v26, (int)&night::NS_TYPE_PROG);
|
||||
lpuexcptb = (struct _Unwind_Exception *)night::NSGod::gen_son(lpuexcpta, (int)v26);
|
||||
std::string::_M_dispose(v26);
|
||||
// 228
|
||||
*((_DWORD *)lpuexcptb + 57) = v16;
|
||||
std::string::operator=((unsigned int *)lpuexcptb + 27, (char *)&byte_551F04);
|
||||
return lpuexcptb;
|
||||
@ -20239,7 +20240,7 @@ _BYTE *__thiscall night::NSCompileJs::compile_obj_property[abi:cxx11](_BYTE *thi
|
||||
std::string::_M_dispose((void **)v39);
|
||||
++*(_DWORD *)(a2 + 32);
|
||||
|
||||
*(_DWORD *)this = this + 8;
|
||||
*(_DWORD *)this = this + 8; // std::string
|
||||
*((_DWORD *)this + 1) = 0;
|
||||
this[8] = 0;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||
|
||||
cd /mnt/d/Work/WeChatProjects/miniprogram-1
|
||||
cd /mnt/d/Work/WeChatProjects/tdesign-miniprogram-starter-retail
|
||||
|
||||
# list="cmd1 cmd2"
|
||||
# for cmd in $list;
|
||||
@ -11,6 +11,9 @@ cd /mnt/d/Work/WeChatProjects/miniprogram-1
|
||||
# /root/github/wx-compiler/build/wcc "--config-path" "/mnt/d/Work/disassembly/wcc-exec/wcc/config/$cmd.txt" > /root/github/wx-compiler/test/wcc_linux.json
|
||||
# /mnt/d/Work/disassembly/wcc-exec/wcc/wcc.exe "--config-path" "d:/Work/disassembly/wcc-exec/wcc/config/$cmd.txt" > /root/github/wx-compiler/test/wcc_win.json
|
||||
# done;
|
||||
filename="WeChatProjects/miniprogram-1/wcc/2535335225445086ae78aa14d79fe1d5"
|
||||
filename="WeChatProjects/case4-cmd.txt"
|
||||
echo "linux:"
|
||||
/root/github/wx-compiler/build/wcc "--config-path" "/mnt/d/Work/$filename" > /root/github/wx-compiler/test/wcc_linux.json
|
||||
|
||||
echo "windows:"
|
||||
/mnt/d/Work/disassembly/wcc-exec/wcc/wcc.exe "--config-path" "d:/Work/$filename" > /root/github/wx-compiler/test/wcc_win.json
|
||||
|
Loading…
x
Reference in New Issue
Block a user