[decompiler] Make addition nicer (#733)

* temp

* update refs

* update reference

* fix tests
This commit is contained in:
water111
2021-08-01 18:24:58 -04:00
committed by GitHub
parent e70d179496
commit 12446037bd
42 changed files with 294 additions and 536 deletions
+24 -31
View File
@@ -62,7 +62,7 @@ TEST_F(FormRegressionTest, ExprAdditionMixed1) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function int uint int)";
std::string expected = "(+ arg0 (the-as int arg1))";
std::string expected = "(+ arg0 arg1)";
test_with_expr(func, type, expected);
}
@@ -73,7 +73,7 @@ TEST_F(FormRegressionTest, ExprAdditionMixed2) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function uint int uint)";
std::string expected = "(+ arg0 (the-as uint arg1))";
std::string expected = "(+ arg0 arg1)";
test_with_expr(func, type, expected);
}
@@ -106,7 +106,7 @@ TEST_F(FormRegressionTest, ExprAdditionMixed1WrongReturn) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function int uint uint)";
std::string expected = "(the-as uint (+ arg0 (the-as int arg1)))";
std::string expected = "(the-as uint (+ arg0 arg1))";
test_with_expr(func, type, expected);
}
@@ -117,7 +117,7 @@ TEST_F(FormRegressionTest, ExprAdditionMixed2WrongReturn) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function uint int int)";
std::string expected = "(the-as int (+ arg0 (the-as uint arg1)))";
std::string expected = "(the-as int (+ arg0 arg1))";
test_with_expr(func, type, expected);
}
@@ -1660,12 +1660,11 @@ TEST_F(FormRegressionTest, ExprInlineArrayMethod5) {
std::string type = "(function inline-array-class int)";
std::string expected =
"(the-as int\n"
" (+ (-> arg0 type size)\n"
" (the-as uint\n"
" (* (-> arg0 allocated-length)"
" (the-as int (-> arg0 type heap-base)))\n"
" )\n"
"(the-as\n"
" int\n"
" (+\n"
" (-> arg0 type size)\n"
" (* (-> arg0 allocated-length) (the-as int (-> arg0 type heap-base)))\n"
" )\n"
" )";
test_with_expr(func, type, expected, true, "inline-array-class");
@@ -1735,12 +1734,12 @@ TEST_F(FormRegressionTest, ExprArrayMethod0) {
" (object-new\n"
" arg0\n"
" arg1\n"
" (the-as\n"
" int\n"
" (+\n"
" (-> arg1 size)\n"
" (the-as uint (* arg3 (if (type-type? arg2 number) (the-as int (-> arg2 size)) 4)))\n"
" )\n"
" (the-as int (+ (-> arg1 size) (* arg3 (if (type-type? arg2 number)\n"
" (the-as int (-> arg2 size))\n"
" 4\n"
" )\n"
" )\n"
" )\n"
" )\n"
" )\n"
" )\n"
@@ -1807,22 +1806,16 @@ TEST_F(FormRegressionTest, ExprArrayMethod5) {
std::string type = "(function array int)";
std::string expected =
" (the-as\n"
" int\n"
" (+\n"
" (-> array size)\n"
" (the-as\n"
" uint\n"
" (*\n"
" (-> arg0 allocated-length)\n"
" (if\n"
" (type-type? (-> arg0 content-type) number)\n"
" (the-as int (-> arg0 content-type size))\n"
" 4\n"
" )\n"
" )\n"
" )\n"
"(the-as\n"
" int\n"
" (+\n"
" (-> array size)\n"
" (* (-> arg0 allocated-length) (if (type-type? (-> arg0 content-type) number)\n"
" (the-as int (-> arg0 content-type size))\n"
" 4\n"
" )\n"
" )\n"
" )\n"
" )";
test_with_expr(func, type, expected, true, "array");
}