Decompiler fixes + decompiling (#276)

* decomp pad

* more decompilation

* update

* fix test name
This commit is contained in:
water111
2021-02-22 09:36:30 -05:00
committed by GitHub
parent ac24b2ab15
commit 5ec9a91eb9
48 changed files with 2567 additions and 530 deletions
+10 -10
View File
@@ -580,7 +580,7 @@ TEST(DecompilerAtomicOpBuilder, OR) {
test_case(assembly_from_list({"or a1, a2, a3"}), {"(set! a1 (logior a2 a3))"}, {{"a1"}},
{{"a2", "a3"}}, {{}});
test_case(assembly_from_list({"or a2, r0, r0"}), {"(set! a2 0)"}, {{"a2"}}, {{}}, {{}});
test_case(assembly_from_list({"or a1, s7, r0"}), {"(set! a1 '#f)"}, {{"a1"}}, {{}}, {{}});
test_case(assembly_from_list({"or a1, s7, r0"}), {"(set! a1 #f)"}, {{"a1"}}, {{}}, {{}});
}
TEST(DecompilerAtomicOpBuilder, ORI) {
@@ -594,24 +594,24 @@ TEST(DecompilerAtomicOpBuilder, SB) {
test_case(assembly_from_list({"sb a1, 2(a3)"}), {"(s.b! (+ a3 2) a1)"}, {{}}, {{"a1", "a3"}},
{{}});
test_case(assembly_from_list({"sb a1, 0(a3)"}), {"(s.b! a3 a1)"}, {{}}, {{"a1", "a3"}}, {{}});
test_case(assembly_from_list({"sb s7, 2(a3)"}), {"(s.b! (+ a3 2) '#f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sb s7, 0(a3)"}), {"(s.b! a3 '#f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sb s7, 2(a3)"}), {"(s.b! (+ a3 2) #f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sb s7, 0(a3)"}), {"(s.b! a3 #f)"}, {{}}, {{"a3"}}, {{}});
}
TEST(DecompilerAtomicOpBuilder, SD) {
test_case(assembly_from_list({"sd a1, 2(a3)"}), {"(s.d! (+ a3 2) a1)"}, {{}}, {{"a1", "a3"}},
{{}});
test_case(assembly_from_list({"sd a1, 0(a3)"}), {"(s.d! a3 a1)"}, {{}}, {{"a1", "a3"}}, {{}});
test_case(assembly_from_list({"sd s7, 2(a3)"}), {"(s.d! (+ a3 2) '#f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sd s7, 0(a3)"}), {"(s.d! a3 '#f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sd s7, 2(a3)"}), {"(s.d! (+ a3 2) #f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sd s7, 0(a3)"}), {"(s.d! a3 #f)"}, {{}}, {{"a3"}}, {{}});
}
TEST(DecompilerAtomicOpBuilder, SH) {
test_case(assembly_from_list({"sh a1, 2(a3)"}), {"(s.h! (+ a3 2) a1)"}, {{}}, {{"a1", "a3"}},
{{}});
test_case(assembly_from_list({"sh a1, 0(a3)"}), {"(s.h! a3 a1)"}, {{}}, {{"a1", "a3"}}, {{}});
test_case(assembly_from_list({"sh s7, 2(a3)"}), {"(s.h! (+ a3 2) '#f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sh s7, 0(a3)"}), {"(s.h! a3 '#f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sh s7, 2(a3)"}), {"(s.h! (+ a3 2) #f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sh s7, 0(a3)"}), {"(s.h! a3 #f)"}, {{}}, {{"a3"}}, {{}});
}
TEST(DecompilerAtomicOpBuilder, SLL) {
@@ -756,12 +756,12 @@ TEST(DecompilerAtomicOpBuilder, SUBS) {
TEST(DecompilerAtomicOpBuilder, SW) {
test_case(assembly_from_list({"sw a1, test(s7)"}), {"(s.w! test a1)"}, {{}}, {{"a1"}}, {{}});
test_case(assembly_from_list({"sw s7, test(s7)"}), {"(s.w! test '#f)"}, {{}}, {{}}, {{}});
test_case(assembly_from_list({"sw s7, test(s7)"}), {"(s.w! test #f)"}, {{}}, {{}}, {{}});
test_case(assembly_from_list({"sw a1, 2(a3)"}), {"(s.w! (+ a3 2) a1)"}, {{}}, {{"a1", "a3"}},
{{}});
test_case(assembly_from_list({"sw a1, 0(a3)"}), {"(s.w! a3 a1)"}, {{}}, {{"a1", "a3"}}, {{}});
test_case(assembly_from_list({"sw s7, 2(a3)"}), {"(s.w! (+ a3 2) '#f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sw s7, 0(a3)"}), {"(s.w! a3 '#f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sw s7, 2(a3)"}), {"(s.w! (+ a3 2) #f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sw s7, 0(a3)"}), {"(s.w! a3 #f)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sw r0, test(s7)"}), {"(s.w! test 0)"}, {{}}, {{}}, {{}});
test_case(assembly_from_list({"sw r0, 2(a3)"}), {"(s.w! (+ a3 2) 0)"}, {{}}, {{"a3"}}, {{}});
test_case(assembly_from_list({"sw r0, 0(a3)"}), {"(s.w! a3 0)"}, {{}}, {{"a3"}}, {{}});
@@ -236,7 +236,7 @@ TEST_F(FormRegressionTest, WhileLoop) {
" (return (begin (set! v1-1 '#t) (set! v0-0 v1-1)))\n"
" )\n"
" )\n"
" (set! v0-0 '#f)\n"
" (set! v0-0 #f)\n"
" (ret-value v0-0)\n"
" )";
test_no_expr(func, type, expected);
@@ -302,7 +302,7 @@ TEST_F(FormRegressionTest, Or) {
" (return (begin (set! v1-1 '#t) (set! v0-0 v1-1)))\n"
" )\n"
" )\n"
" (set! v0-0 '#f)\n"
" (set! v0-0 #f)\n"
" (ret-value v0-0)\n"
" )";
test_no_expr(func, type, expected);
+20 -20
View File
@@ -360,7 +360,7 @@ TEST_F(FormRegressionTest, ExprFalse) {
" jr ra\n"
" daddu sp, sp, r0";
std::string type = "(function symbol)";
std::string expected = "'#f";
std::string expected = "#f";
test_with_expr(func, type, expected);
}
@@ -464,7 +464,7 @@ TEST_F(FormRegressionTest, ExprBasicTypeP) {
" (return '#t)\n"
" )\n"
" )\n"
" '#f\n"
" #f\n"
" )";
test_with_expr(func, type, expected);
}
@@ -507,7 +507,7 @@ TEST_F(FormRegressionTest, FinalBasicTypeP) {
" (begin (set! v1-0 (-> v1-0 parent)) (= v1-0 a0-1))\n"
" (if (= v1-0 arg1) (return (quote #t)))\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )";
test_final_function(func, type, expected);
}
@@ -561,7 +561,7 @@ TEST_F(FormRegressionTest, ExprTypeTypep) {
" )\n"
" (if (= arg0 arg1) (return '#t))\n"
" )\n"
" '#f\n"
" #f\n"
" )";
test_with_expr(func, type, expected, false, "");
}
@@ -662,7 +662,7 @@ TEST_F(FormRegressionTest, ExprRef) {
" (nop!)\n"
" (nop!)\n"
" (set! arg0 (cdr arg0))\n"
" (set! v1-0 (+ v1-0 1))\n"
" (+! v1-0 1)\n"
" )\n"
" (car arg0)\n"
" )";
@@ -726,7 +726,7 @@ TEST_F(FormRegressionTest, ExprPairMethod4) {
" (and (!= v1-1 '()) "
" (< (shl (the-as int v1-1) 62) 0)\n"
" )\n"
" (set! v0-0 (+ v0-0 1))\n"
" (+! v0-0 1)\n"
" (set! v1-1 (cdr v1-1))\n"
" )\n"
" )\n"
@@ -1582,7 +1582,7 @@ TEST_F(FormRegressionTest, ExprSort) {
" (set! v1-1 (arg1 s2-0 s1-0))\n"
" (when\n"
" (and (or (not v1-1) (> (the-as int v1-1) 0)) (!= v1-1 (quote #t)))\n"
" (set! s4-0 (+ s4-0 1))\n"
" (+! s4-0 1)\n"
" (set! (car s3-0) s1-0)\n"
" (set! (car (cdr s3-0)) s2-0)\n"
" )\n"
@@ -1873,9 +1873,9 @@ TEST_F(FormRegressionTest, ExprMemCopy) {
" (while\n"
" (< v1-0 arg2)\n"
" (set! (-> (the-as (pointer int8) arg0)) (-> (the-as (pointer uint8) arg1)))\n"
" (set! arg0 (+ arg0 (the-as uint 1)))\n"
" (set! arg1 (+ arg1 (the-as uint 1)))\n"
" (set! v1-0 (+ v1-0 1))\n"
" (&+! arg0 1)\n"
" (&+! arg1 1)\n"
" (+! v1-0 1)\n"
" )\n"
" v0-0\n"
" )";
@@ -1914,9 +1914,9 @@ TEST_F(FormRegressionTest, ExprMemSet32) {
" (while\n"
" (< v1-0 arg1)\n"
" (set! (-> (the-as (pointer int32) arg0)) arg2)\n"
" (set! arg0 (+ arg0 (the-as uint 4)))\n"
" (&+! arg0 4)\n"
" (nop!)\n"
" (set! v1-0 (+ v1-0 1))\n"
" (+! v1-0 1)\n"
" )\n"
" v0-0\n"
" )";
@@ -1964,9 +1964,9 @@ TEST_F(FormRegressionTest, ExprMemOr) {
" (-> (the-as (pointer uint8) arg1))\n"
" )\n"
" )\n"
" (set! arg0 (+ arg0 (the-as uint 1)))\n"
" (set! arg1 (+ arg1 (the-as uint 1)))\n"
" (set! v1-0 (+ v1-0 1))\n"
" (&+! arg0 1)\n"
" (&+! arg1 1)\n"
" (+! v1-0 1)\n"
" )\n"
" v0-0\n"
" )";
@@ -2181,9 +2181,9 @@ TEST_F(FormRegressionTest, ExprPrintTreeBitmask) {
" (format (quote #t) \"| \")\n"
" )\n"
" (set! arg0 (shr arg0 1))\n"
" (set! s4-0 (+ s4-0 1))\n"
" (+! s4-0 1)\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )";
test_with_expr(func, type, expected, false, "", {{"L323", " "}, {"L322", "| "}});
}
@@ -2496,11 +2496,11 @@ TEST_F(FormRegressionTest, StringLt) {
" (< v1-4 s4-1)\n"
" (cond\n"
" ((< (-> arg0 data v1-4) (-> arg1 data v1-4)) (return (quote #t)))\n"
" ((< (-> arg1 data v1-4) (-> arg0 data v1-4)) (return (quote #f)))\n"
" ((< (-> arg1 data v1-4) (-> arg0 data v1-4)) (return #f))\n"
" )\n"
" (set! v1-4 (+ v1-4 1))\n"
" (+! v1-4 1)\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )";
test_with_expr(func, type, expected, false, "");
}
@@ -552,7 +552,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (if (zero? s5-0) \"~D\" \" ~D\")\n"
" (-> (the-as (array int32) arg0) s5-0)\n"
" )\n"
" (set! s5-0 (+ s5-0 1))\n"
" (+! s5-0 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote uint32))\n"
@@ -564,7 +564,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (if (zero? s5-1) \"~D\" \" ~D\")\n"
" (-> (the-as (array uint32) arg0) s5-1)\n"
" )\n"
" (set! s5-1 (+ s5-1 1))\n"
" (+! s5-1 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote int64))\n"
@@ -576,7 +576,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (if (zero? s5-2) \"~D\" \" ~D\")\n"
" (-> (the-as (array int64) arg0) s5-2)\n"
" )\n"
" (set! s5-2 (+ s5-2 1))\n"
" (+! s5-2 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote uint64))\n"
@@ -588,7 +588,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (if (zero? s5-3) \"#x~X\" \" #x~X\")\n"
" (-> (the-as (array uint64) arg0) s5-3)\n"
" )\n"
" (set! s5-3 (+ s5-3 1))\n"
" (+! s5-3 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote int8))\n"
@@ -600,7 +600,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (if (zero? s5-4) \"~D\" \" ~D\")\n"
" (-> (the-as (array int8) arg0) s5-4)\n"
" )\n"
" (set! s5-4 (+ s5-4 1))\n"
" (+! s5-4 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote uint8))\n"
@@ -612,7 +612,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (if (zero? s5-5) \"~D\" \" ~D\")\n"
" (-> (the-as (array uint8) arg0) s5-5)\n"
" )\n"
" (set! s5-5 (+ s5-5 1))\n"
" (+! s5-5 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote int16))\n"
@@ -624,7 +624,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (if (zero? s5-6) \"~D\" \" ~D\")\n"
" (-> (the-as (array int16) arg0) s5-6)\n"
" )\n"
" (set! s5-6 (+ s5-6 1))\n"
" (+! s5-6 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote uint16))\n"
@@ -636,7 +636,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (if (zero? s5-7) \"~D\" \" ~D\")\n"
" (-> (the-as (array uint16) arg0) s5-7)\n"
" )\n"
" (set! s5-7 (+ s5-7 1))\n"
" (+! s5-7 1)\n"
" )\n"
" )\n"
" (else\n"
@@ -654,7 +654,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" )\n"
" (.lq a2-8 12 v1-42)\n"
" (t9-10 a0-21 a1-11 a2-8)\n"
" (set! s5-8 (+ s5-8 1))\n"
" (+! s5-8 1)\n"
" )\n"
" )\n"
" (else\n"
@@ -666,7 +666,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (if (zero? s5-9) \"~D\" \" ~D\")\n"
" (-> (the-as (array int32) arg0) s5-9)\n"
" )\n"
" (set! s5-9 (+ s5-9 1))\n"
" (+! s5-9 1)\n"
" )\n"
" )\n"
" )\n"
@@ -684,7 +684,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (format (quote #t) \"~f\" (-> (the-as (array float) arg0) s5-10))\n"
" (format (quote #t) \" ~f\" (-> (the-as (array float) arg0) s5-10))\n"
" )\n"
" (set! s5-10 (+ s5-10 1))\n"
" (+! s5-10 1)\n"
" )\n"
" )\n"
" (else\n"
@@ -696,7 +696,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod2) {
" (format (quote #t) \"~A\" (-> (the-as (array basic) arg0) s5-11))\n"
" (format (quote #t) \" ~A\" (-> (the-as (array basic) arg0) s5-11))\n"
" )\n"
" (set! s5-11 (+ s5-11 1))\n"
" (+! s5-11 1)\n"
" )\n"
" )\n"
" )\n"
@@ -1212,7 +1212,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-0\n"
" (-> (the-as (array int32) arg0) s5-0)\n"
" )\n"
" (set! s5-0 (+ s5-0 1))\n"
" (+! s5-0 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote uint32))\n"
@@ -1225,7 +1225,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-1\n"
" (-> (the-as (array uint32) arg0) s5-1)\n"
" )\n"
" (set! s5-1 (+ s5-1 1))\n"
" (+! s5-1 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote int64))\n"
@@ -1238,7 +1238,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-2\n"
" (-> (the-as (array int64) arg0) s5-2)\n"
" )\n"
" (set! s5-2 (+ s5-2 1))\n"
" (+! s5-2 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote uint64))\n"
@@ -1251,7 +1251,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-3\n"
" (-> (the-as (array uint64) arg0) s5-3)\n"
" )\n"
" (set! s5-3 (+ s5-3 1))\n"
" (+! s5-3 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote int8))\n"
@@ -1264,7 +1264,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-4\n"
" (-> (the-as (array int8) arg0) s5-4)\n"
" )\n"
" (set! s5-4 (+ s5-4 1))\n"
" (+! s5-4 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote uint8))\n"
@@ -1277,7 +1277,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-5\n"
" (-> (the-as (array int8) arg0) s5-5)\n"
" )\n"
" (set! s5-5 (+ s5-5 1))\n"
" (+! s5-5 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote int16))\n"
@@ -1290,7 +1290,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-6\n"
" (-> (the-as (array int16) arg0) s5-6)\n"
" )\n"
" (set! s5-6 (+ s5-6 1))\n"
" (+! s5-6 1)\n"
" )\n"
" )\n"
" ((= v1-1 (quote uint16))\n"
@@ -1303,7 +1303,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-7\n"
" (-> (the-as (array uint16) arg0) s5-7)\n"
" )\n"
" (set! s5-7 (+ s5-7 1))\n"
" (+! s5-7 1)\n"
" )\n"
" )\n"
" (else\n"
@@ -1322,7 +1322,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" )\n"
" (.lq a3-10 12 v1-42)\n"
" (t9-14 a0-25 a1-15 a2-13 a3-10)\n"
" (set! s5-8 (+ s5-8 1))\n"
" (+! s5-8 1)\n"
" )\n"
" )\n"
" (else\n"
@@ -1330,7 +1330,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" (while\n"
" (< s5-9 (-> arg0 length))\n"
" (format (quote #t) \"~T [~D] ~D~%\" s5-9 (-> arg0 s5-9))\n"
" (set! s5-9 (+ s5-9 1))\n"
" (+! s5-9 1)\n"
" )\n"
" )\n"
" )\n"
@@ -1349,7 +1349,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-10\n"
" (-> (the-as (array float) arg0) s5-10)\n"
" )\n"
" (set! s5-10 (+ s5-10 1))\n"
" (+! s5-10 1)\n"
" )\n"
" )\n"
" (else\n"
@@ -1362,7 +1362,7 @@ TEST_F(FormRegressionTest, ExprArrayMethod3) {
" s5-11\n"
" (-> (the-as (array basic) arg0) s5-11)\n"
" )\n"
" (set! s5-11 (+ s5-11 1))\n"
" (+! s5-11 1)\n"
" )\n"
" )\n"
" )\n"
@@ -1940,7 +1940,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg2\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" ((not v1-1)\n"
" (if\n"
@@ -1952,7 +1952,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg2\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" (else (quote #t))\n"
" )\n"
@@ -1973,7 +1973,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg1\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" ((or\n"
" (not v1-1)\n"
@@ -1993,7 +1993,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg1\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" (else (quote #t))\n"
" )\n"
@@ -2011,7 +2011,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg1\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" ((not v1-1)\n"
" (if\n"
@@ -2024,7 +2024,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg1\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" (else (quote #t))\n"
" )\n"
@@ -2043,7 +2043,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg1\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" )\n"
" )\n"
@@ -2058,7 +2058,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg1\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" ((not v1-1)\n"
" (if\n"
@@ -2071,7 +2071,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg1\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" ((and (= arg1 type) (!= (rtype-of arg0) type))\n"
" (if\n"
@@ -2086,13 +2086,13 @@ TEST_F(FormRegressionTest, ExprValid) {
" (rtype-of arg0)\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" (else\n"
" (cond\n"
" ((and\t\n"
" (!= arg1 type)\t\n"
" (not (valid? (rtype-of arg0) type (quote #f) (quote #t) 0))\t\n"
" (not (valid? (rtype-of arg0) type #f (quote #t) 0))\t\n"
" )\n"
" (if\n"
" arg2\n"
@@ -2106,7 +2106,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" (rtype-of arg0)\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" ((not (type-type? (rtype-of arg0) arg1))\n"
" (if\n"
@@ -2121,7 +2121,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" (rtype-of arg0)\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" ((= arg1 symbol)\n"
" (set! v1-43 32768)\n"
@@ -2139,7 +2139,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg1\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" (else (quote #t))\n"
" )\n"
@@ -2160,7 +2160,7 @@ TEST_F(FormRegressionTest, ExprValid) {
" arg1\n"
" )\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" (else (quote #t))\n"
" )\n"
@@ -2472,23 +2472,20 @@ TEST_F(FormRegressionTest, ExprStringToInt) {
" (a0-2 (pointer uint8))\n"
" (a0-3 (pointer uint8))\n"
" (a0-4 (pointer uint8))\n"
" (a0-5 symbol)\n"
" (a1-8 (pointer uint8))\n"
" (a1-14 uint)\n"
" (a1-20 uint)\n"
" (a1-23 uint)\n"
" (a1-33 symbol)\n"
" (a1-44 symbol)\n"
" (a1-47 (pointer uint8))\n"
" )\n"
" (set! a0-1 (-> arg0 data))\n"
" (set! v0-0 0)\n"
" (set! v1-0 (quote #f))\n"
" (set! v1-0 #f)\n"
" (cond\n"
" ((= (-> a0-1 0) 35)\n"
" (set! a0-2 (&-> a0-1 1))\n"
" (cond\n"
" ((or (zero? (+ (-> a0-2 0) -120)) (zero? (+ (-> a0-2 0) -88)))\n"
" ((or (= (-> a0-2 0) 120) (= (-> a0-2 0) 88))\n"
" (set! a0-3 (&-> a0-2 1))\n"
" (when\n"
" (= (-> a0-3 1) 45)\n"
@@ -2538,7 +2535,7 @@ TEST_F(FormRegressionTest, ExprStringToInt) {
" (set! a0-3 (&-> a0-3 1))\n"
" )\n"
" )\n"
" ((or (zero? (+ (-> a0-2 0) -98)) (zero? (+ (-> a0-2 0) -66)))\n"
" ((or (= (-> a0-2 0) 98) (= (-> a0-2 0) 66))\n"
" (set! a0-4 (&-> a0-2 1))\n"
" (while\n"
" (and (>= (-> a0-4 0) (the-as uint 48)) (>= (the-as uint 49) (-> a0-4 0)))\n"
+49 -52
View File
@@ -323,11 +323,11 @@ TEST_F(FormRegressionTest, ExprMethod0Thread) {
" (set!\n"
" v0-0\n"
" (cond\n"
" ((-> arg2 top-thread) (+ arg5 (the-as uint -7164)))\n"
" ((-> arg2 top-thread) (&+ arg5 -7164))\n"
" (else\n"
" (set!\n"
" v1-2\n"
" (logand -16 (the-as int (+ (-> arg2 heap-cur) (the-as uint 15))))\n"
" (logand -16 (the-as int (&+ (-> arg2 heap-cur) 15)))\n"
" )\n"
" (set! (-> arg2 heap-cur) (+ (+ v1-2 (the-as int (-> arg1 size))) arg4))\n"
" (+ v1-2 4)\n"
@@ -427,9 +427,9 @@ TEST_F(FormRegressionTest, RemoveMethod0ProcessTree) {
" (set! v0-0 (object-new arg0 arg1 (the-as int (-> arg1 size))))\n"
" (set! (-> v0-0 name) arg2)\n"
" (set! (-> v0-0 mask) 256)\n"
" (set! (-> v0-0 parent) (quote #f))\n"
" (set! (-> v0-0 brother) (quote #f))\n"
" (set! (-> v0-0 child) (quote #f))\n"
" (set! (-> v0-0 parent) #f)\n"
" (set! (-> v0-0 brother) #f)\n"
" (set! (-> v0-0 child) #f)\n"
" (set! (-> v0-0 self) v0-0)\n"
" (set! (-> v0-0 ppointer) (&-> v0-0 self))\n"
" v0-0\n"
@@ -631,25 +631,25 @@ TEST_F(FormRegressionTest, ExprMethod0Process) {
" (set! (-> (the-as process v0-0) name) arg2)\n"
" (set! (-> v0-0 status) (quote dead))\n"
" (set! (-> v0-0 pid) 0)\n"
" (set! (-> v0-0 pool) (quote #f))\n"
" (set! (-> v0-0 pool) #f)\n"
" (set! (-> v0-0 allocated-length) arg3)\n"
" (set! (-> v0-0 top-thread) (quote #f))\n"
" (set! (-> v0-0 main-thread) (quote #f))\n"
" (set! (-> v0-0 top-thread) #f)\n"
" (set! (-> v0-0 main-thread) #f)\n"
" (set! v1-5 (-> v0-0 stack))\n"
" (set! (-> v0-0 heap-cur) v1-5)\n"
" (set! (-> v0-0 heap-base) v1-5)\n"
" (set! (-> v0-0 heap-top) (&-> v0-0 stack (-> v0-0 allocated-length)))\n"
" (set! (-> v0-0 stack-frame-top) (-> v0-0 heap-top))\n"
" (set! (-> v0-0 stack-frame-top) (quote #f))\n"
" (set! (-> v0-0 state) (quote #f))\n"
" (set! (-> v0-0 next-state) (quote #f))\n"
" (set! (-> v0-0 entity) (quote #f))\n"
" (set! (-> v0-0 trans-hook) (quote #f))\n"
" (set! (-> v0-0 post-hook) (quote #f))\n"
" (set! (-> v0-0 event-hook) (quote #f))\n"
" (set! (-> v0-0 parent) (quote #f))\n"
" (set! (-> v0-0 brother) (quote #f))\n"
" (set! (-> v0-0 child) (quote #f))\n"
" (set! (-> v0-0 stack-frame-top) #f)\n"
" (set! (-> v0-0 state) #f)\n"
" (set! (-> v0-0 next-state) #f)\n"
" (set! (-> v0-0 entity) #f)\n"
" (set! (-> v0-0 trans-hook) #f)\n"
" (set! (-> v0-0 post-hook) #f)\n"
" (set! (-> v0-0 event-hook) #f)\n"
" (set! (-> v0-0 parent) #f)\n"
" (set! (-> v0-0 brother) #f)\n"
" (set! (-> v0-0 child) #f)\n"
" (set! (-> v0-0 self) v0-0)\n"
" (set! (-> v0-0 ppointer) (&-> v0-0 self))\n"
" v0-0\n"
@@ -711,16 +711,13 @@ TEST_F(FormRegressionTest, ExprInspectProcessHeap) {
std::string type = "(function process symbol)";
std::string expected =
"(begin\n"
" (set! s5-0 (+ (-> arg0 heap-base) (the-as uint 4)))\n"
" (set! s5-0 (&+ (-> arg0 heap-base) 4))\n"
" (while\n"
" (< (the-as int s5-0) (the-as int (-> arg0 heap-cur)))\n"
" (inspect (the-as basic s5-0))\n"
" (set!\n"
" (the-as int s5-0)\n"
" (+ (the-as int s5-0) (logand -16 (+ (asize-of s5-0) 15)))\n"
" )\n"
" (+! (the-as int s5-0) (logand -16 (+ (asize-of s5-0) 15)))\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
"";
test_with_expr(func, type, expected, false, "", {},
@@ -921,9 +918,9 @@ TEST_F(FormRegressionTest, ExprMethod0DeadPool) {
" (set! s3-0 (object-new arg0 arg1 (the-as int (-> arg1 size))))\n"
" (set! (-> s3-0 name) arg4)\n"
" (set! (-> s3-0 mask) 256)\n"
" (set! (-> s3-0 parent) (quote #f))\n"
" (set! (-> s3-0 brother) (quote #f))\n"
" (set! (-> s3-0 child) (quote #f))\n"
" (set! (-> s3-0 parent) #f)\n"
" (set! (-> s3-0 brother) #f)\n"
" (set! (-> s3-0 child) #f)\n"
" (set! (-> s3-0 self) s3-0)\n"
" (set! (-> s3-0 ppointer) (&-> s3-0 self))\n"
" (set! s2-1 0)\n"
@@ -937,7 +934,7 @@ TEST_F(FormRegressionTest, ExprMethod0DeadPool) {
" (set! (-> v1-5 parent) (if a0-4 (-> a0-4 ppointer)))\n"
" (set! (-> v1-5 pool) s3-0)\n"
" (set! (-> v1-5 brother) s1-0)\n"
" (set! s2-1 (+ s2-1 1))\n"
" (+! s2-1 1)\n"
" )\n"
" s3-0\n"
" )";
@@ -1082,7 +1079,7 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPool) {
" (if s4-0 (-> s4-0 0 self))\n"
" (-> arg0 name)\n"
" )\n"
" (quote #f)\n"
" #f\n"
" )\n"
" )\n"
" )\n"
@@ -1235,36 +1232,36 @@ TEST_F(FormRegressionTest, ExprMethod0DeadPoolHeap) {
" (set! (-> v0-0 name) arg2)\n"
" (set! (-> v0-0 mask) 256)\n"
" (set! (-> v0-0 allocated-length) arg3)\n"
" (set! (-> v0-0 parent) (quote #f))\n"
" (set! (-> v0-0 brother) (quote #f))\n"
" (set! (-> v0-0 child) (quote #f))\n"
" (set! (-> v0-0 parent) #f)\n"
" (set! (-> v0-0 brother) #f)\n"
" (set! (-> v0-0 child) #f)\n"
" (set! (-> v0-0 self) v0-0)\n"
" (set! (-> v0-0 ppointer) (&-> v0-0 self))\n"
" (set! v1-4 arg3)\n"
" (while\n"
" (nonzero? v1-4)\n"
" (set! v1-4 (+ v1-4 -1))\n"
" (+! v1-4 -1)\n"
" (set! a0-4 (-> v0-0 process-list v1-4))\n"
" (set! (-> a0-4 process) *null-process*)\n"
" (set! (-> a0-4 next) (-> v0-0 process-list (+ v1-4 1)))\n"
" )\n"
" (set! (-> v0-0 dead-list next) (-> v0-0 process-list))\n"
" (set! (-> v0-0 alive-list process) (quote #f))\n"
" (set! (-> v0-0 process-list (+ arg3 -1) next) (quote #f))\n"
" (set! (-> v0-0 alive-list process) #f)\n"
" (set! (-> v0-0 process-list (+ arg3 -1) next) #f)\n"
" (set! (-> v0-0 alive-list prev) (-> v0-0 alive-list))\n"
" (set! (-> v0-0 alive-list next) (quote #f))\n"
" (set! (-> v0-0 alive-list process) (quote #f))\n"
" (set! (-> v0-0 alive-list next) #f)\n"
" (set! (-> v0-0 alive-list process) #f)\n"
" (set! (-> v0-0 first-gap) (-> v0-0 alive-list))\n"
" (set! (-> v0-0 first-shrink) (quote #f))\n"
" (set! (-> v0-0 first-shrink) #f)\n"
" (set!\n"
" (-> v0-0 heap base)\n"
" (logand\n"
" -16\n"
" (the-as int (+ (+ (the-as int v0-0) 115) (the-as uint (* 12 arg3))))\n"
" (the-as int (&+ (+ (the-as int v0-0) 115) (* 12 arg3)))\n"
" )\n"
" )\n"
" (set! (-> v0-0 heap current) (-> v0-0 heap base))\n"
" (set! (-> v0-0 heap top) (+ (-> v0-0 heap base) (the-as uint arg4)))\n"
" (set! (-> v0-0 heap top) (&+ (-> v0-0 heap base) arg4))\n"
" (set! (-> v0-0 heap top-base) (-> v0-0 heap top))\n"
" v0-0\n"
" )";
@@ -1371,15 +1368,15 @@ TEST_F(FormRegressionTest, ExprMethod21DeadPoolHeap) {
" ((-> arg1 process)\n"
" (set!\n"
" v1-3\n"
" (+\n"
" (+ (-> arg1 process) (the-as uint (-> process size)))\n"
" (the-as uint (-> arg1 process allocated-length))\n"
" (&+\n"
" (&+ (-> arg1 process) (-> process size))\n"
" (-> arg1 process allocated-length)\n"
" )\n"
" )\n"
" (if\n"
" (-> arg1 next)\n"
" (- (-> arg1 next process) (the-as uint v1-3))\n"
" (- (-> arg0 heap top) (the-as uint (+ v1-3 (the-as uint 4))))\n"
" (- (-> arg0 heap top) (the-as uint (&+ v1-3 4)))\n"
" )\n"
" )\n"
" (else\n"
@@ -1387,7 +1384,7 @@ TEST_F(FormRegressionTest, ExprMethod21DeadPoolHeap) {
" (-> arg1 next)\n"
" (-\n"
" (-> arg1 next process)\n"
" (the-as uint (+ (-> arg0 heap base) (the-as uint 4)))\n"
" (the-as uint (&+ (-> arg0 heap base) 4))\n"
" )\n"
" (- (-> arg0 heap top) (the-as uint (-> arg0 heap base)))\n"
" )\n"
@@ -1564,7 +1561,7 @@ TEST_F(FormRegressionTest, ExprMethod3DeadPoolHeap) {
" )\n"
" )\n"
" (set! s5-1 (-> s5-1 next))\n"
" (set! s4-0 (+ s4-0 1))\n"
" (+! s4-0 1)\n"
" )\n"
" arg0\n"
" )";
@@ -1971,7 +1968,7 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPoolHeap) {
std::string expected =
"(begin\n"
" (set! s4-0 (-> arg0 dead-list next))\n"
" (set! s3-0 (quote #f))\n"
" (set! s3-0 #f)\n"
" (set! s1-0 (find-gap-by-size arg0 (+ (-> process size) (the-as uint arg2))))\n"
" (cond\n"
" ((and s4-0 s1-0)\n"
@@ -2182,7 +2179,7 @@ TEST_F(FormRegressionTest, ExprMethod15DeadPoolHeap) {
" )\n"
" )\n"
" (change-parent arg1 arg0)\n"
" (set! (-> arg0 child) (quote #f))\n"
" (set! (-> arg0 child) #f)\n"
" (set! s5-1 (-> arg1 ppointer))\n"
" (if\n"
" (or\n"
@@ -2199,7 +2196,7 @@ TEST_F(FormRegressionTest, ExprMethod15DeadPoolHeap) {
" (set! (-> arg0 first-shrink) (-> s5-1 1))\n"
" (when\n"
" (not (-> arg0 first-shrink process))\n"
" (set! (-> arg0 first-shrink) (quote #f))\n"
" (set! (-> arg0 first-shrink) #f)\n"
" )\n"
" )\n"
" (set! (-> s5-1 1 parent) (-> s5-1 2))\n"
@@ -2549,7 +2546,7 @@ TEST_F(FormRegressionTest, ExprMethod16DeadPoolHeap) {
" (set! (-> arg0 compact-count) 0)\n"
" (while\n"
" (nonzero? arg1)\n"
" (set! arg1 (+ arg1 -1))\n"
" (+! arg1 -1)\n"
" (set! v1-13 (-> arg0 first-shrink))\n"
" (when\n"
" (not v1-13)\n"
@@ -2725,7 +2722,7 @@ TEST_F(FormRegressionTest, ExprMethod18DeadPoolHeap) {
"(begin\n"
" (while\n"
" (nonzero? arg1)\n"
" (set! arg1 (+ arg1 -1))\n"
" (+! arg1 -1)\n"
" (set! s4-0 (-> arg0 alive-list next))\n"
" (when\n"
" s4-0\n"
@@ -2744,7 +2741,7 @@ TEST_F(FormRegressionTest, ExprMethod18DeadPoolHeap) {
" (set! (-> arg0 first-shrink) (-> s4-0 prev))\n"
" (when\n"
" (not (-> arg0 first-shrink process))\n"
" (set! (-> arg0 first-shrink) (quote #f))\n"
" (set! (-> arg0 first-shrink) #f)\n"
" )\n"
" )\n"
" (set! (-> s4-0 prev next) (-> s4-0 next))\n"
@@ -0,0 +1,63 @@
(deftype spool-anim-test (basic)
((name basic :offset 16) ;; why?
(index int32 :offset-assert 20)
(parts int32 :offset-assert 24)
(priority float :offset-assert 28)
(owner uint64 :offset-assert 32)
(command-list basic :offset-assert 40)
)
:pack-me
:method-count-assert 9
:size-assert #x2c
:flag-assert #x90000002c
)
(deftype external-art-control-test (basic)
((buffer basic 2 :offset-assert 4)
(rec spool-anim-test 3 :inline)
(spool-lock uint64 :offset-assert 160)
(reserve-buffer basic :offset-assert 168)
(reserve-buffer-count int32 :offset-assert 172)
(active-stream basic :offset-assert 176)
(preload-stream spool-anim-test :inline :offset-assert 184)
(last-preload-stream spool-anim-test :inline :offset-assert 232)
(end-pad uint32)
)
:method-count-assert 17
:size-assert #x118
:flag-assert #x1100000118
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(dummy-11 () none 11)
(dummy-12 () none 12)
(dummy-13 () none 13)
(dummy-14 () none 14)
(dummy-15 () none 15)
(dummy-16 () none 16)
)
)
(deftype simple (basic)
((data float))
)
;; 0 <- type pointer.
;; 4 <- buffer 0
;; 8 <- buffer 1
;; 12 <- EMPTY
;; 16 <- rec's type pointer
(define format _format)
(let ((test (new 'global 'external-art-control-test)))
(format #t "rec stride: ~D~%" (&- (-> test rec 1) (-> test rec 0))) ;; should be 48
(format #t "offset of float: ~D~%" (&- (&-> test rec 0 priority) test)) ;; should be 40
(format #t "offset: ~D~%" (&- (-> test rec 0) test)) ;; should be 16
(format #t "offset2: ~D~%" (&- (-> test preload-stream) test)) ;; should be 184
)
(let ((sb (new 'global 'inline-array 'simple 3)))
(format #t "array: #x~X~%" (logand 15 (the int sb)))
(format #t "first: #x~X~%" (logand 15 (the int (-> sb 0))))
)
0
+11
View File
@@ -420,6 +420,17 @@ TEST_F(WithGameTests, Trig) {
"0\n"});
}
TEST_F(WithGameTests, InlinedPackedBasics) {
runner.run_static_test(env, testCategory, "inlined-packed-basics.gc",
{"rec stride: 48\n"
"offset of float: 40\n"
"offset: 16\n"
"offset2: 184\n"
"array: #x0\n"
"first: #x0\n"
"0\n"});
}
// VECTOR FLOAT TESTS
// ---- One off Tests