mirror of
https://github.com/open-goal/jak-project
synced 2026-05-28 00:16:20 -04:00
[decompiler] Make addition nicer (#733)
* temp * update refs * update reference * fix tests
This commit is contained in:
@@ -270,17 +270,11 @@ TEST_F(FormRegressionTest, ExprMethod9Thread) {
|
||||
" )\n"
|
||||
" ((=\n"
|
||||
" (-> a2-0 heap-cur)\n"
|
||||
" (+\n"
|
||||
" (+ (+ (-> arg0 stack-size) -4) (the-as int (-> arg0 type size)))\n"
|
||||
" (the-as int arg0)\n"
|
||||
" )\n"
|
||||
" (+ (+ (-> arg0 stack-size) -4 (-> arg0 type size)) (the-as int arg0))\n"
|
||||
" )\n"
|
||||
" (set!\n"
|
||||
" (-> a2-0 heap-cur)\n"
|
||||
" (the-as\n"
|
||||
" pointer\n"
|
||||
" (+ (+ (+ arg1 -4) (the-as int (-> arg0 type size))) (the-as int arg0))\n"
|
||||
" )\n"
|
||||
" (the-as pointer (+ (+ arg1 -4 (-> arg0 type size)) (the-as int arg0)))\n"
|
||||
" )\n"
|
||||
" (set! (-> arg0 stack-size) arg1)\n"
|
||||
" )\n"
|
||||
@@ -383,7 +377,7 @@ TEST_F(FormRegressionTest, ExprMethod5CpuThread) {
|
||||
" jr ra\n"
|
||||
" daddu sp, sp, r0";
|
||||
std::string type = "(function cpu-thread int)";
|
||||
std::string expected = "(the-as int (+ (-> arg0 type size) (the-as uint (-> arg0 stack-size))))";
|
||||
std::string expected = "(the-as int (+ (-> arg0 type size) (-> arg0 stack-size)))";
|
||||
test_with_expr(func, type, expected, false);
|
||||
}
|
||||
|
||||
@@ -638,11 +632,7 @@ TEST_F(FormRegressionTest, ExprMethod0Process) {
|
||||
std::string type = "(function symbol type basic int process)";
|
||||
std::string expected =
|
||||
"(let ((v0-0 (if (= (-> arg0 type) symbol)\n"
|
||||
" (object-new\n"
|
||||
" arg0\n"
|
||||
" arg1\n"
|
||||
" (the-as int (+ (-> process size) (the-as uint arg3)))\n"
|
||||
" )\n"
|
||||
" (object-new arg0 arg1 (the-as int (+ (-> process size) arg3)))\n"
|
||||
" (+ (the-as int arg0) 4)\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
@@ -766,8 +756,7 @@ TEST_F(FormRegressionTest, ExprMethod5Process) {
|
||||
" jr ra\n"
|
||||
" daddu sp, sp, r0";
|
||||
std::string type = "(function process int)";
|
||||
std::string expected =
|
||||
"(the-as int (+ (-> process size) (the-as uint (-> arg0 allocated-length))))";
|
||||
std::string expected = "(the-as int (+ (-> process size) (-> arg0 allocated-length)))";
|
||||
test_with_expr(func, type, expected);
|
||||
}
|
||||
|
||||
@@ -1250,13 +1239,7 @@ TEST_F(FormRegressionTest, ExprMethod0DeadPoolHeap) {
|
||||
" (object-new\n"
|
||||
" arg0\n"
|
||||
" arg1\n"
|
||||
" (the-as\n"
|
||||
" int\n"
|
||||
" (+\n"
|
||||
" (+ (-> arg1 size) (the-as uint (logand -16 (+ (* 12 arg3) 15))))\n"
|
||||
" (the-as uint arg4)\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
" (the-as int (+ (-> arg1 size) (logand -16 (+ (* 12 arg3) 15)) arg4))\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
@@ -1287,7 +1270,7 @@ TEST_F(FormRegressionTest, ExprMethod0DeadPoolHeap) {
|
||||
" (set! (-> obj first-shrink) #f)\n"
|
||||
" (set!\n"
|
||||
" (-> obj heap base)\n"
|
||||
" (the-as pointer (logand -16 (+ (+ (the-as int obj) 115) (* 12 arg3))))\n"
|
||||
" (the-as pointer (logand -16 (+ (the-as int obj) 115 (* 12 arg3))))\n"
|
||||
" )\n"
|
||||
" (set! (-> obj heap current) (-> obj heap base))\n"
|
||||
" (set! (-> obj heap top) (&+ (-> obj heap base) arg4))\n"
|
||||
@@ -1328,10 +1311,7 @@ TEST_F(FormRegressionTest, ExprMethod22DeadPoolHeap) {
|
||||
std::string expected =
|
||||
"(the-as pointer (if (-> arg1 process)\n"
|
||||
" (+\n"
|
||||
" (+\n"
|
||||
" (+ (-> arg1 process allocated-length) -4)\n"
|
||||
" (the-as int (-> process size))\n"
|
||||
" )\n"
|
||||
" (+ (-> arg1 process allocated-length) -4 (-> process size))\n"
|
||||
" (the-as int (-> arg1 process))\n"
|
||||
" )\n"
|
||||
" (-> arg0 heap base)\n"
|
||||
@@ -2004,40 +1984,33 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPoolHeap) {
|
||||
" daddiu sp, sp, 112";
|
||||
std::string type = "(function dead-pool-heap type int process)";
|
||||
std::string expected =
|
||||
"(let\n"
|
||||
" ((s4-0 (-> arg0 dead-list next)) (s3-0 (the-as process #f)))\n"
|
||||
" (let\n"
|
||||
" ((s1-0 (find-gap-by-size arg0 (the-as int (+ (-> process size) (the-as uint arg2))))))\n"
|
||||
"(let ((s4-0 (-> arg0 dead-list next))\n"
|
||||
" (s3-0 (the-as process #f))\n"
|
||||
" )\n"
|
||||
" (let ((s1-0 (find-gap-by-size arg0 (the-as int (+ (-> process size) arg2)))))\n"
|
||||
" (cond\n"
|
||||
" ((and s4-0 s1-0)\n"
|
||||
" (set! (-> arg0 dead-list next) (-> s4-0 next))\n"
|
||||
" (let\n"
|
||||
" ((v1-5 (-> s1-0 next)))\n"
|
||||
" (let ((v1-5 (-> s1-0 next)))\n"
|
||||
" (set! (-> s1-0 next) s4-0)\n"
|
||||
" (set! (-> s4-0 next) v1-5)\n"
|
||||
" (if v1-5 (set! (-> v1-5 prev) s4-0))\n"
|
||||
" (if v1-5\n"
|
||||
" (set! (-> v1-5 prev) s4-0)\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
" (set! (-> s4-0 prev) s1-0)\n"
|
||||
" (if\n"
|
||||
" (= s1-0 (-> arg0 alive-list prev))\n"
|
||||
" (if (= s1-0 (-> arg0 alive-list prev))\n"
|
||||
" (set! (-> arg0 alive-list prev) s4-0)\n"
|
||||
" )\n"
|
||||
" (let\n"
|
||||
" ((a0-4 (gap-location arg0 s1-0)))\n"
|
||||
" (let ((a0-4 (gap-location arg0 s1-0)))\n"
|
||||
" (set!\n"
|
||||
" s3-0\n"
|
||||
" ((method-of-type process new)\n"
|
||||
" (the-as symbol a0-4)\n"
|
||||
" process\n"
|
||||
" (quote process)\n"
|
||||
" arg2\n"
|
||||
" )\n"
|
||||
" ((method-of-type process new) (the-as symbol a0-4) process 'process arg2)\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
" (set! (-> s4-0 process) s3-0)\n"
|
||||
" (set! (-> s3-0 ppointer) (&-> s4-0 process))\n"
|
||||
" (if\n"
|
||||
" (= (-> arg0 first-gap) s1-0)\n"
|
||||
" (if (= (-> arg0 first-gap) s1-0)\n"
|
||||
" (set! (-> arg0 first-gap) (find-gap arg0 s4-0))\n"
|
||||
" )\n"
|
||||
" (if\n"
|
||||
@@ -2052,11 +2025,9 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPoolHeap) {
|
||||
" (set! (-> arg0 child) (&-> s4-0 process))\n"
|
||||
" )\n"
|
||||
" (else\n"
|
||||
" (when\n"
|
||||
" (and *debug-segment* (!= arg0 *debug-dead-pool*))\n"
|
||||
" (when (and *debug-segment* (!= arg0 *debug-dead-pool*))\n"
|
||||
" (set! s3-0 (get-process *debug-dead-pool* arg1 arg2))\n"
|
||||
" (if\n"
|
||||
" (and s3-0 *vis-boot*)\n"
|
||||
" (if (and s3-0 *vis-boot*)\n"
|
||||
" (format\n"
|
||||
" 0\n"
|
||||
" \"WARNING: ~A ~A had to be allocated from the debug pool, because ~A was "
|
||||
@@ -2070,8 +2041,7 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPoolHeap) {
|
||||
" )\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
" (if\n"
|
||||
" s3-0\n"
|
||||
" (if s3-0\n"
|
||||
" (set! (-> s3-0 type) arg1)\n"
|
||||
" (format\n"
|
||||
" 0\n"
|
||||
|
||||
Reference in New Issue
Block a user